Bug 9409: Add --dbhost parameter and dbhost field
authorMark Tompsett <mtompset@hotmail.com>
Fri, 23 Jun 2017 01:46:50 +0000 (01:46 +0000)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Tue, 15 Aug 2017 15:17:44 +0000 (12:17 -0300)
This allows setting the remote db host correctly for
request-db either with a command-line or passwd file.

Signed-off-by: Lee Jamison <ldjamison@marywood.edu>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

debian/scripts/koha-create

index ba4f043..be133a1 100755 (executable)
@@ -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