[Koha-patches] [PATCH 25/28] Use /etc/mysql/koha-common.cnf instead of the Debian one.

Lars Wirzenius lars at catalyst.net.nz
Tue May 25 03:44:24 CEST 2010


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.
---
 debian/koha-common.README.Debian |   10 ++++++++++
 debian/koha-common.postinst      |   11 +++++++++++
 debian/scripts/koha-create       |    6 +++---
 debian/scripts/koha-remove       |    2 +-
 debian/scripts/koha-reset-passwd |    2 +-
 debian/scripts/koha-restore      |    6 +++---
 6 files changed, 29 insertions(+), 8 deletions(-)
 create mode 100644 debian/koha-common.postinst

diff --git a/debian/koha-common.README.Debian b/debian/koha-common.README.Debian
index 221e1a3..0676284 100644
--- a/debian/koha-common.README.Debian
+++ b/debian/koha-common.README.Debian
@@ -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
index 0000000..0067ef9
--- /dev/null
+++ b/debian/koha-common.postinst
@@ -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#
diff --git a/debian/scripts/koha-create b/debian/scripts/koha-create
index 45f65e4..cb0268d 100755
--- a/debian/scripts/koha-create
+++ b/debian/scripts/koha-create
@@ -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' 
diff --git a/debian/scripts/koha-remove b/debian/scripts/koha-remove
index 7b4a19e..de3fe1c 100755
--- a/debian/scripts/koha-remove
+++ b/debian/scripts/koha-remove
@@ -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;
diff --git a/debian/scripts/koha-reset-passwd b/debian/scripts/koha-reset-passwd
index c9f3752..70ba3ba 100755
--- a/debian/scripts/koha-reset-passwd
+++ b/debian/scripts/koha-reset-passwd
@@ -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"
diff --git a/debian/scripts/koha-restore b/debian/scripts/koha-restore
index 6e15fd0..560dc40 100755
--- a/debian/scripts/koha-restore
+++ b/debian/scripts/koha-restore
@@ -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;
-- 
1.7.1




More information about the Koha-patches mailing list