[Koha-patches] [PATCH 26/28] Add support for a remote mysql server.
Lars Wirzenius
lars at catalyst.net.nz
Tue May 25 03:44:25 CEST 2010
---
debian/control | 2 +-
debian/koha-common.postinst | 4 ++--
debian/scripts/koha-create | 12 +++++++++++-
debian/templates/koha-conf-site.xml.in | 2 +-
4 files changed, 15 insertions(+), 5 deletions(-)
diff --git a/debian/control b/debian/control
index 999dbfa..459e1c3 100644
--- a/debian/control
+++ b/debian/control
@@ -75,9 +75,9 @@ Depends: ${shlib:Depends}, ${misc:Depends}, ${koha:Depends},
libjs-jquery,
libjs-yui,
mysql-client,
- mysql-server,
tinymce2,
yaz
+Suggests: mysql-server
Homepage: http://koha-community.org/
Description: integrated (physical) library management system
Koha is an Integrated Library Managment system for real-world libraries
diff --git a/debian/koha-common.postinst b/debian/koha-common.postinst
index 0067ef9..ffb2165 100644
--- a/debian/koha-common.postinst
+++ b/debian/koha-common.postinst
@@ -3,9 +3,9 @@
set -e
conf=/etc/mysql/koha-common.cnf
-if [ ! -e "$conf" ]
+if [ ! -e "$conf" ] && [ ! -L "$conf" ]
then
- ln -s debian.cnf /etc/mysql/koha-common.cnf
+ ln -s debian.cnf "$conf"
fi
#DEBHELPER#
diff --git a/debian/scripts/koha-create b/debian/scripts/koha-create
index cb0268d..f360cf2 100755
--- a/debian/scripts/koha-create
+++ b/debian/scripts/koha-create
@@ -37,6 +37,7 @@ generate_config_file() {
-e "s/__INTRASERVER__/$intradomain/g" \
-e "s/__ZEBRA_PASS__/$zebrapwd/g" \
-e "s/__DB_NAME__/$mysqldb/g" \
+ -e "s/__DB_HOST__/$mysqlhost/g" \
-e "s/__DB_USER__/$mysqluser/g" \
-e "s/__DB_PASS__/$mysqlpwd/g" \
-e "s/__UNIXUSER__/$username/g" \
@@ -44,6 +45,14 @@ generate_config_file() {
"/etc/koha/$1" > "$2"
}
+getmysqlhost() {
+ awk '
+ /^\[/ { inclient = 0 }
+ /^\[client\]/ { inclient = 1 }
+ inclient && /^ *host *=/ { print $3 }' \
+ /etc/mysql/koha-common.cnf
+}
+
# Set defaults and read config file, if it exists.
DOMAIN=""
@@ -93,11 +102,12 @@ zebrapwd="$(pwgen -1)"
# Set up MySQL database for this instance.
mysqldb="koha_$name"
+mysqlhost="$(getmysqlhost)"
mysqluser="koha_$name"
mysqlpwd="$(pwgen -1)"
mysql --defaults-extra-file=/etc/mysql/koha-common.cnf <<eof
CREATE DATABASE $mysqldb;
-CREATE USER '$mysqluser' IDENTIFIED BY '$mysqlpwd';
+CREATE USER '$mysqluser'@'%' IDENTIFIED BY '$mysqlpwd';
GRANT ALL PRIVILEGES ON $mysqldb.* TO '$mysqluser';
FLUSH PRIVILEGES;
eof
diff --git a/debian/templates/koha-conf-site.xml.in b/debian/templates/koha-conf-site.xml.in
index 38808fe..d5ca838 100644
--- a/debian/templates/koha-conf-site.xml.in
+++ b/debian/templates/koha-conf-site.xml.in
@@ -122,7 +122,7 @@
<config>
<db_scheme>mysql</db_scheme>
<database>__DB_NAME__</database>
- <hostname>localhost</hostname>
+ <hostname>__DB_HOST__</hostname>
<port>3306</port>
<user>__DB_USER__</user>
<pass>__DB_PASS__</pass>
--
1.7.1
More information about the Koha-patches
mailing list