[Koha-patches] [PATCH] Bug 6482 - allow the mysql details to be changed during koha-create
Robin Sheat
robin at catalyst.net.nz
Wed Jun 8 06:13:02 CEST 2011
This allows the database details (username and database name in
particular) to be modified in between a koha-create --request-db and
--populate-db. Most useful when you discover that the username is too
long or something. Now, when populating the database, the connection
information is reloaded from the koha-conf.xml rather than being
generated from the instance name.
---
debian/scripts/koha-create | 21 ++++++++++++++++-----
1 files changed, 16 insertions(+), 5 deletions(-)
diff --git a/debian/scripts/koha-create b/debian/scripts/koha-create
index e3c73fc..80c9cac 100755
--- a/debian/scripts/koha-create
+++ b/debian/scripts/koha-create
@@ -54,10 +54,16 @@ getmysqlhost() {
}
getinstancemysqlpassword() {
- sed -n '/<pass>/s:.*>\(.*\)</pass>.*:\1:p' \
- "/etc/koha/sites/$1/koha-conf.xml"
+ xmlstarlet sel -t -v 'yazgfs/config/pass' "/etc/koha/sites/$1/koha-conf.xml"
}
+getinstancemysqluser() {
+ xmlstarlet sel -t -v 'yazgfs/config/user' "/etc/koha/sites/$1/koha-conf.xml"
+}
+
+getinstancemysqldatabase() {
+ xmlstarlet sel -t -v 'yazgfs/config/database' "/etc/koha/sites/$1/koha-conf.xml"
+}
# Set defaults and read config file, if it exists.
DOMAIN=""
@@ -124,7 +130,7 @@ then
koha-create-dirs "$name"
# Generate Zebra database password.
- zebrapwd="$(pwgen -1)"
+ zebrapwd="$(pwgen -s 12 1)"
# Set up MySQL database for this instance.
if [ "$op" = create ]
then
@@ -134,7 +140,7 @@ CREATE USER \`$mysqluser\`@'%' IDENTIFIED BY '$mysqlpwd';
GRANT ALL PRIVILEGES ON \`$mysqldb\`.* TO \`$mysqluser\`;
FLUSH PRIVILEGES;
eof
- fi
+ fi #`
# Generate and install Apache site-available file and log dir.
generate_config_file apache-site.conf.in \
@@ -183,6 +189,11 @@ fi
if [ "$op" = create ] || [ "$op" = populate ]
then
+ # Re-fetch the passwords from the config we've generated, allows it
+ # to be different from what we set, in case the user had to change
+ # something.
+ mysqluser=$(getinstancemysqluser $name)
+ mysqldb=$(getinstancemysqldatabase $name)
# Use the default database content if that exists.
if [ -e "$DEFAULTSQL" ]
then
@@ -205,7 +216,7 @@ UPDATE borrowers
SET password = '$staffdigest'
WHERE borrowernumber = 3;
eof
-
+ #`
echo "staff user password is '$staffpass' but keep that secret"
# Upgrade the database schema, just in case the dump was from an
--
1.7.4.1
More information about the Koha-patches
mailing list