[DRE-commits] [gitlab] 03/05: check varibales are defined before using them
Praveen Arimbrathodiyil
praveen at moszumanska.debian.org
Mon Apr 17 09:58:27 UTC 2017
This is an automated email from the git hooks/post-receive script.
praveen pushed a commit to branch master
in repository gitlab.
commit 8ed3768bb363967119ef86b6f70a90051b0926fc
Author: Praveen Arimbrathodiyil <praveen at debian.org>
Date: Mon Apr 17 11:05:50 2017 +0530
check varibales are defined before using them
---
debian/postrm | 61 +++++++++++++++++++++++++++++------------------------------
1 file changed, 30 insertions(+), 31 deletions(-)
diff --git a/debian/postrm b/debian/postrm
index 4da11fb..cf629cc 100644
--- a/debian/postrm
+++ b/debian/postrm
@@ -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}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ruby-extras/gitlab.git
More information about the Pkg-ruby-extras-commits
mailing list