View | Details | Raw Unified | Return to bug 6684
Collapse All | Expand All

(-)a/debian/scripts/koha-remove (-6 / +28 lines)
Lines 30-50 do Link Here
30
    shift
30
    shift
31
done
31
done
32
32
33
NAMES="$@"
33
34
34
for name in "$@"
35
SITECONFDIR="/etc/koha/sites"
36
# There has to be a better way of excluding '.' from find. But this works.
37
INSTANCES=`cd $SITECONFDIR && find . -type d -printf " %f" |sed s/\ .\ //`
38
39
if [ -z $NAMES ] ; then
40
    echo "Please specify a Koha instance name. Your choices are:"
41
    echo "$INSTANCES"
42
    exit 1
43
fi
44
45
for name in $NAMES
35
do
46
do
47
    # Does the directory (ie instance) name exist?
48
    if [ ! -d $SITECONFDIR/$name ] ; then
49
	echo Koha configuration directory for instance \"$name\" does not exist, please specify a valid Koha instance
50
	exit 1
51
    fi
52
36
    echo "Removing Koha instance $name"
53
    echo "Removing Koha instance $name"
37
54
38
    if [ "$keepmysql" != "1" ]
55
    if [ "$keepmysql" != "1" ]
39
    then
56
    then
40
        mysql --defaults-extra-file=/etc/mysql/koha-common.cnf <<eof
57
        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
- 

Return to bug 6684