Lines 19-48
Link Here
|
19 |
|
19 |
|
20 |
set -e |
20 |
set -e |
21 |
|
21 |
|
|
|
22 |
NAMES="$@" |
22 |
|
23 |
|
23 |
for name in "$@" |
24 |
SITECONFDIR="/etc/koha/sites" |
|
|
25 |
# There has to be a better way of excluding '.' from find. But this works. |
26 |
INSTANCES=`cd $SITECONFDIR && find . -type d -printf " %f" |sed s/\ .\ //` |
27 |
|
28 |
if [ -z $NAMES ] ; then |
29 |
echo "Please specify a Koha instance name. Your choices are:" |
30 |
echo "$INSTANCES" |
31 |
exit 1 |
32 |
fi |
33 |
|
34 |
for name in $NAMES |
24 |
do |
35 |
do |
|
|
36 |
# Does the directory (ie instance) name exist? |
37 |
if [ ! -d $SITECONFDIR/$name ] ; then |
38 |
echo Koha configuration directory for instance \"$name\" does not exist, please specify a valid Koha instance |
39 |
exit 1 |
40 |
fi |
41 |
|
25 |
echo "Removing Koha instance $name" |
42 |
echo "Removing Koha instance $name" |
26 |
|
43 |
|
|
|
44 |
# The grant creates the user in case it isn't, we don't want our loop to fail if it has already being deleted. |
27 |
mysql --defaults-extra-file=/etc/mysql/koha-common.cnf <<eof |
45 |
mysql --defaults-extra-file=/etc/mysql/koha-common.cnf <<eof |
|
|
46 |
GRANT USAGE ON \`koha_$name\`.* TO \`koha_$name\`@\`%\`; |
28 |
DROP USER \`koha_$name\`; |
47 |
DROP USER \`koha_$name\`; |
29 |
DROP DATABASE \`koha_$name\`; |
48 |
DROP DATABASE IF EXISTS \`koha_$name\`; |
30 |
FLUSH PRIVILEGES; |
49 |
FLUSH PRIVILEGES; |
31 |
eof |
50 |
eof |
32 |
|
51 |
|
33 |
koha-stop-zebra $name |
52 |
# If the daemon is not running already, we don't want to fail this loop. So bin the result code if this fails. |
34 |
rm "/etc/apache2/sites-available/$name" |
53 |
koha-stop-zebra $name | /bin/true |
35 |
rm "/etc/koha/sites/$name/koha-conf.xml" |
54 |
rm -f "/etc/apache2/sites-available/$name" |
36 |
rm "/etc/koha/sites/$name/zebra-biblios.cfg" |
55 |
rm -f "$SITECONFDIR/$name/koha-conf.xml" |
37 |
rm "/etc/koha/sites/$name/zebra-authorities.cfg" |
56 |
rm -f "$SITECONFDIR/$name/zebra-biblios.cfg" |
38 |
rm "/etc/koha/sites/$name/zebra-authorities-dom.cfg" |
57 |
rm -f "$SITECONFDIR/$name/zebra-authorities.cfg" |
39 |
rm "/etc/koha/sites/$name/zebra.passwd" |
58 |
rm -f "$SITECONFDIR/$name/zebra-authorities-dom.cfg" |
40 |
rmdir "/etc/koha/sites/$name" |
59 |
rm -f "$SITECONFDIR/$name/zebra.passwd" |
41 |
rm -r "/var/lock/koha/$name" |
60 |
# 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 they have. |
42 |
rm -r "/var/log/koha/$name" |
61 |
rmdir --ignore-fail-on-non-empty "$SITECONFDIR/$name" |
43 |
rm -r "/var/run/koha/$name" |
62 |
rm -rf "/var/lock/koha/$name" |
44 |
deluser --quiet "$name-koha" |
63 |
rm -rf "/var/log/koha/$name" |
45 |
a2dissite "$name" |
64 |
rm -rf "/var/run/koha/$name" |
|
|
65 |
# Frequently warns about the mailspool dir. Sometimes the daemon has not stopped yet. So work around the non-zero result code. |
66 |
echo "Deleting Koha user for $name" |
67 |
userdel --force --remove "$name-koha" &> /dev/null | /bin/true |
68 |
# in case the site has already been disabled, we don't want to break the loop now. |
69 |
a2dissite "$name" | /bin/true |
46 |
done |
70 |
done |
47 |
|
71 |
|
48 |
service apache2 restart |
72 |
service apache2 restart |
49 |
- |
|
|