Use /etc/mysql/koha-common.cnf instead of the Debian one.

koha-common.postinst now creates a symlink to the Debian one.
The sysadmin may replace that manually with something that allows
Koha to access a remote mysql server.

Signed-off-by: Galen Charlton <gmcharlt@gmail.com>
This commit is contained in:
Lars Wirzenius 2010-05-25 13:44:24 +12:00 committed by Chris Cormack
parent 434b7dcfe4
commit d2985c6c92
6 changed files with 29 additions and 8 deletions

View file

@ -17,3 +17,13 @@ Each Koha instance has files in the following places:
* /var/run/koha/$name -- run-time sockets etc * /var/run/koha/$name -- run-time sockets etc
* /var/spool/koha/$name -- database dumps * /var/spool/koha/$name -- database dumps
Koha and MySQL
==============
koha-common's postinst script sets up the /etc/mysql/koha-common.cnf,
and all scripts use that to access the MySQL database. By default, it
is a symlink pointing at debian.cnf, and only works on localhost.
If you wish, you can create a file /etc/mysql/koha-common.cnf instead
of the symlink, and point it at a remote server. There is currently
no tool to help you do that, but it should be fairly straightforward.

11
debian/koha-common.postinst vendored Normal file
View file

@ -0,0 +1,11 @@
#!/bin/sh
set -e
conf=/etc/mysql/koha-common.cnf
if [ ! -e "$conf" ]
then
ln -s debian.cnf /etc/mysql/koha-common.cnf
fi
#DEBHELPER#

View file

@ -95,7 +95,7 @@ zebrapwd="$(pwgen -1)"
mysqldb="koha_$name" mysqldb="koha_$name"
mysqluser="koha_$name" mysqluser="koha_$name"
mysqlpwd="$(pwgen -1)" mysqlpwd="$(pwgen -1)"
mysql --defaults-extra-file=/etc/mysql/debian.cnf <<eof mysql --defaults-extra-file=/etc/mysql/koha-common.cnf <<eof
CREATE DATABASE $mysqldb; CREATE DATABASE $mysqldb;
CREATE USER '$mysqluser' IDENTIFIED BY '$mysqlpwd'; CREATE USER '$mysqluser' IDENTIFIED BY '$mysqlpwd';
GRANT ALL PRIVILEGES ON $mysqldb.* TO '$mysqluser'; GRANT ALL PRIVILEGES ON $mysqldb.* TO '$mysqluser';
@ -109,7 +109,7 @@ then
# Populate the database with default content. # Populate the database with default content.
zcat "$DEFAULTSQL" | zcat "$DEFAULTSQL" |
sed "s/__KOHASITE__/$name/g" | sed "s/__KOHASITE__/$name/g" |
mysql --defaults-extra-file=/etc/mysql/debian.cnf mysql --defaults-extra-file=/etc/mysql/koha-common.cnf
# Change the default user's password. # Change the default user's password.
@ -118,7 +118,7 @@ then
perl -e ' perl -e '
use Digest::MD5 qw(md5_base64); use Digest::MD5 qw(md5_base64);
while (<>) { print md5_base64($_), "\n"; }') while (<>) { print md5_base64($_), "\n"; }')
mysql --defaults-extra-file=/etc/mysql/debian.cnf <<eof mysql --defaults-extra-file=/etc/mysql/koha-common.cnf <<eof
USE \`$mysqldb\`; USE \`$mysqldb\`;
UPDATE borrowers UPDATE borrowers
SET password = '$staffdigest' SET password = '$staffdigest'

View file

@ -24,7 +24,7 @@ for name in "$@"
do do
echo "Removing Koha instance $name" echo "Removing Koha instance $name"
mysql --defaults-extra-file=/etc/mysql/debian.cnf <<eof mysql --defaults-extra-file=/etc/mysql/koha-common.cnf <<eof
DROP USER 'koha_$name'; DROP USER 'koha_$name';
DROP DATABASE koha_$name; DROP DATABASE koha_$name;
FLUSH PRIVILEGES; FLUSH PRIVILEGES;

View file

@ -52,6 +52,6 @@ do
>> "$temp" >> "$temp"
done done
mysql --defaults-extra-file=/etc/mysql/debian.cnf < "$temp" mysql --defaults-extra-file=/etc/mysql/koha-common.cnf < "$temp"
rm "$temp" rm "$temp"

View file

@ -70,11 +70,11 @@ tar -C / -xf "$configdump"
mysqldb="koha_$name" mysqldb="koha_$name"
mysqluser="koha_$name" mysqluser="koha_$name"
mysqlpwd="$(sed -n '/.*<pass>\(.*\)<\/pass>.*/s//\1/p' /etc/koha/sites/$name/koha-conf.xml)" mysqlpwd="$(sed -n '/.*<pass>\(.*\)<\/pass>.*/s//\1/p' /etc/koha/sites/$name/koha-conf.xml)"
zcat "$sqldump" | mysql --defaults-extra-file=/etc/mysql/debian.cnf zcat "$sqldump" | mysql --defaults-extra-file=/etc/mysql/koha-common.cnf
mysql --defaults-extra-file=/etc/mysql/debian.cnf <<eof || true mysql --defaults-extra-file=/etc/mysql/koha-common.cnf <<eof || true
DROP USER '$mysqluser'; DROP USER '$mysqluser';
eof eof
mysql --defaults-extra-file=/etc/mysql/debian.cnf << eof || true mysql --defaults-extra-file=/etc/mysql/koha-common.cnf << eof || true
CREATE USER '$mysqluser' IDENTIFIED BY '$mysqlpwd'; CREATE USER '$mysqluser' IDENTIFIED BY '$mysqlpwd';
GRANT ALL PRIVILEGES ON $mysqldb.* TO '$mysqluser'; GRANT ALL PRIVILEGES ON $mysqldb.* TO '$mysqluser';
FLUSH PRIVILEGES; FLUSH PRIVILEGES;