Use /etc/mysql/koha-common.cnf instead of the Debian one.
authorLars Wirzenius <lars@catalyst.net.nz>
Tue, 25 May 2010 01:44:24 +0000 (13:44 +1200)
committerChris Cormack <chrisc@catalyst.net.nz>
Wed, 26 May 2010 04:30:24 +0000 (16:30 +1200)
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>
debian/koha-common.README.Debian
debian/koha-common.postinst [new file with mode: 0644]
debian/scripts/koha-create
debian/scripts/koha-remove
debian/scripts/koha-reset-passwd
debian/scripts/koha-restore

index 221e1a3..0676284 100644 (file)
@@ -17,3 +17,13 @@ Each Koha instance has files in the following places:
 * /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.
diff --git a/debian/koha-common.postinst b/debian/koha-common.postinst
new file mode 100644 (file)
index 0000000..0067ef9
--- /dev/null
@@ -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#
index 45f65e4..cb0268d 100755 (executable)
@@ -95,7 +95,7 @@ zebrapwd="$(pwgen -1)"
 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';
@@ -109,7 +109,7 @@ then
     # 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.
@@ -118,7 +118,7 @@ then
                   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' 
index 7b4a19e..de3fe1c 100755 (executable)
@@ -24,7 +24,7 @@ for name in "$@"
 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;
index c9f3752..70ba3ba 100755 (executable)
@@ -52,6 +52,6 @@ do
         >> "$temp"
 done
 
-mysql --defaults-extra-file=/etc/mysql/debian.cnf < "$temp"
+mysql --defaults-extra-file=/etc/mysql/koha-common.cnf < "$temp"
 
 rm "$temp"
index 6e15fd0..560dc40 100755 (executable)
@@ -70,11 +70,11 @@ tar -C / -xf "$configdump"
 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;