@@ -, +, @@ populating db. --- debian/scripts/koha-create | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) --- a/debian/scripts/koha-create +++ a/debian/scripts/koha-create @@ -69,6 +69,8 @@ Options: --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. + --defaultsql-creds src Which source should be used for database credentials to use + when populating the database with --defaultsql. (default|instance) --template-cache-dir Set a user defined template_cache_dir. It defaults to /var/cache/koha//templates --timezone time/zone Specify a timezone. e.g. America/Argentina @@ -397,7 +399,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,enable-sru,sru-port:,help,marcflavor:,auth-idx:,biblio-idx:,zebralang:,defaultsql:,configfile:,passwdfile:,dbhost:,dbport:,database:,elasticsearch-server:,adminuser:,memcached-servers:,memcached-prefix:,template-cache-dir:,timezone:,upload-path:,tmp-path:,letsencrypt, \ +TEMP=`getopt -o chrpm:l:d:f:b:a: -l create-db,request-db,populate-db,use-db,enable-sru,sru-port:,help,marcflavor:,auth-idx:,biblio-idx:,zebralang:,defaultsql:,defaultsql-creds:,configfile:,passwdfile:,dbhost:,dbport:,database:,elasticsearch-server:,adminuser:,memcached-servers:,memcached-prefix:,template-cache-dir:,timezone:,upload-path:,tmp-path:,letsencrypt, \ -n "$0" -- "$@"` # Note the quotes around `$TEMP': they are essential! @@ -416,6 +418,7 @@ CLO_TMP_PATH="" CLO_LETSENCRYPT="" CLO_TEMPLATE_CACHE_DIR="" CLO_TIMEZONE="" +CLO_DEFAULTSQL_CREDS="" while true ; do case "$1" in @@ -439,6 +442,8 @@ while true ; do CLO_ZEBRA_LANGUAGE="$2" ; shift 2 ;; -d|--defaultsql) CLO_DEFAULTSQL="$2" ; shift 2 ;; + --defaultsql-creds) + CLO_DEFAULTSQL_CREDS="$2" ; shift 2 ;; -f|--configfile) configfile="$2" ; shift 2 ;; -s|--passwdfile) @@ -498,6 +503,12 @@ if [ "$CLO_DEFAULTSQL" != "" ] then DEFAULTSQL="$CLO_DEFAULTSQL" fi +if [ "$CLO_DEFAULTSQL_CREDS" != "" ] +then + DEFAULTSQL_CREDS="$CLO_DEFAULTSQL_CREDS" +else + DEFAULTSQL_CREDS="default" +fi if [ "$CLO_ADMINUSER" != "" ] then ADMINUSER="$CLO_ADMINUSER" @@ -579,6 +590,7 @@ then mysqlpwd=`echo $passwdline | cut -d ":" -f 3` mysqldb=`echo $passwdline | cut -d ":" -f 4` mysqlhost=`echo $passwdline | cut -d ":" -f 5` + mysqlport=`echo $passwdline | cut -d ":" -f 6` fi # The order of precedence for MySQL database name is: @@ -725,18 +737,18 @@ 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 + if [ "$DEFAULTSQL_CREDS" = "instance" ] ; then + mysqlcmd="koha-mysql $(printf %q $name)" + else + mysqlcmd="mysql --host=$(printf %q $mysqlhost) --user=$(printf %q $mysqluser) --port=$(printf %q $mysqlport) --password=$(printf %q $mysqlpwd) $(printf %q $mysqldb)" + fi # Populate the database with default content. zcat -f "$DEFAULTSQL" | sed "s/__KOHASITE__/koha_$name/g" | - mysql --host="$mysqlhost" --user="$mysqluser" --password="$mysqlpwd" "$mysqldb" + $mysqlcmd # Change the default user's password. @@ -745,8 +757,7 @@ then perl -e ' use Digest::MD5 qw(md5_base64); while (<>) { print md5_base64($_), "\n"; }') - mysql --host="$mysqlhost" --user="$mysqluser" \ ---password="$mysqlpwd" <