3 # koha-remove -- Remove a Koha instance.
4 # Copyright 2010 Catalyst IT, Ltd
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
22 args=$(getopt -l keep-mysql -o k -n $0 -- "$@")
27 -k|--keep-mysql) keepmysql=1; exit;;
36 echo "Removing Koha instance $name"
38 if [ "$keepmysql" != "1" ]
40 mysql --defaults-extra-file=/etc/mysql/koha-common.cnf <<eof
41 DROP USER \`koha_$name\`;
42 DROP DATABASE \`koha_$name\`;
48 [ -f "/etc/apache2/sites-available/$name" ] && \
49 rm "/etc/apache2/sites-available/$name"
50 [ -f "/etc/koha/sites/$name/koha-conf.xml" ] && \
51 rm "/etc/koha/sites/$name/koha-conf.xml"
52 [ -f "/etc/koha/sites/$name/zebra-biblios.cfg" ] && \
53 rm "/etc/koha/sites/$name/zebra-biblios.cfg"
54 [ -f "/etc/koha/sites/$name/zebra-authorities.cfg" ] && \
55 rm "/etc/koha/sites/$name/zebra-authorities.cfg"
56 [ -f "/etc/koha/sites/$name/zebra-authorities-dom.cfg" ] && \
57 rm "/etc/koha/sites/$name/zebra-authorities-dom.cfg"
58 [ -f "/etc/koha/sites/$name/zebra.passwd" ] && \
59 rm "/etc/koha/sites/$name/zebra.passwd"
60 [ -d "/etc/koha/sites/$name" ] && \
61 rmdir "/etc/koha/sites/$name"
62 [ -d "/var/lock/koha/$name" ] && \
63 rm -r "/var/lock/koha/$name"
64 [ -d "/var/log/koha/$name" ] && \
65 rm -r "/var/log/koha/$name"
66 [ -d "/var/run/koha/$name" ] && \
67 rm -r "/var/run/koha/$name"
68 getent passwd "$name-koha" > /dev/null && deluser --quiet "$name-koha"
72 service apache2 restart