check varibales are defined before using them
This commit is contained in:
parent
20c77e7cb7
commit
8ed3768bb3
1 changed files with 30 additions and 31 deletions
49
debian/postrm
vendored
49
debian/postrm
vendored
|
@ -18,8 +18,18 @@ gitlab_debian_defaults=/var/lib/gitlab/gitlab-debian.defaults
|
||||||
# Ensure the menu system is updated
|
# Ensure the menu system is updated
|
||||||
|
|
||||||
# Read debian specific configuration
|
# Read debian specific configuration
|
||||||
test -f ${gitlab_debian_conf} && . ${gitlab_debian_conf}
|
if [ -f ${gitlab_debian_conf} ]; then . ${gitlab_debian_conf}; fi
|
||||||
test -f ${gitlab_debian_defaults} && . ${gitlab_debian_defaults}
|
if [ -f ${gitlab_debian_defaults}; then . ${gitlab_debian_defaults}; fi
|
||||||
|
|
||||||
|
safely_remove() {
|
||||||
|
CANDIDATE_DIR=$1
|
||||||
|
if [ -n ${CANDIDATE_DIR} ];then
|
||||||
|
if [ -e ${CANDIDATE_DIR} ]; then
|
||||||
|
echo "Removing $i..."
|
||||||
|
rm -rf ${CANDIDATE_DIR}
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
remove)
|
remove)
|
||||||
|
@ -53,10 +63,10 @@ case "$1" in
|
||||||
if [ -e ${gitlab_data_dir}/$i ]; then rm -rf ${gitlab_data_dir}/$i; fi
|
if [ -e ${gitlab_data_dir}/$i ]; then rm -rf ${gitlab_data_dir}/$i; fi
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
if [ -e ${gitlab_log_dir} ]; then rm -rf ${gitlab_log_dir}; fi
|
for i in ${gitlab_log_dir} ${gitlab_cache_path} ${gitlab_pid_path} \
|
||||||
if [ -e ${gitlab_cache_path} ]; then rm -rf ${gitlab_cache_path}; fi
|
${gitlab_data_dir}; do
|
||||||
if [ -e ${gitlab_pid_path} ]; then rm -rf ${gitlab_pid_path}; fi
|
safely_remove $i
|
||||||
if [ -e ${gitlab_data_dir} ]; then rm -rf ${gitlab_data_dir}; fi
|
done
|
||||||
if [ ! -z "${gitlab_user}" ]; then
|
if [ ! -z "${gitlab_user}" ]; then
|
||||||
# Do only if gitlab_user is set
|
# Do only if gitlab_user is set
|
||||||
if command -v dropdb >/dev/null; then
|
if command -v dropdb >/dev/null; then
|
||||||
|
@ -70,7 +80,7 @@ case "$1" in
|
||||||
else
|
else
|
||||||
echo "gitlab_user not set. Hence not removing user."
|
echo "gitlab_user not set. Hence not removing user."
|
||||||
fi
|
fi
|
||||||
rm -rf ${gitlab_ssl_path}
|
safely_remove ${gitlab_ssl_path}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Remove my changes to the db.
|
# Remove my changes to the db.
|
||||||
|
@ -93,32 +103,21 @@ case "$1" in
|
||||||
rm -f ${gitlab_shell_config}$ext
|
rm -f ${gitlab_shell_config}$ext
|
||||||
done
|
done
|
||||||
|
|
||||||
|
for i in ${nginx_site} ${gitlab_debian_conf} ${gitlab_yml} \
|
||||||
|
${gitlab_tmpfiles} ${gitlab_shell_config}; do
|
||||||
# remove the configuration file itself
|
# remove the configuration file itself
|
||||||
if [ -f ${nginx_site} ]; then rm -f ${nginx_site}; fi
|
safely_remove $i
|
||||||
if [ -f ${gitlab_debian_conf} ]; then rm -f ${gitlab_debian_conf}; fi
|
|
||||||
if [ -f ${gitlab_yml} ]; then rm -f ${gitlab_yml}; fi
|
|
||||||
if [ -f ${gitlab_tmpfiles} ]; then rm -f ${gitlab_tmpfiles}; fi
|
|
||||||
if [ -f ${gitlab_shell_config} ]; then rm -f ${gitlab_shell_config}; fi
|
|
||||||
|
|
||||||
# and finally clear it out from the ucf database
|
# and finally clear it out from the ucf database
|
||||||
if which ucf >/dev/null; then
|
if which ucf >/dev/null; then
|
||||||
if [ -n "${nginx_site}" ]; then ucf --purge ${nginx_site}; fi
|
if [ -n "$i" ]; then ucf --purge $i; fi
|
||||||
if [ -n "${gitlab_debian_conf}" ]; then ucf --purge ${gitlab_debian_conf}; fi
|
|
||||||
if [ -n "${gitlab_yml}" ]; then ucf --purge ${gitlab_yml}; fi
|
|
||||||
if [ -n "${gitlab_tmpfiles}" ]; then ucf --purge ${gitlab_tmpfiles}; fi
|
|
||||||
if [ -n "${gitlab_shell_config}"; then ucf -purge ${gitlab_shell_config}; fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if which ucfr >/dev/null; then
|
if which ucfr >/dev/null; then
|
||||||
if [ -n "${nginx_site}" ]; then ucfr --purge gitlab ${nginx_site}; fi
|
if [ -n "$i" ]; then ucfr --purge gitlab $i; fi
|
||||||
if [ -n "${gitlab_debian_conf}" ]; then ucfr --purge gitlab ${gitlab_debian_conf}; fi
|
|
||||||
if [ -n "${gitlab_yml}" ]; then ucfr --purge gitlab ${gitlab_yml}; fi
|
|
||||||
if [ -n "${gitlab_tmpfiles}" ]; then ucfr --purge gitlab ${gitlab_tmpfiles}; fi
|
|
||||||
if [ -n "${gitlab_shell_config}" ]; then ucfr -purge gitlab ${gitlab_shell_config}; fi
|
|
||||||
fi
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
# remove generated assets
|
# remove generated assets
|
||||||
rm -rf ${gitlab_data_dir}/public/assets
|
if [ -n ${gitlab_data_dir}]; then safely_remove ${gitlab_data_dir}/public/assets; fi
|
||||||
|
|
||||||
# Remove private copies of configuration files
|
# Remove private copies of configuration files
|
||||||
rm -f ${nginx_site_private}
|
rm -f ${nginx_site_private}
|
||||||
|
|
Loading…
Reference in a new issue