|
Lines 31-50
do
Link Here
|
| 31 |
shift |
31 |
shift |
| 32 |
done |
32 |
done |
| 33 |
|
33 |
|
| 34 |
for name in "$@" |
34 |
NAMES="$@" |
|
|
35 |
|
| 36 |
SITECONFDIR="/etc/koha/sites" |
| 37 |
# There has to be a better way of excluding '.' from find. But this works. |
| 38 |
INSTANCES=`cd $SITECONFDIR && find . -type d -printf " %f" |sed s/\ .\ //` |
| 39 |
|
| 40 |
if [ -z $NAMES ] ; then |
| 41 |
echo "Please specify a Koha instance name. Your choices are:" |
| 42 |
echo "$INSTANCES" |
| 43 |
exit 1 |
| 44 |
fi |
| 45 |
|
| 46 |
for name in $NAMES |
| 35 |
do |
47 |
do |
|
|
48 |
# Does the directory (ie instance) name exist? |
| 49 |
if [ ! -d $SITECONFDIR/$name ] ; then |
| 50 |
echo Koha configuration directory for instance \"$name\" does not exist, please specify a valid Koha instance |
| 51 |
exit 1 |
| 52 |
fi |
| 53 |
|
| 36 |
echo "Removing Koha instance $name" |
54 |
echo "Removing Koha instance $name" |
| 37 |
|
55 |
|
| 38 |
if [ "$keepmysql" != "1" ] |
56 |
if [ "$keepmysql" != "1" ] |
| 39 |
then |
57 |
then |
| 40 |
mysql --defaults-extra-file=/etc/mysql/koha-common.cnf <<eof |
58 |
# The grant creates the user in case it isn't, we don't want our loop to fail if it has already being deleted. |
|
|
59 |
mysql --defaults-extra-file=/etc/mysql/koha-common.cnf <<eof |
| 60 |
GRANT USAGE ON \`koha_$name\`.* TO \`koha_$name\`@\`%\`; |
| 41 |
DROP USER \`koha_$name\`; |
61 |
DROP USER \`koha_$name\`; |
| 42 |
DROP DATABASE \`koha_$name\`; |
62 |
DROP DATABASE IF EXISTS \`koha_$name\`; |
| 43 |
FLUSH PRIVILEGES; |
63 |
FLUSH PRIVILEGES; |
| 44 |
eof |
64 |
eof |
| 45 |
fi #` |
65 |
fi #` |
| 46 |
|
66 |
|
| 47 |
koha-stop-zebra $name |
67 |
# If the daemon is not running already, we don't want to fail this loop. So bin the result code if this fails. |
|
|
68 |
koha-stop-zebra $name | /bin/true |
| 48 |
[ -f "/etc/apache2/sites-available/$name" ] && \ |
69 |
[ -f "/etc/apache2/sites-available/$name" ] && \ |
| 49 |
rm "/etc/apache2/sites-available/$name" |
70 |
rm "/etc/apache2/sites-available/$name" |
| 50 |
[ -f "/etc/koha/sites/$name/koha-conf.xml" ] && \ |
71 |
[ -f "/etc/koha/sites/$name/koha-conf.xml" ] && \ |
|
Lines 57-64
eof
Link Here
|
| 57 |
rm "/etc/koha/sites/$name/zebra-authorities-dom.cfg" |
78 |
rm "/etc/koha/sites/$name/zebra-authorities-dom.cfg" |
| 58 |
[ -f "/etc/koha/sites/$name/zebra.passwd" ] && \ |
79 |
[ -f "/etc/koha/sites/$name/zebra.passwd" ] && \ |
| 59 |
rm "/etc/koha/sites/$name/zebra.passwd" |
80 |
rm "/etc/koha/sites/$name/zebra.passwd" |
|
|
81 |
# 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. |
| 60 |
[ -d "/etc/koha/sites/$name" ] && \ |
82 |
[ -d "/etc/koha/sites/$name" ] && \ |
| 61 |
rmdir "/etc/koha/sites/$name" |
83 |
rmdir --ignore-fail-on-non-empty "/etc/koha/sites/$name" |
| 62 |
[ -d "/var/lock/koha/$name" ] && \ |
84 |
[ -d "/var/lock/koha/$name" ] && \ |
| 63 |
rm -r "/var/lock/koha/$name" |
85 |
rm -r "/var/lock/koha/$name" |
| 64 |
[ -d "/var/log/koha/$name" ] && \ |
86 |
[ -d "/var/log/koha/$name" ] && \ |
|
Lines 66-72
eof
Link Here
|
| 66 |
[ -d "/var/run/koha/$name" ] && \ |
88 |
[ -d "/var/run/koha/$name" ] && \ |
| 67 |
rm -r "/var/run/koha/$name" |
89 |
rm -r "/var/run/koha/$name" |
| 68 |
getent passwd "$name-koha" > /dev/null && deluser --quiet "$name-koha" |
90 |
getent passwd "$name-koha" > /dev/null && deluser --quiet "$name-koha" |
| 69 |
a2dissite "$name" |
91 |
# in case the site has already been disabled, we don't want to break the loop now. |
|
|
92 |
a2dissite "$name" | /bin/true |
| 70 |
done |
93 |
done |
| 71 |
|
94 |
|
| 72 |
service apache2 restart |
95 |
service apache2 restart |
| 73 |
- |
|
|