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>
* /var/run/koha/$name -- run-time sockets etc
* /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.
--- /dev/null
+#!/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#
mysqldb="koha_$name"
mysqluser="koha_$name"
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 USER '$mysqluser' IDENTIFIED BY '$mysqlpwd';
GRANT ALL PRIVILEGES ON $mysqldb.* TO '$mysqluser';
# Populate the database with default content.
zcat "$DEFAULTSQL" |
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.
perl -e '
use Digest::MD5 qw(md5_base64);
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\`;
UPDATE borrowers
SET password = '$staffdigest'
do
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 DATABASE koha_$name;
FLUSH PRIVILEGES;
>> "$temp"
done
-mysql --defaults-extra-file=/etc/mysql/debian.cnf < "$temp"
+mysql --defaults-extra-file=/etc/mysql/koha-common.cnf < "$temp"
rm "$temp"
mysqldb="koha_$name"
mysqluser="koha_$name"
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
-mysql --defaults-extra-file=/etc/mysql/debian.cnf <<eof || true
+zcat "$sqldump" | mysql --defaults-extra-file=/etc/mysql/koha-common.cnf
+mysql --defaults-extra-file=/etc/mysql/koha-common.cnf <<eof || true
DROP USER '$mysqluser';
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';
GRANT ALL PRIVILEGES ON $mysqldb.* TO '$mysqluser';
FLUSH PRIVILEGES;