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

(-)a/debian/scripts/koha-create (-1 / +6 lines)
Lines 163-169 opacdomain="$OPACPREFIX$name$OPACSUFFIX$DOMAIN" Link Here
163
intradomain="$INTRAPREFIX$name$INTRASUFFIX$DOMAIN"
163
intradomain="$INTRAPREFIX$name$INTRASUFFIX$DOMAIN"
164
164
165
165
166
if [ `cat $PASSWDFILE | grep "^$name:"` ]
166
if [ -f $PASSWDFILE ] && [ `cat $PASSWDFILE | grep "^$name:"` ]
167
then
167
then
168
    passwdline=`cat $PASSWDFILE | grep "^$name:"`
168
    passwdline=`cat $PASSWDFILE | grep "^$name:"`
169
    mysqluser=`echo $passwdline | cut -d ":" -f 2`
169
    mysqluser=`echo $passwdline | cut -d ":" -f 2`
Lines 221-231 then Link Here
221
221
222
    # Generate Zebra database password.
222
    # Generate Zebra database password.
223
    zebrapwd="$(pwgen -s 12 1)"
223
    zebrapwd="$(pwgen -s 12 1)"
224
    # Future enhancement: make this configurable for when your db is on
225
    # another server.
226
    mysql_hostname="localhost"
224
    # Set up MySQL database for this instance.
227
    # Set up MySQL database for this instance.
225
    if [ "$op" = create ]
228
    if [ "$op" = create ]
226
    then
229
    then
227
        mysql --defaults-extra-file=/etc/mysql/koha-common.cnf <<eof
230
        mysql --defaults-extra-file=/etc/mysql/koha-common.cnf <<eof
228
CREATE DATABASE \`$mysqldb\`;
231
CREATE DATABASE \`$mysqldb\`;
232
CREATE USER \`$mysqluser\`@'$mysql_hostname' IDENTIFIED BY '$mysqlpwd';
229
CREATE USER \`$mysqluser\`@'%' IDENTIFIED BY '$mysqlpwd';
233
CREATE USER \`$mysqluser\`@'%' IDENTIFIED BY '$mysqlpwd';
230
GRANT ALL PRIVILEGES ON \`$mysqldb\`.* TO \`$mysqluser\`;
234
GRANT ALL PRIVILEGES ON \`$mysqldb\`.* TO \`$mysqluser\`;
231
FLUSH PRIVILEGES;
235
FLUSH PRIVILEGES;
Lines 235-240 eof Link Here
235
    if [ "$op" = use ]
239
    if [ "$op" = use ]
236
    then
240
    then
237
        mysql --defaults-extra-file=/etc/mysql/koha-common.cnf --force <<eof
241
        mysql --defaults-extra-file=/etc/mysql/koha-common.cnf --force <<eof
242
CREATE USER \`$mysqluser\`@'$mysql_hostname' IDENTIFIED BY '$mysqlpwd';
238
CREATE USER \`$mysqluser\`@'%' IDENTIFIED BY '$mysqlpwd';
243
CREATE USER \`$mysqluser\`@'%' IDENTIFIED BY '$mysqlpwd';
239
GRANT ALL PRIVILEGES ON \`$mysqldb\`.* TO \`$mysqluser\`;
244
GRANT ALL PRIVILEGES ON \`$mysqldb\`.* TO \`$mysqluser\`;
240
FLUSH PRIVILEGES;
245
FLUSH PRIVILEGES;
(-)a/debian/scripts/koha-remove (-5 / +6 lines)
Lines 52-71 do Link Here
52
    fi
52
    fi
53
53
54
    echo "Removing Koha instance $name"
54
    echo "Removing Koha instance $name"
55
55
    mysql_hostname="localhost"
56
    if [ "$keepmysql" != "1" ]
56
    if [ "$keepmysql" != "1" ]
57
    then
57
    then
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.
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
59
    mysql --defaults-extra-file=/etc/mysql/koha-common.cnf <<eof
60
GRANT USAGE ON \`koha_$name\`.* TO \`koha_$name\`@\`%\`;
60
GRANT USAGE ON \`koha_$name\`.* TO \`koha_$name\`@\`%\`;
61
DROP USER \`koha_$name\`;
61
GRANT USAGE ON \`koha_$name\`.* TO \`koha_$name\`@\`$mysql_hostname\`;
62
DROP USER \`koha_$name\`@\`%\`;
63
DROP USER \`koha_$name\`@\`$mysql_hostname\`;
62
DROP DATABASE IF EXISTS \`koha_$name\`;
64
DROP DATABASE IF EXISTS \`koha_$name\`;
63
FLUSH PRIVILEGES;
65
FLUSH PRIVILEGES;
64
eof
66
eof
65
    fi #`
67
    fi #`
66
    
68
    
67
    # If the daemon is not running already, we don't want to fail this loop. So bin the result code if this fails.
69
    # 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
70
    koha-stop-zebra $name || /bin/true
69
    [ -f "/etc/apache2/sites-available/$name" ]  && \
71
    [ -f "/etc/apache2/sites-available/$name" ]  && \
70
        rm "/etc/apache2/sites-available/$name"
72
        rm "/etc/apache2/sites-available/$name"
71
    [ -f "/etc/koha/sites/$name/koha-conf.xml" ] && \
73
    [ -f "/etc/koha/sites/$name/koha-conf.xml" ] && \
Lines 89-95 eof Link Here
89
        rm -r "/var/run/koha/$name"
91
        rm -r "/var/run/koha/$name"
90
    getent passwd "$name-koha" > /dev/null && deluser --quiet "$name-koha"
92
    getent passwd "$name-koha" > /dev/null && deluser --quiet "$name-koha"
91
    # in case the site has already been disabled, we don't want to break the loop now.
93
    # in case the site has already been disabled, we don't want to break the loop now.
92
    a2dissite "$name" | /bin/true
94
    a2dissite "$name" || /bin/true
93
done
95
done
94
96
95
service apache2 restart
97
service apache2 restart
96
- 

Return to bug 8162