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 452-458 fi Link Here
452
454
453
[ $# -ge 1 ] && [ $# -le 16 ] || ( usage ; die "Error: wrong parameters" )
455
[ $# -ge 1 ] && [ $# -le 16 ] || ( usage ; die "Error: wrong parameters" )
454
456
455
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:,smtp-host:,smtp-port,smtp-timeout:,smtp-ssl-mode:smtp-user-name:,smtp-password:,smtp-debug,letsencrypt, \
457
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:,smtp-host:,smtp-port,smtp-timeout:,smtp-ssl-mode:smtp-user-name:,smtp-password:,smtp-debug,letsencrypt, \
456
     -n "$0" -- "$@"`
458
     -n "$0" -- "$@"`
457
459
458
# Note the quotes around `$TEMP': they are essential!
460
# Note the quotes around `$TEMP': they are essential!
Lines 478-483 CLO_SMTP_SSL_MODE="" Link Here
478
CLO_SMTP_USER_NAME=""
480
CLO_SMTP_USER_NAME=""
479
CLO_SMTP_PASSWORD=""
481
CLO_SMTP_PASSWORD=""
480
CLO_SMTP_DEBUG=""
482
CLO_SMTP_DEBUG=""
483
CLO_DEFAULTSQL_CREDS=""
481
484
482
while true ; do
485
while true ; do
483
    case "$1" in
486
    case "$1" in
Lines 501-506 while true ; do Link Here
501
            CLO_ZEBRA_LANGUAGE="$2" ; shift 2 ;;
504
            CLO_ZEBRA_LANGUAGE="$2" ; shift 2 ;;
502
        -d|--defaultsql)
505
        -d|--defaultsql)
503
            CLO_DEFAULTSQL="$2" ; shift 2 ;;
506
            CLO_DEFAULTSQL="$2" ; shift 2 ;;
507
        --defaultsql-creds)
508
            CLO_DEFAULTSQL_CREDS="$2" ; shift 2 ;;
504
        -f|--configfile)
509
        -f|--configfile)
505
            configfile="$2" ; shift 2 ;;
510
            configfile="$2" ; shift 2 ;;
506
        -s|--passwdfile)
511
        -s|--passwdfile)
Lines 574-579 if [ "$CLO_DEFAULTSQL" != "" ] Link Here
574
then
579
then
575
    DEFAULTSQL="$CLO_DEFAULTSQL"
580
    DEFAULTSQL="$CLO_DEFAULTSQL"
576
fi
581
fi
582
if [ "$CLO_DEFAULTSQL_CREDS" != "" ]
583
then
584
    DEFAULTSQL_CREDS="$CLO_DEFAULTSQL_CREDS"
585
else
586
    DEFAULTSQL_CREDS="default"
587
fi
577
if [ "$CLO_ADMINUSER" != "" ]
588
if [ "$CLO_ADMINUSER" != "" ]
578
then
589
then
579
    ADMINUSER="$CLO_ADMINUSER"
590
    ADMINUSER="$CLO_ADMINUSER"
Lines 659-664 then Link Here
659
    mysqlpwd=`echo $passwdline | cut -d ":" -f 3`
670
    mysqlpwd=`echo $passwdline | cut -d ":" -f 3`
660
    mysqldb=`echo $passwdline | cut -d ":" -f 4`
671
    mysqldb=`echo $passwdline | cut -d ":" -f 4`
661
    mysqlhost=`echo $passwdline | cut -d ":" -f 5`
672
    mysqlhost=`echo $passwdline | cut -d ":" -f 5`
673
    mysqlport=`echo $passwdline | cut -d ":" -f 6`
662
fi
674
fi
663
675
664
# The order of precedence for MySQL database name is:
676
# The order of precedence for MySQL database name is:
Lines 805-822 fi Link Here
805
817
806
if [ "$op" = create ] || [ "$op" = populate ]
818
if [ "$op" = create ] || [ "$op" = populate ]
807
then
819
then
808
    # Re-fetch the passwords from the config we've generated, allows it
809
    # to be different from what we set, in case the user had to change
810
    # something.
811
    mysqluser=$(getinstancemysqluser $name)
812
    mysqldb=$(getinstancemysqldatabase $name)
813
    # Use the default database content if that exists.
820
    # Use the default database content if that exists.
814
    if [ -e "$DEFAULTSQL" ]
821
    if [ -e "$DEFAULTSQL" ]
815
    then
822
    then
823
	if [ "$DEFAULTSQL_CREDS" = "instance" ] ; then
824
	    mysqlcmd="koha-mysql $(printf %q $name)"
825
	else
826
	    mysqlcmd="mysql --host=$(printf %q $mysqlhost) --user=$(printf %q $mysqluser) --port=$(printf %q $mysqlport) --password=$(printf %q $mysqlpwd) $(printf %q $mysqldb)"
827
	fi
816
        # Populate the database with default content.
828
        # Populate the database with default content.
817
        zcat -f "$DEFAULTSQL" |
829
        zcat -f "$DEFAULTSQL" |
818
        sed "s/__KOHASITE__/koha_$name/g" |
830
        sed "s/__KOHASITE__/koha_$name/g" |
819
        mysql --host="$mysqlhost" --user="$mysqluser" --password="$mysqlpwd" "$mysqldb"
831
	$mysqlcmd
820
832
821
833
822
        # Change the default user's password.
834
        # Change the default user's password.
Lines 825-832 then Link Here
825
                      perl -e '
837
                      perl -e '
826
                            use Digest::MD5 qw(md5_base64); 
838
                            use Digest::MD5 qw(md5_base64); 
827
                            while (<>) { print md5_base64($_), "\n"; }')
839
                            while (<>) { print md5_base64($_), "\n"; }')
828
        mysql --host="$mysqlhost" --user="$mysqluser" \
840
	$mysqlcmd <<eof
829
--password="$mysqlpwd" <<eof
830
USE \`$mysqldb\`;
841
USE \`$mysqldb\`;
831
UPDATE borrowers 
842
UPDATE borrowers 
832
SET password = '$staffdigest' 
843
SET password = '$staffdigest' 
833
- 

Return to bug 23141