You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by rn...@apache.org on 2019/09/03 13:44:39 UTC

[couchdb-pkg] branch postrm_remove_databases created (now c3b71dd)

This is an automated email from the ASF dual-hosted git repository.

rnewson pushed a change to branch postrm_remove_databases
in repository https://gitbox.apache.org/repos/asf/couchdb-pkg.git.


      at c3b71dd  Add extra protection to databases during package purge

This branch includes the following new commits:

     new c3b71dd  Add extra protection to databases during package purge

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[couchdb-pkg] 01/01: Add extra protection to databases during package purge

Posted by rn...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rnewson pushed a commit to branch postrm_remove_databases
in repository https://gitbox.apache.org/repos/asf/couchdb-pkg.git

commit c3b71ddef408d0d1bda1265d79b667ce85bd5549
Author: Robert Newson <rn...@apache.org>
AuthorDate: Tue Sep 3 14:44:09 2019 +0100

    Add extra protection to databases during package purge
---
 debian/couchdb.postrm    | 29 ++++++++++++++++++++---------
 debian/couchdb.templates |  7 +++++++
 2 files changed, 27 insertions(+), 9 deletions(-)

diff --git a/debian/couchdb.postrm b/debian/couchdb.postrm
index c844e43..3db29fc 100644
--- a/debian/couchdb.postrm
+++ b/debian/couchdb.postrm
@@ -19,19 +19,30 @@ case $1 in
         if test -d "/opt/couchdb/etc"; then
             rm -rf "/opt/couchdb/etc"
         fi
-        if test -d "/var/lib/couchdb"; then
-            rm -rf "/var/lib/couchdb"
-        fi
         if test -d "/var/log/couchdb"; then
             rm -rf "/var/log/couchdb"
         fi
-        pkill -u couchdb >/dev/null 2>&1 || true
-        if getent passwd couchdb > /dev/null; then
-            deluser couchdb >/dev/null 2>&1
-        fi
-        if getent group couchdb > /dev/null; then
-            delgroup couchdb >/dev/null 2>&1
+
+        db_input high couchdb/postrm_remove_databases || true
+        db_go || true
+        db_get couchdb/postrm_remove_databases || true
+
+        if [ "$RET" = "true" ]; then
+            if test -d "/var/lib/couchdb"; then
+                rm -rf "/var/lib/couchdb"
+            fi
+
+            # If we didn't delete the data, we should
+            # keep the uid and gid too.
+            if getent passwd couchdb > /dev/null; then
+                deluser couchdb >/dev/null 2>&1
+            fi
+            if getent group couchdb > /dev/null; then
+                delgroup couchdb >/dev/null 2>&1
+            fi
         fi
+
+        pkill -u couchdb >/dev/null 2>&1 || true
         db_reset couchdb/mode
         db_reset couchdb/nodename
         db_reset couchdb/cookie
diff --git a/debian/couchdb.templates b/debian/couchdb.templates
index 0fc5acd..2e927e2 100644
--- a/debian/couchdb.templates
+++ b/debian/couchdb.templates
@@ -94,3 +94,10 @@ _Description: CouchDB 1.x databases found
  /var/lib/couchdb directory. These need migration to be used in
  CouchDB 2.x and forward. Use the `couchup' utility to assist in
  the migration process.
+
+Template: couchdb/postrm_remove_databases
+Type: boolean
+Default: false
+_Description: Remove all CouchDB databases?
+ The /var/lib/couchdb directory containg all CouchDB databases will
+ be removed.