From c5cb615f9ce18b650a270e444dbc6868aa09fa0d 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 MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 Signed-off-by: Jonathan Druart Signed-off-by: Brendan A Gallagher (cherry picked from commit 1d99fa026bb05225df93e56740456ba185a5937d) Signed-off-by: Julian Maurice (cherry picked from commit 69fd29942c843b8b15df1bb75cd25451344341ba) Signed-off-by: Frédéric Demians --- 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 528db758f6..c8f0380a1f 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.39.5