remove all data during purge after user confirmation
This commit is contained in:
parent
5e31e3a779
commit
f1432c8088
2 changed files with 43 additions and 6 deletions
9
debian/gitlab.templates
vendored
9
debian/gitlab.templates
vendored
|
@ -57,3 +57,12 @@ _Description: Use Let's Encrypt?
|
||||||
Note: letsencrypt does not have a usable nginx plugin currently, so
|
Note: letsencrypt does not have a usable nginx plugin currently, so
|
||||||
certificates must be renewed manually after 3 months, when current
|
certificates must be renewed manually after 3 months, when current
|
||||||
letsencrypt certificate expire.
|
letsencrypt certificate expire.
|
||||||
|
|
||||||
|
Template: gitlab/purge
|
||||||
|
Type: boolean
|
||||||
|
Default: yes
|
||||||
|
_Description: Remove all data?
|
||||||
|
Do you want to remove all data of this Gitlab instance?
|
||||||
|
.
|
||||||
|
This will permanently remove all data of this Gitlab instance such as database,
|
||||||
|
uploaded files, SSH public keys etc.
|
||||||
|
|
36
debian/postrm
vendored
36
debian/postrm
vendored
|
@ -14,7 +14,9 @@ set -e
|
||||||
# Ensure the menu system is updated
|
# Ensure the menu system is updated
|
||||||
|
|
||||||
# Read and export debian specific configuration
|
# Read and export debian specific configuration
|
||||||
# Only exported variables will be passed on to gitlab app
|
gitlab_debian_conf=/etc/gitlab/gitlab-debian.conf
|
||||||
|
test -f ${gitlab_debian_conf} && export $(cat ${gitlab_debian_conf})
|
||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
remove)
|
remove)
|
||||||
# This package is being removed, but its configuration has not yet
|
# This package is being removed, but its configuration has not yet
|
||||||
|
@ -34,13 +36,31 @@ case "$1" in
|
||||||
if [ -e /usr/share/debconf/confmodule ]; then
|
if [ -e /usr/share/debconf/confmodule ]; then
|
||||||
# Source debconf library.
|
# Source debconf library.
|
||||||
. /usr/share/debconf/confmodule
|
. /usr/share/debconf/confmodule
|
||||||
|
|
||||||
|
# Do you want to remove all data?
|
||||||
|
db_input high gitlab/purge || true
|
||||||
|
db_go
|
||||||
|
|
||||||
|
# Check if we should remove data?
|
||||||
|
db_get gitlab/purge
|
||||||
|
if [ "${RET}" = "true" ]; then
|
||||||
|
rm -rf /var/lib/gitlab/shared
|
||||||
|
rm -rf /var/lib/gitlab/public
|
||||||
|
rm -rf /var/lib/gitlab/db
|
||||||
|
rm -rf /var/lib/gitlab/repositories
|
||||||
|
rm -rf /var/lib/gitlab/secrets.yml
|
||||||
|
rm -rf /var/lib/gitlab/Gemfile.lock
|
||||||
|
rm -rf /var/log/gitlab
|
||||||
|
rm -rf /var/cache/gitlab
|
||||||
|
rm -rf /run/gitlab
|
||||||
|
userdel -r ${gitlab_user}
|
||||||
|
su postgres -c "dropdb gitlab_production"
|
||||||
|
fi
|
||||||
|
|
||||||
# Remove my changes to the db.
|
# Remove my changes to the db.
|
||||||
db_purge
|
db_purge
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Reading gitlab-debian.conf..."
|
|
||||||
gitlab_debian_conf=/etc/gitlab/gitlab-debian.conf
|
|
||||||
test -f ${gitlab_debian_conf} && export $(cat ${gitlab_debian_conf})
|
|
||||||
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}..."
|
test -f ${nginx_site} && echo "Found nginx site configuration at ${nginx_site}..."
|
||||||
|
@ -72,6 +92,7 @@ case "$1" in
|
||||||
test -n "${gitlab_tmpfiles}" && ucf --purge ${gitlab_tmpfiles}
|
test -n "${gitlab_tmpfiles}" && ucf --purge ${gitlab_tmpfiles}
|
||||||
test -n "${gitlab_shell_config}" && ucf -purge ${gitlab_shell_config}
|
test -n "${gitlab_shell_config}" && ucf -purge ${gitlab_shell_config}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if which ucfr >/dev/null; then
|
if which ucfr >/dev/null; then
|
||||||
test -n "${nginx_site}" && ucfr --purge gitlab ${nginx_site}
|
test -n "${nginx_site}" && ucfr --purge gitlab ${nginx_site}
|
||||||
test -n "${gitlab_debian_conf}" && ucfr --purge gitlab ${gitlab_debian_conf}
|
test -n "${gitlab_debian_conf}" && ucfr --purge gitlab ${gitlab_debian_conf}
|
||||||
|
@ -83,6 +104,13 @@ case "$1" in
|
||||||
# remove generated assets
|
# remove generated assets
|
||||||
rm -rf /var/lib/gitlab/public/assets
|
rm -rf /var/lib/gitlab/public/assets
|
||||||
|
|
||||||
|
# Remove private copies of configuration files
|
||||||
|
rm -f ${nginx_site_private}
|
||||||
|
rm -f ${gitlab_debian_conf_private}
|
||||||
|
rm -f ${gitlab_yml_private}
|
||||||
|
rm -f ${gitlab_tmpfiles_private}
|
||||||
|
rm -f ${gitlab_shell_config_private}
|
||||||
|
|
||||||
# cleanup complete
|
# cleanup complete
|
||||||
exit 0
|
exit 0
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue