From 1490b1ee9856f6767f4967aa4019f53cb65ef294 Mon Sep 17 00:00:00 2001 From: Mark Tompsett Date: Fri, 23 Jun 2017 01:46:50 +0000 Subject: [PATCH] Bug 9409: Add --dbhost parameter and dbhost field This allows setting the remote db host correctly for request-db either with a command-line or passwd file. Signed-off-by: Lee Jamison --- debian/scripts/koha-create | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/debian/scripts/koha-create b/debian/scripts/koha-create index ba4f043..be133a1 100755 --- a/debian/scripts/koha-create +++ b/debian/scripts/koha-create @@ -66,6 +66,7 @@ Options: --defaultsql some.sql Specify a default SQL file to be loaded on the DB. --configfile cfg_file Specify an alternate config file for reading default values. --passwdfile passwd Specify an alternate passwd file. + --dbhost host Enforce the use of the specified DB server --database dbname Enforce the use of the specified DB name (64 char limit) --adminuser n Explicit the admin user ID in the DB. Relevant in conjunction with --defaultsql and --populate-db. @@ -432,7 +433,7 @@ fi [ $# -ge 1 ] && [ $# -le 16 ] || ( usage ; die "Error: wrong parameters" ) -TEMP=`getopt -o chrpm:l:d:f:b:a: -l create-db,request-db,populate-db,use-db,use-memcached,enable-sru,sru-port:,help,marcflavor:,auth-idx:,biblio-idx:,zebralang:,defaultsql:,configfile:,passwdfile:,database:,adminuser:,memcached-servers:,memcached-prefix:,upload-path:,letsencrypt, \ +TEMP=`getopt -o chrpm:l:d:f:b:a: -l create-db,request-db,populate-db,use-db,use-memcached,enable-sru,sru-port:,help,marcflavor:,auth-idx:,biblio-idx:,zebralang:,defaultsql:,configfile:,passwdfile:,dbhost:,database:,adminuser:,memcached-servers:,memcached-prefix:,upload-path:,letsencrypt, \ -n "$0" -- "$@"` # Note the quotes around `$TEMP': they are essential! @@ -482,6 +483,8 @@ while true ; do CLO_PASSWDFILE="$2" ; shift 2 ;; -b|--database) CLO_DATABASE="$2" ; shift 2 ;; + --dbhost) + CLO_DBHOST="$2" ; shift 2 ;; -a|--adminuser) CLO_ADMINUSER="$2" ; shift 2 ;; --enable-sru) @@ -600,6 +603,7 @@ then mysqluser=`echo $passwdline | cut -d ":" -f 2` mysqlpwd=`echo $passwdline | cut -d ":" -f 3` mysqldb=`echo $passwdline | cut -d ":" -f 4` + mysqlhost=`echo $passwdline | cut -d ":" -f 5` fi # The order of precedence for MySQL database name is: @@ -608,6 +612,7 @@ if [ "$mysqldb" = "" ] then mysqldb="koha_$name" fi + if [ "$CLO_DATABASE" != "" ] then mysqldb="$CLO_DATABASE" @@ -617,7 +622,16 @@ if [ "$mysqluser" = "" ] then mysqluser="koha_$name" fi -mysqlhost="$(getmysqlhost)" + +if [ "$CLO_DBHOST" != "" ] +then + mysqlhost="$CLO_DBHOST" +fi + +if [ "$mysqlhost" = "" ] +then + mysqlhost="$(getmysqlhost)" +fi if [ "$op" = create ] || [ "$op" = request ] || [ "$op" = use ] then -- 2.1.4