From 0ad958a84136e76cbe47be045fe32c8fbbf43d5f Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Thu, 14 Jan 2016 12:29:45 +0100 Subject: [PATCH] Bug 9754: koha-remove optionally includes var/lib and var/spool Currently, the files in the folder /var/lib/koha/[instance] and also in /var/spool/koha/[instance] are not removed. This patch adds the option -p|--purge-all to include those two directories when removing files. Note: There was a small bug in the for loop. On the -k line the extra shift statement is one too much. NOTE: Verify that you use the adjusted koha-remove in the test plan and not accidentally an older version of this script. Test plan: [1] Create an instance test. [2] Run koha-remove and verify that /var/lib/koha/test still exists. [3] Create an instance test2. [4] Run koha-remove -k -p and verify that the sql database still exists but the two instance folders in var/lib/koha and var/spool/koha are gone. Signed-off-by: Chris Cormack --- debian/scripts/koha-remove | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/debian/scripts/koha-remove b/debian/scripts/koha-remove index 528db75..c8f0380 100755 --- a/debian/scripts/koha-remove +++ b/debian/scripts/koha-remove @@ -27,12 +27,14 @@ else exit 1 fi -args=$(getopt -l keep-mysql -o k -n $0 -- "$@") +args=$(getopt -l keep-mysql,purge-all -o kp -n $0 -- "$@") eval set -- $args while [ ! -z "$1" ] do case "$1" in - -k|--keep-mysql) keepmysql=1; shift;; + -k|--keep-mysql) keepmysql=1;; + -p|--purge-all) purgeall=1;; + # purgeall removes all instance files in var/lib/koha and var/spool/koha --) shift; break;; *) break;; esac @@ -102,6 +104,10 @@ eof rm -r "/var/log/koha/$name" [ -d "/var/run/koha/$name" ] && \ rm -r "/var/run/koha/$name" + [ "$purgeall" = "1" ] && [ -d "/var/lib/koha/$name" ] && \ + rm -r "/var/lib/koha/$name" + [ "$purgeall" = "1" ] && [ -d "/var/spool/koha/$name" ] && \ + rm -r "/var/spool/koha/$name" getent passwd "$name-koha" > /dev/null && deluser --quiet "$name-koha" # in case the site has already been disabled, we don't want to break the loop now. a2dissite "$name" > /dev/null 2>&1 || a2dissite "${name}.conf" > /dev/null 2>&1 || /bin/true -- 2.7.0.rc3