Bug 6997: Koha-remove leaves system in inconsistent state

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Bug 6997: Koha-remove leaves system in inconsistent state

Jared Camins-Esakov-2
If you accidentally delete one of the files that koha-remove is supposed to
remove, when koha-remove reaches that point in the script, it will die, leaving
later removal steps undone. This patch fixes the problem by checking for the
existence of each file prior to deleting it, so that short of an actual problem
with removing the file, the script can continue. Note that the fix for bug 6929
is also needed to prevent any problems with stopping Zebra from killing
koha-remove.
---
 debian/scripts/koha-remove |   32 +++++++++++++++++++++-----------
 1 files changed, 21 insertions(+), 11 deletions(-)

diff --git a/debian/scripts/koha-remove b/debian/scripts/koha-remove
index 10a8b78..b9e5c2a 100755
--- a/debian/scripts/koha-remove
+++ b/debian/scripts/koha-remove
@@ -31,17 +31,27 @@ FLUSH PRIVILEGES;
 eof
     
     koha-stop-zebra $name
-    rm "/etc/apache2/sites-available/$name"
-    rm "/etc/koha/sites/$name/koha-conf.xml"
-    rm "/etc/koha/sites/$name/zebra-biblios.cfg"
-    rm "/etc/koha/sites/$name/zebra-authorities.cfg"
-    rm "/etc/koha/sites/$name/zebra-authorities-dom.cfg"
-    rm "/etc/koha/sites/$name/zebra.passwd"
-    rmdir "/etc/koha/sites/$name"
-    rm -r "/var/lock/koha/$name"
-    rm -r "/var/log/koha/$name"
-    rm -r "/var/run/koha/$name"
-    deluser --quiet "$name-koha"
+    [ -f "/etc/apache2/sites-available/$name" ]  && \
+        rm "/etc/apache2/sites-available/$name"
+    [ -f "/etc/koha/sites/$name/koha-conf.xml" ] && \
+        rm "/etc/koha/sites/$name/koha-conf.xml"
+    [ -f "/etc/koha/sites/$name/zebra-biblios.cfg" ] && \
+        rm "/etc/koha/sites/$name/zebra-biblios.cfg"
+    [ -f "/etc/koha/sites/$name/zebra-authorities.cfg" ] && \
+        rm "/etc/koha/sites/$name/zebra-authorities.cfg"
+    [ -f "/etc/koha/sites/$name/zebra-authorities-dom.cfg" ] && \
+        rm "/etc/koha/sites/$name/zebra-authorities-dom.cfg"
+    [ -f "/etc/koha/sites/$name/zebra.passwd" ] && \
+        rm "/etc/koha/sites/$name/zebra.passwd"
+    [ -d "/etc/koha/sites/$name" ] && \
+        rmdir "/etc/koha/sites/$name"
+    [ -d "/var/lock/koha/$name" ] && \
+        rm -r "/var/lock/koha/$name"
+    [ -d "/var/log/koha/$name" ] && \
+        rm -r "/var/log/koha/$name"
+    [ -d "/var/run/koha/$name" ] && \
+        rm -r "/var/run/koha/$name"
+    getent passwd "$name-koha" > /dev/null && deluser --quiet "$name-koha"
     a2dissite "$name"
 done
 
--
1.7.2.5

_______________________________________________
Koha-patches mailing list
[hidden email]
http://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-patches
website : http://www.koha-community.org/
git : http://git.koha-community.org/
bugs : http://bugs.koha-community.org/
Reply | Threaded
Open this post in threaded view
|

Re: Bug 6997: Koha-remove leaves system in inconsistent state

Robin Sheat-2
Op dinsdag 11 oktober 2011 01:16:51 schreef Jared Camins-Esakov:
> +    [ -f "/etc/apache2/sites-available/$name" ]  && \
> +        rm "/etc/apache2/sites-available/$name"
> +    [ -f "/etc/koha/sites/$name/koha-conf.xml" ] && \
> +        rm "/etc/koha/sites/$name/koha-conf.xml"

While I'm OK with this patch, a simpler way do do this is simply to add '-f'
to the rm, and ' || true' to the other things we don't care about.

--
Robin Sheat
Catalyst IT Ltd.
✆ +64 4 803 2204

_______________________________________________
Koha-patches mailing list
[hidden email]
http://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-patches
website : http://www.koha-community.org/
git : http://git.koha-community.org/
bugs : http://bugs.koha-community.org/

signature.asc (205 bytes) Download Attachment