[DRE-commits] [gitlab] 01/05: make postrm idempotent
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 a99872e5ec14d2b7e5fa6672af7bb86ff0b353bf
Author: Praveen Arimbrathodiyil <praveen at debian.org>
Date: Mon Apr 17 10:09:55 2017 +0530
make postrm idempotent
---
debian/postrm | 46 +++++++++++++++++++++++-----------------------
1 file changed, 23 insertions(+), 23 deletions(-)
diff --git a/debian/postrm b/debian/postrm
index d5fd3b4..4da11fb 100644
--- a/debian/postrm
+++ b/debian/postrm
@@ -50,23 +50,23 @@ case "$1" in
if [ "${RET}" = "true" ]; then
if [ -d ${gitlab_data_dir} ]; then
for i in shared public db repositories secrets.yml Gemfile.lock; do
- test -e ${gitlab_data_dir}/$i && rm -rf ${gitlab_data_dir}/$i
+ if [ -e ${gitlab_data_dir}/$i ]; then rm -rf ${gitlab_data_dir}/$i; fi
done
fi
- test -e ${gitlab_log_dir} && rm -rf ${gitlab_log_dir}
- test -e ${gitlab_cache_path} && rm -rf ${gitlab_cache_path}
- test -e ${gitlab_pid_path} && rm -rf ${gitlab_pid_path}
- test -e ${gitlab_data_dir} && rm -rf ${gitlab_data_dir}
+ 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
if [ ! -z "${gitlab_user}" ]; then
# Do only if gitlab_user is set
if command -v dropdb >/dev/null; then
echo "Removing Database: gitlab_production"
- su ${gitlab_user} -c 'psql gitlab_production -c ""' && su postgres -c "dropdb gitlab_production"
+ if su ${gitlab_user} -c 'psql gitlab_production -c ""' ; then su postgres -c "dropdb gitlab_production"; fi
else
echo "dropdb command not found. Hence not removing database."
fi
echo "Removing user: ${gitlab_user}"
- id -u ${gitlab_user} && userdel -r ${gitlab_user}
+ if [ id -u ${gitlab_user} ]; then userdel -r ${gitlab_user}; fi
else
echo "gitlab_user not set. Hence not removing user."
fi
@@ -79,7 +79,7 @@ case "$1" in
nginx_site="/etc/nginx/sites-available/${GITLAB_HOST}"
- test -f ${nginx_site} && echo "Found nginx site configuration at ${nginx_site}..."
+ if [ -f ${nginx_site} ]; then echo "Found nginx site configuration at ${nginx_site}..."; fi
# we mimic dpkg as closely as possible, so we remove configuration
@@ -94,27 +94,27 @@ case "$1" in
done
# remove the configuration file itself
- test -f ${nginx_site} && rm -f ${nginx_site}
- test -f ${gitlab_debian_conf} && rm -f ${gitlab_debian_conf}
- test -f ${gitlab_yml} && rm -f ${gitlab_yml}
- test -f ${gitlab_tmpfiles} && rm -f ${gitlab_tmpfiles}
- test -f ${gitlab_shell_config} && rm -f ${gitlab_shell_config}
+ 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
- test -n "${nginx_site}" && ucf --purge ${nginx_site}
- test -n "${gitlab_debian_conf}" && ucf --purge ${gitlab_debian_conf}
- test -n "${gitlab_yml}" && ucf --purge ${gitlab_yml}
- test -n "${gitlab_tmpfiles}" && ucf --purge ${gitlab_tmpfiles}
- test -n "${gitlab_shell_config}" && ucf -purge ${gitlab_shell_config}
+ 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
- test -n "${nginx_site}" && ucfr --purge gitlab ${nginx_site}
- test -n "${gitlab_debian_conf}" && ucfr --purge gitlab ${gitlab_debian_conf}
- test -n "${gitlab_yml}" && ucfr --purge gitlab ${gitlab_yml}
- test -n "${gitlab_tmpfiles}" && ucfr --purge gitlab ${gitlab_tmpfiles}
- test -n "${gitlab_shell_config}" && ucfr -purge gitlab ${gitlab_shell_config}
+ 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
# remove generated assets
--
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