make postrm idempotent
This commit is contained in:
parent
c9148dc95f
commit
a99872e5ec
1 changed files with 23 additions and 23 deletions
46
debian/postrm
vendored
46
debian/postrm
vendored
|
@ -50,23 +50,23 @@ case "$1" in
|
||||||
if [ "${RET}" = "true" ]; then
|
if [ "${RET}" = "true" ]; then
|
||||||
if [ -d ${gitlab_data_dir} ]; then
|
if [ -d ${gitlab_data_dir} ]; then
|
||||||
for i in shared public db repositories secrets.yml Gemfile.lock; do
|
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
|
done
|
||||||
fi
|
fi
|
||||||
test -e ${gitlab_log_dir} && rm -rf ${gitlab_log_dir}
|
if [ -e ${gitlab_log_dir} ]; then rm -rf ${gitlab_log_dir}; fi
|
||||||
test -e ${gitlab_cache_path} && rm -rf ${gitlab_cache_path}
|
if [ -e ${gitlab_cache_path} ]; then rm -rf ${gitlab_cache_path}; fi
|
||||||
test -e ${gitlab_pid_path} && rm -rf ${gitlab_pid_path}
|
if [ -e ${gitlab_pid_path} ]; then rm -rf ${gitlab_pid_path}; fi
|
||||||
test -e ${gitlab_data_dir} && rm -rf ${gitlab_data_dir}
|
if [ -e ${gitlab_data_dir} ]; then rm -rf ${gitlab_data_dir}; fi
|
||||||
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
|
||||||
echo "Removing Database: gitlab_production"
|
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
|
else
|
||||||
echo "dropdb command not found. Hence not removing database."
|
echo "dropdb command not found. Hence not removing database."
|
||||||
fi
|
fi
|
||||||
echo "Removing user: ${gitlab_user}"
|
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
|
else
|
||||||
echo "gitlab_user not set. Hence not removing user."
|
echo "gitlab_user not set. Hence not removing user."
|
||||||
fi
|
fi
|
||||||
|
@ -79,7 +79,7 @@ case "$1" in
|
||||||
|
|
||||||
nginx_site="/etc/nginx/sites-available/${GITLAB_HOST}"
|
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
|
# we mimic dpkg as closely as possible, so we remove configuration
|
||||||
|
@ -94,27 +94,27 @@ case "$1" in
|
||||||
done
|
done
|
||||||
|
|
||||||
# remove the configuration file itself
|
# remove the configuration file itself
|
||||||
test -f ${nginx_site} && rm -f ${nginx_site}
|
if [ -f ${nginx_site} ]; then rm -f ${nginx_site}; fi
|
||||||
test -f ${gitlab_debian_conf} && rm -f ${gitlab_debian_conf}
|
if [ -f ${gitlab_debian_conf} ]; then rm -f ${gitlab_debian_conf}; fi
|
||||||
test -f ${gitlab_yml} && rm -f ${gitlab_yml}
|
if [ -f ${gitlab_yml} ]; then rm -f ${gitlab_yml}; fi
|
||||||
test -f ${gitlab_tmpfiles} && rm -f ${gitlab_tmpfiles}
|
if [ -f ${gitlab_tmpfiles} ]; then rm -f ${gitlab_tmpfiles}; fi
|
||||||
test -f ${gitlab_shell_config} && rm -f ${gitlab_shell_config}
|
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
|
||||||
test -n "${nginx_site}" && ucf --purge ${nginx_site}
|
if [ -n "${nginx_site}" ]; then ucf --purge ${nginx_site}; fi
|
||||||
test -n "${gitlab_debian_conf}" && ucf --purge ${gitlab_debian_conf}
|
if [ -n "${gitlab_debian_conf}" ]; then ucf --purge ${gitlab_debian_conf}; fi
|
||||||
test -n "${gitlab_yml}" && ucf --purge ${gitlab_yml}
|
if [ -n "${gitlab_yml}" ]; then ucf --purge ${gitlab_yml}; fi
|
||||||
test -n "${gitlab_tmpfiles}" && ucf --purge ${gitlab_tmpfiles}
|
if [ -n "${gitlab_tmpfiles}" ]; then ucf --purge ${gitlab_tmpfiles}; fi
|
||||||
test -n "${gitlab_shell_config}" && ucf -purge ${gitlab_shell_config}
|
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
|
||||||
test -n "${nginx_site}" && ucfr --purge gitlab ${nginx_site}
|
if [ -n "${nginx_site}" ]; then ucfr --purge gitlab ${nginx_site}; fi
|
||||||
test -n "${gitlab_debian_conf}" && ucfr --purge gitlab ${gitlab_debian_conf}
|
if [ -n "${gitlab_debian_conf}" ]; then ucfr --purge gitlab ${gitlab_debian_conf}; fi
|
||||||
test -n "${gitlab_yml}" && ucfr --purge gitlab ${gitlab_yml}
|
if [ -n "${gitlab_yml}" ]; then ucfr --purge gitlab ${gitlab_yml}; fi
|
||||||
test -n "${gitlab_tmpfiles}" && ucfr --purge gitlab ${gitlab_tmpfiles}
|
if [ -n "${gitlab_tmpfiles}" ]; then ucfr --purge gitlab ${gitlab_tmpfiles}; fi
|
||||||
test -n "${gitlab_shell_config}" && ucfr -purge gitlab ${gitlab_shell_config}
|
if [ -n "${gitlab_shell_config}" ]; then ucfr -purge gitlab ${gitlab_shell_config}; fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# remove generated assets
|
# remove generated assets
|
||||||
|
|
Loading…
Reference in a new issue