- 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"
- 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"
- a2dissite "$name"
+ # If the daemon is not running already, we don't want to fail this loop. So bin the result code if this fails.
+ koha-stop-zebra $name || /bin/true
+ [ -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-biblios-dom.cfg" ] && \
+ rm "/etc/koha/sites/$name/zebra-biblios-dom.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"
+ # Maybe a user has left something in the config directory they want to keep? We won't delete it here, nor throw an error if the have.
+ [ -d "/etc/koha/sites/$name" ] && \
+ rmdir --ignore-fail-on-non-empty "/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"
+ # in case the site has already been disabled, we don't want to break the loop now.
+ a2dissite "$name" || /bin/true