Bug 6540 - Add config file as command line option for koha-create

Order of precedence for config options, from lowest to highest:

1. The defaults set in koha-create itself
2. /etc/koha/koha-sites.conf
3. Config file specified with --configfile
4. Individual options set with --marcflavor, --zebralang, --defaultsql

Signed-off-by: Robin Sheat <robin@catalyst.net.nz>
Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
(cherry picked from commit b66c860d5d)

Signed-off-by: Chris Nighswonger <chris.nighswonger@gmail.com>
This commit is contained in:
Magnus Enger 2011-07-20 19:01:19 +02:00 committed by Chris Nighswonger
parent 7d99f048a4
commit e871a3faf3
1 changed files with 39 additions and 9 deletions

View File

@ -19,6 +19,11 @@
set -e
usage="Usage: $0 [--create-db|--request-db|--populate-db] \
[--marcflavor marc21|normarc|unimarc] \
[--zebralang en|fr|nb] [--defaultsql /path/to/some.sql]
[--configfile /path/to/config] instancename"
die() {
echo "$@" 1>&2
exit 1
@ -71,30 +76,55 @@ 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"
[ $# -ge 2 ] && [ $# -le 10 ] || die $usage
TEMP=`getopt -o crpm:l: -l create-db,request-db,populate-db,marcflavor:,zebralang: \
TEMP=`getopt -o crpm:l: -l create-db,request-db,populate-db,marcflavor:,zebralang:,configfile: \
-n "$0" -- "$@"`
# Note the quotes around `$TEMP': they are essential!
eval set -- "$TEMP"
# Temporary variables for the command line options
CLO_ZEBRA_MARC_FORMAT=""
CLO_ZEBRA_LANGUAGE=""
CLO_DEFAULTSQL=""
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 ;;
-m|--marcflavor) CLO_ZEBRA_MARC_FORMAT="$2" ; shift 2 ;;
-l|--zebralang) CLO_ZEBRA_LANGUAGE="$2" ; shift 2 ;;
-d|--defaultsql) CLO_DEFAULTSQL="$2" ; shift 2 ;;
-f|--configfile) configfile="$2" ; shift 2 ;;
--) shift ; break ;;
*) die "Internal error! " ;;
*) die $usage ;;
esac
done
# Load the configfile given on the command line
if [ -e "$configfile" ]
then
. "$configfile"
else
die "$configfile does not exist.";
fi
# Make sure options from the command line get the highest precedence
if [ "$CLO_ZEBRA_MARC_FORMAT" != "" ]
then
ZEBRA_MARC_FORMAT="$CLO_ZEBRA_MARC_FORMAT"
fi
if [ "$CLO_ZEBRA_LANGUAGE" != "" ]
then
ZEBRA_LANGUAGE="$CLO_ZEBRA_LANGUAGE"
fi
if [ "$CLO_DEFAULTSQL" != "" ]
then
DEFAULTSQL="$CLO_DEFAULTSQL"
fi
name="$1"
domain="$name$DOMAIN"