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
61
debian/postrm
vendored
61
debian/postrm
vendored
|
@ -18,8 +18,18 @@ gitlab_debian_defaults=/var/lib/gitlab/gitlab-debian.defaults
|
|||
# Ensure the menu system is updated
|
||||
|
||||
# Read debian specific configuration
|
||||
test -f ${gitlab_debian_conf} && . ${gitlab_debian_conf}
|
||||
test -f ${gitlab_debian_defaults} && . ${gitlab_debian_defaults}
|
||||
if [ -f ${gitlab_debian_conf} ]; then . ${gitlab_debian_conf}; fi
|
||||
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
|
||||
remove)
|
||||
|
@ -53,10 +63,10 @@ case "$1" in
|
|||
if [ -e ${gitlab_data_dir}/$i ]; then rm -rf ${gitlab_data_dir}/$i; fi
|
||||
done
|
||||
fi
|
||||
if [ -e ${gitlab_log_dir} ]; then rm -rf ${gitlab_log_dir}; fi
|
||||
if [ -e ${gitlab_cache_path} ]; then rm -rf ${gitlab_cache_path}; fi
|
||||
if [ -e ${gitlab_pid_path} ]; then rm -rf ${gitlab_pid_path}; fi
|
||||
if [ -e ${gitlab_data_dir} ]; then rm -rf ${gitlab_data_dir}; fi
|
||||
for i in ${gitlab_log_dir} ${gitlab_cache_path} ${gitlab_pid_path} \
|
||||
${gitlab_data_dir}; do
|
||||
safely_remove $i
|
||||
done
|
||||
if [ ! -z "${gitlab_user}" ]; then
|
||||
# Do only if gitlab_user is set
|
||||
if command -v dropdb >/dev/null; then
|
||||
|
@ -70,7 +80,7 @@ case "$1" in
|
|||
else
|
||||
echo "gitlab_user not set. Hence not removing user."
|
||||
fi
|
||||
rm -rf ${gitlab_ssl_path}
|
||||
safely_remove ${gitlab_ssl_path}
|
||||
fi
|
||||
|
||||
# Remove my changes to the db.
|
||||
|
@ -93,32 +103,21 @@ case "$1" in
|
|||
rm -f ${gitlab_shell_config}$ext
|
||||
done
|
||||
|
||||
# remove the configuration file itself
|
||||
if [ -f ${nginx_site} ]; then rm -f ${nginx_site}; fi
|
||||
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
|
||||
if which ucf >/dev/null; then
|
||||
if [ -n "${nginx_site}" ]; then ucf --purge ${nginx_site}; 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
|
||||
|
||||
if which ucfr >/dev/null; then
|
||||
if [ -n "${nginx_site}" ]; then ucfr --purge gitlab ${nginx_site}; 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
|
||||
for i in ${nginx_site} ${gitlab_debian_conf} ${gitlab_yml} \
|
||||
${gitlab_tmpfiles} ${gitlab_shell_config}; do
|
||||
# remove the configuration file itself
|
||||
safely_remove $i
|
||||
# and finally clear it out from the ucf database
|
||||
if which ucf >/dev/null; then
|
||||
if [ -n "$i" ]; then ucf --purge $i; fi
|
||||
fi
|
||||
if which ucfr >/dev/null; then
|
||||
if [ -n "$i" ]; then ucfr --purge gitlab $i; fi
|
||||
fi
|
||||
done
|
||||
|
||||
# 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
|
||||
rm -f ${nginx_site_private}
|
||||
|
|
Loading…
Reference in a new issue