View | Details | Raw Unified | Return to bug 23141
Collapse All | Expand All

(-)a/debian/scripts/koha-create (-10 / +20 lines)
Lines 69-74 Options: Link Here
69
  --database dbname         Enforce the use of the specified DB name (64 char limit)
69
  --database dbname         Enforce the use of the specified DB name (64 char limit)
70
  --adminuser n             Explicit the admin user ID in the DB. Relevant in
70
  --adminuser n             Explicit the admin user ID in the DB. Relevant in
71
                            conjunction with --defaultsql and --populate-db.
71
                            conjunction with --defaultsql and --populate-db.
72
  --defaultsql-creds src    Which source should be used for database credentials to use
73
                            when populating the database with --defaultsql.  (default|instance)
72
  --template-cache-dir      Set a user defined template_cache_dir. It defaults to
74
  --template-cache-dir      Set a user defined template_cache_dir. It defaults to
73
                            /var/cache/koha/<instance>/templates
75
                            /var/cache/koha/<instance>/templates
74
  --timezone time/zone      Specify a timezone. e.g. America/Argentina
76
  --timezone time/zone      Specify a timezone. e.g. America/Argentina
Lines 397-403 fi Link Here
397
399
398
[ $# -ge 1 ] && [ $# -le 16 ] || ( usage ; die "Error: wrong parameters" )
400
[ $# -ge 1 ] && [ $# -le 16 ] || ( usage ; die "Error: wrong parameters" )
399
401
400
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, \
402
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, \
401
     -n "$0" -- "$@"`
403
     -n "$0" -- "$@"`
402
404
403
# Note the quotes around `$TEMP': they are essential!
405
# Note the quotes around `$TEMP': they are essential!
Lines 416-421 CLO_TMP_PATH="" Link Here
416
CLO_LETSENCRYPT=""
418
CLO_LETSENCRYPT=""
417
CLO_TEMPLATE_CACHE_DIR=""
419
CLO_TEMPLATE_CACHE_DIR=""
418
CLO_TIMEZONE=""
420
CLO_TIMEZONE=""
421
CLO_DEFAULTSQL_CREDS=""
419
422
420
while true ; do
423
while true ; do
421
    case "$1" in
424
    case "$1" in
Lines 439-444 while true ; do Link Here
439
            CLO_ZEBRA_LANGUAGE="$2" ; shift 2 ;;
442
            CLO_ZEBRA_LANGUAGE="$2" ; shift 2 ;;
440
        -d|--defaultsql)
443
        -d|--defaultsql)
441
            CLO_DEFAULTSQL="$2" ; shift 2 ;;
444
            CLO_DEFAULTSQL="$2" ; shift 2 ;;
445
        --defaultsql-creds)
446
            CLO_DEFAULTSQL_CREDS="$2" ; shift 2 ;;
442
        -f|--configfile)
447
        -f|--configfile)
443
            configfile="$2" ; shift 2 ;;
448
            configfile="$2" ; shift 2 ;;
444
        -s|--passwdfile)
449
        -s|--passwdfile)
Lines 498-503 if [ "$CLO_DEFAULTSQL" != "" ] Link Here
498
then
503
then
499
    DEFAULTSQL="$CLO_DEFAULTSQL"
504
    DEFAULTSQL="$CLO_DEFAULTSQL"
500
fi
505
fi
506
if [ "$CLO_DEFAULTSQL_CREDS" != "" ]
507
then
508
    DEFAULTSQL_CREDS="$CLO_DEFAULTSQL_CREDS"
509
else
510
    DEFAULTSQL_CREDS="default"
511
fi
501
if [ "$CLO_ADMINUSER" != "" ]
512
if [ "$CLO_ADMINUSER" != "" ]
502
then
513
then
503
    ADMINUSER="$CLO_ADMINUSER"
514
    ADMINUSER="$CLO_ADMINUSER"
Lines 579-584 then Link Here
579
    mysqlpwd=`echo $passwdline | cut -d ":" -f 3`
590
    mysqlpwd=`echo $passwdline | cut -d ":" -f 3`
580
    mysqldb=`echo $passwdline | cut -d ":" -f 4`
591
    mysqldb=`echo $passwdline | cut -d ":" -f 4`
581
    mysqlhost=`echo $passwdline | cut -d ":" -f 5`
592
    mysqlhost=`echo $passwdline | cut -d ":" -f 5`
593
    mysqlport=`echo $passwdline | cut -d ":" -f 6`
582
fi
594
fi
583
595
584
# The order of precedence for MySQL database name is:
596
# The order of precedence for MySQL database name is:
Lines 725-742 fi Link Here
725
737
726
if [ "$op" = create ] || [ "$op" = populate ]
738
if [ "$op" = create ] || [ "$op" = populate ]
727
then
739
then
728
    # Re-fetch the passwords from the config we've generated, allows it
729
    # to be different from what we set, in case the user had to change
730
    # something.
731
    mysqluser=$(getinstancemysqluser $name)
732
    mysqldb=$(getinstancemysqldatabase $name)
733
    # Use the default database content if that exists.
740
    # Use the default database content if that exists.
734
    if [ -e "$DEFAULTSQL" ]
741
    if [ -e "$DEFAULTSQL" ]
735
    then
742
    then
743
	if [ "$DEFAULTSQL_CREDS" = "instance" ] ; then
744
	    mysqlcmd="koha-mysql $(printf %q $name)"
745
	else
746
	    mysqlcmd="mysql --host=$(printf %q $mysqlhost) --user=$(printf %q $mysqluser) --port=$(printf %q $mysqlport) --password=$(printf %q $mysqlpwd) $(printf %q $mysqldb)"
747
	fi
736
        # Populate the database with default content.
748
        # Populate the database with default content.
737
        zcat -f "$DEFAULTSQL" |
749
        zcat -f "$DEFAULTSQL" |
738
        sed "s/__KOHASITE__/koha_$name/g" |
750
        sed "s/__KOHASITE__/koha_$name/g" |
739
        mysql --host="$mysqlhost" --user="$mysqluser" --password="$mysqlpwd" "$mysqldb"
751
	$mysqlcmd
740
752
741
753
742
        # Change the default user's password.
754
        # Change the default user's password.
Lines 745-752 then Link Here
745
                      perl -e '
757
                      perl -e '
746
                            use Digest::MD5 qw(md5_base64); 
758
                            use Digest::MD5 qw(md5_base64); 
747
                            while (<>) { print md5_base64($_), "\n"; }')
759
                            while (<>) { print md5_base64($_), "\n"; }')
748
        mysql --host="$mysqlhost" --user="$mysqluser" \
760
	$mysqlcmd <<eof
749
--password="$mysqlpwd" <<eof
750
USE \`$mysqldb\`;
761
USE \`$mysqldb\`;
751
UPDATE borrowers 
762
UPDATE borrowers 
752
SET password = '$staffdigest' 
763
SET password = '$staffdigest' 
753
- 

Return to bug 23141