Bug 6540 - Add defaultsql command line option
[koha_ffzg] / debian / scripts / koha-create
index e3c73fc..85b208b 100755 (executable)
 
 set -e
 
-
 die() {
     echo "$@" 1>&2
     exit 1
 }
 
-
 generate_config_file() {
     touch "$2"
     chown "root:$username" "$2"
@@ -36,6 +34,8 @@ generate_config_file() {
         -e "s/__OPACSERVER__/$domain/g" \
         -e "s/__INTRASERVER__/$intradomain/g" \
         -e "s/__ZEBRA_PASS__/$zebrapwd/g" \
+        -e "s/__ZEBRA_MARC_FORMAT__/$ZEBRA_MARC_FORMAT/g" \
+        -e "s/__ZEBRA_LANGUAGE__/$ZEBRA_LANGUAGE/g" \
         -e "s/__DB_NAME__/$mysqldb/g" \
         -e "s/__DB_HOST__/$mysqlhost/g" \
         -e "s/__DB_USER__/$mysqluser/g" \
@@ -58,30 +58,45 @@ getinstancemysqlpassword() {
         "/etc/koha/sites/$1/koha-conf.xml"
 }
 
-
 # Set defaults and read config file, if it exists.
 DOMAIN=""
 INTRAPORT="8080"
 INTRAPREFIX=""
 INTRASUFFIX=""
 DEFAULTSQL=""
+ZEBRA_MARC_FORMAT="marc21"
+ZEBRA_LANGUAGE="en"
 if [ -e /etc/koha/koha-sites.conf ]
 then
     . /etc/koha/koha-sites.conf
 fi
 
+[ $# -ge 2 ] && [ $# -le 6 ] || 
+    die "Usage: $0 [--create-db|--request-db|--populate-db] \
+[--marcflavor marc21|normarc|unimarc] \
+[--zebralang en|fr|nb] instancename"
+
+TEMP=`getopt -o crpm:l: -l create-db,request-db,populate-db,marcflavor:,zebralang: \
+     -n "$0" -- "$@"`
+
+# Note the quotes around `$TEMP': they are essential!
+eval set -- "$TEMP"
+
+while true ; do
+       case "$1" in
+               -c|--create-db) op=create ; shift ;;
+               -r|--request-db) op=request ; shift ;;
+               -p|--populate-db) op=populate ; shift ;;
+               -m|--marcflavor) ZEBRA_MARC_FORMAT="$2" ; shift 2 ;;
+               -l|--zebralang) ZEBRA_LANGUAGE="$2" ; shift 2 ;;
+               -d|--defaultsql) DEFAULTSQL="$2" ; shift 2 ;;
+               --) shift ; break ;;
+               *) die "Internal error! " ;;
+       esac
+done
 
-# Parse command line.
-[ "$#" = 2 ] || 
-    die "Usage: $0 [--create-db|--request-db|--populate-db] instancename"
-case "$1" in
-  --create-db) op=create ;;
-  --request-db) op=request ;;
-  --populate-db) op=populate ;;
-  *) die "Usage: $0 [--create-db|--request-db|--populate-db] instancename" ;;
-esac
+name="$1"
 
-name="$2"
 domain="$name$DOMAIN"
 if [ "$INTRAPORT" = 80 ] || [ "$INTRAPORT" = "" ]
 then