[DRE-commits] [gitlab] 12/16: remove all data during purge after user confirmation

Praveen Arimbrathodiyil praveen at moszumanska.debian.org
Thu Feb 16 12:09:32 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 f1432c80880bee0ea268f76553167650c9f7bc2a
Author: Praveen Arimbrathodiyil <praveen at debian.org>
Date:   Thu Feb 16 15:53:38 2017 +0530

    remove all data during purge after user confirmation
---
 debian/gitlab.templates |  9 +++++++++
 debian/postrm           | 40 ++++++++++++++++++++++++++++++++++------
 2 files changed, 43 insertions(+), 6 deletions(-)

diff --git a/debian/gitlab.templates b/debian/gitlab.templates
index 97c0df6..310203f 100644
--- a/debian/gitlab.templates
+++ b/debian/gitlab.templates
@@ -57,3 +57,12 @@ _Description: Use Let's Encrypt?
  Note: letsencrypt does not have a usable nginx plugin currently, so
  certificates must be renewed manually after 3 months, when current
  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.
diff --git a/debian/postrm b/debian/postrm
index 20a580b..2b3f3ba 100644
--- a/debian/postrm
+++ b/debian/postrm
@@ -14,7 +14,9 @@ set -e
 # Ensure the menu system is updated
 
 # 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
   remove)
     # 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
       # Source debconf library.
       . /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.
       db_purge
     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}"
 
     test -f ${nginx_site} && echo "Found nginx site configuration at ${nginx_site}..."
@@ -70,8 +90,9 @@ case "$1" in
       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}
-    fi    
+      test -n "${gitlab_shell_config}" && ucf -purge ${gitlab_shell_config}        
+    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}
@@ -82,6 +103,13 @@ case "$1" in
 
     # remove generated 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
     exit 0

-- 
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