Lines 1-4
Link Here
|
1 |
#!/bin/sh |
1 |
#!/bin/bash |
2 |
# |
2 |
# |
3 |
# koha-create -- Create a new Koha instance. |
3 |
# koha-create -- Create a new Koha instance. |
4 |
# Copyright 2010 Catalyst IT, Ltd |
4 |
# Copyright 2010 Catalyst IT, Ltd |
Lines 22-27
set -e
Link Here
|
22 |
usage="Usage: $0 [--create-db|--request-db|--populate-db|--use-db] \ |
22 |
usage="Usage: $0 [--create-db|--request-db|--populate-db|--use-db] \ |
23 |
[--marcflavor marc21|normarc|unimarc] \ |
23 |
[--marcflavor marc21|normarc|unimarc] \ |
24 |
[--zebralang en|es|fr|nb|ru|uk] \ |
24 |
[--zebralang en|es|fr|nb|ru|uk] \ |
|
|
25 |
[--auth-idx dom|grs1] [--biblio-idx dom|grs1] \ |
25 |
[--defaultsql /path/to/some.sql] \ |
26 |
[--defaultsql /path/to/some.sql] \ |
26 |
[--configfile /path/to/config] [--passwdfile /path/to/passwd] \ |
27 |
[--configfile /path/to/config] [--passwdfile /path/to/passwd] \ |
27 |
[--database database] [--adminuser n] instancename" |
28 |
[--database database] [--adminuser n] instancename" |
Lines 45-50
generate_config_file() {
Link Here
|
45 |
-e "s/__ZEBRA_PASS__/$zebrapwd/g" \ |
46 |
-e "s/__ZEBRA_PASS__/$zebrapwd/g" \ |
46 |
-e "s/__ZEBRA_MARC_FORMAT__/$ZEBRA_MARC_FORMAT/g" \ |
47 |
-e "s/__ZEBRA_MARC_FORMAT__/$ZEBRA_MARC_FORMAT/g" \ |
47 |
-e "s/__ZEBRA_LANGUAGE__/$ZEBRA_LANGUAGE/g" \ |
48 |
-e "s/__ZEBRA_LANGUAGE__/$ZEBRA_LANGUAGE/g" \ |
|
|
49 |
-e "s/__BIBLIOS_INDEXING_MODE__/$BIBLIOS_INDEXING_MODE/g" \ |
50 |
-e "s/__AUTHORITIES_INDEXING_MODE__/$AUTHORITIES_INDEXING_MODE/g" \ |
51 |
-e "s/__ZEBRA_BIBLIOS_CFG__/$ZEBRA_BIBLIOS_CFG/g" \ |
52 |
-e "s/__ZEBRA_AUTHORITIES_CFG__/$ZEBRA_AUTHORITIES_CFG/g" \ |
53 |
-e "s/__START_BIBLIOS_RETRIEVAL_INFO__/`echo $START_BIBLIOS_RETRIEVAL_INFO`/g" \ |
54 |
-e "s/__END_BIBLIOS_RETRIEVAL_INFO__/`echo $END_BIBLIOS_RETRIEVAL_INFO`/g" \ |
55 |
-e "s/__START_AUTHORITIES_RETRIEVAL_INFO__/`echo $START_AUTHORITIES_RETRIEVAL_INFO`/g" \ |
56 |
-e "s/__END_AUTHORITIES_RETRIEVAL_INFO__/`echo $END_AUTHORITIES_RETRIEVAL_INFO`/g" \ |
48 |
-e "s/__DB_NAME__/$mysqldb/g" \ |
57 |
-e "s/__DB_NAME__/$mysqldb/g" \ |
49 |
-e "s/__DB_HOST__/$mysqlhost/g" \ |
58 |
-e "s/__DB_HOST__/$mysqlhost/g" \ |
50 |
-e "s/__DB_USER__/$mysqluser/g" \ |
59 |
-e "s/__DB_USER__/$mysqluser/g" \ |
Lines 53-58
generate_config_file() {
Link Here
|
53 |
-e "s/__UNIXGROUP__/$username/g" \ |
62 |
-e "s/__UNIXGROUP__/$username/g" \ |
54 |
-e "s/__PLUGINS_DIR__/\/var\/lib\/koha\/$name\/plugins/g" \ |
63 |
-e "s/__PLUGINS_DIR__/\/var\/lib\/koha\/$name\/plugins/g" \ |
55 |
"/etc/koha/$1" > "$2" |
64 |
"/etc/koha/$1" > "$2" |
|
|
65 |
|
56 |
} |
66 |
} |
57 |
|
67 |
|
58 |
getmysqlhost() { |
68 |
getmysqlhost() { |
Lines 75-80
getinstancemysqldatabase() {
Link Here
|
75 |
xmlstarlet sel -t -v 'yazgfs/config/database' "/etc/koha/sites/$1/koha-conf.xml" |
85 |
xmlstarlet sel -t -v 'yazgfs/config/database' "/etc/koha/sites/$1/koha-conf.xml" |
76 |
} |
86 |
} |
77 |
|
87 |
|
|
|
88 |
set_biblios_indexing_mode() |
89 |
{ |
90 |
local indexing_mode=$1 |
91 |
local marc_format=$2 |
92 |
|
93 |
case $indexing_mode in |
94 |
"dom") |
95 |
START_BIBLIOS_RETRIEVAL_INFO=`cat <<EOF |
96 |
<xi:include href="\/etc\/koha\/$marc_format-retrieval-info-bib-dom.xml"\n |
97 |
xmlns:xi="http:\/\/www.w3.org\/2001\/XInclude">\n |
98 |
<xi:fallback>\n |
99 |
<retrievalinfo> |
100 |
EOF` |
101 |
|
102 |
END_BIBLIOS_RETRIEVAL_INFO=`cat <<EOF |
103 |
<\/retrievalinfo>\n |
104 |
<\/xi:fallback>\n |
105 |
<\/xi:include> |
106 |
EOF` |
107 |
BIBLIOS_INDEXING_MODE="dom" |
108 |
ZEBRA_BIBLIOS_CFG="zebra-biblios-dom.cfg" |
109 |
;; |
110 |
"grs1") |
111 |
START_BIBLIOS_RETRIEVAL_INFO=" <retrievalinfo>" |
112 |
END_BIBLIOS_RETRIEVAL_INFO=" <\/retrievalinfo>" |
113 |
BIBLIOS_INDEXING_MODE="grs1" |
114 |
ZEBRA_BIBLIOS_CFG="zebra-biblios.cfg" |
115 |
;; |
116 |
*) |
117 |
die "Error: '$indexing_mode' is not a valid indexing mode for bibliographic records." |
118 |
;; |
119 |
esac |
120 |
} |
121 |
|
122 |
|
123 |
set_authorities_indexing_mode() |
124 |
{ |
125 |
local indexing_mode=$1 |
126 |
local marc_format=$2 |
127 |
|
128 |
case $indexing_mode in |
129 |
"dom") |
130 |
START_AUTHORITIES_RETRIEVAL_INFO=`cat <<EOF |
131 |
<xi:include href="\/etc\/koha\/$marc_format-retrieval-info-auth-dom.xml"\n |
132 |
xmlns:xi="http:\/\/www.w3.org\/2001\/XInclude">\n |
133 |
<xi:fallback>\n |
134 |
<retrievalinfo> |
135 |
EOF` |
136 |
|
137 |
END_AUTHORITIES_RETRIEVAL_INFO=`cat <<EOF |
138 |
<\/retrievalinfo>\n |
139 |
<\/xi:fallback>\n |
140 |
<\/xi:include>\n |
141 |
EOF` |
142 |
AUTHORITIES_INDEXING_MODE="dom" |
143 |
ZEBRA_AUTHORITIES_CFG="zebra-authorities-dom.cfg" |
144 |
;; |
145 |
"grs1") |
146 |
START_AUTHORITIES_RETRIEVAL_INFO=" <retrievalinfo>" |
147 |
END_AUTHORITIES_RETRIEVAL_INFO=" <\/retrievalinfo>" |
148 |
AUTHORITIES_INDEXING_MODE="grs1" |
149 |
ZEBRA_AUTHORITIES_CFG="zebra-authorities.cfg" |
150 |
;; |
151 |
*) |
152 |
die "Error: '$indexing_mode' is not a valid indexing mode for authority records." |
153 |
;; |
154 |
esac |
155 |
} |
156 |
|
78 |
# Set defaults and read config file, if it exists. |
157 |
# Set defaults and read config file, if it exists. |
79 |
DOMAIN="" |
158 |
DOMAIN="" |
80 |
OPACPORT="80" |
159 |
OPACPORT="80" |
Lines 88-93
ZEBRA_MARC_FORMAT="marc21"
Link Here
|
88 |
ZEBRA_LANGUAGE="en" |
167 |
ZEBRA_LANGUAGE="en" |
89 |
ADMINUSER="1" |
168 |
ADMINUSER="1" |
90 |
PASSWDFILE="/etc/koha/passwd" |
169 |
PASSWDFILE="/etc/koha/passwd" |
|
|
170 |
|
171 |
# Indexing mode variables (default is DOM) |
172 |
BIBLIOS_INDEXING_MODE="dom" |
173 |
AUTHORITIES_INDEXING_MODE="dom" |
174 |
|
175 |
START_BIBLIOS_RETRIEVAL_INFO="" |
176 |
END_BIBLIOS_RETRIEVAL_INFO="" |
177 |
START_AUTHORITIES_RETRIEVAL_INFO="" |
178 |
END_AUTHORITIES_RETRIEVAL_INFO="" |
179 |
|
91 |
if [ -e /etc/koha/koha-sites.conf ] |
180 |
if [ -e /etc/koha/koha-sites.conf ] |
92 |
then |
181 |
then |
93 |
. /etc/koha/koha-sites.conf |
182 |
. /etc/koha/koha-sites.conf |
Lines 95-101
fi
Link Here
|
95 |
|
184 |
|
96 |
[ $# -ge 2 ] && [ $# -le 16 ] || die $usage |
185 |
[ $# -ge 2 ] && [ $# -le 16 ] || die $usage |
97 |
|
186 |
|
98 |
TEMP=`getopt -o crpm:l:d:f:b:a: -l create-db,request-db,populate-db,use-db,marcflavor:,zebralang:,defaultsql:,configfile:,passwdfile:,database:,adminuser: \ |
187 |
TEMP=`getopt -o crpm:l:d:f:b:a: -l create-db,request-db,populate-db,use-db,marcflavor:,auth-idx:,biblio-idx:,zebralang:,defaultsql:,configfile:,passwdfile:,database:,adminuser: \ |
99 |
-n "$0" -- "$@"` |
188 |
-n "$0" -- "$@"` |
100 |
|
189 |
|
101 |
# Note the quotes around `$TEMP': they are essential! |
190 |
# Note the quotes around `$TEMP': they are essential! |
Lines 106-111
CLO_ZEBRA_MARC_FORMAT=""
Link Here
|
106 |
CLO_ZEBRA_LANGUAGE="" |
195 |
CLO_ZEBRA_LANGUAGE="" |
107 |
CLO_DEFAULTSQL="" |
196 |
CLO_DEFAULTSQL="" |
108 |
CLO_ADMINUSER="" |
197 |
CLO_ADMINUSER="" |
|
|
198 |
CLO_BIBLIOS_INDEXING_MODE="" |
199 |
CLO_AUTHORITIES_INDEXING_MODE="" |
200 |
|
109 |
|
201 |
|
110 |
while true ; do |
202 |
while true ; do |
111 |
case "$1" in |
203 |
case "$1" in |
Lines 115-120
while true ; do
Link Here
|
115 |
-u|--use-db) op=use ; shift ;; |
207 |
-u|--use-db) op=use ; shift ;; |
116 |
-m|--marcflavor) CLO_ZEBRA_MARC_FORMAT="$2" ; shift 2 ;; |
208 |
-m|--marcflavor) CLO_ZEBRA_MARC_FORMAT="$2" ; shift 2 ;; |
117 |
-l|--zebralang) CLO_ZEBRA_LANGUAGE="$2" ; shift 2 ;; |
209 |
-l|--zebralang) CLO_ZEBRA_LANGUAGE="$2" ; shift 2 ;; |
|
|
210 |
--auth-idx) CLO_AUTHORITIES_INDEXING_MODE="$2" ; shift 2 ;; |
211 |
--biblio-idx) CLO_BIBLIOS_INDEXING_MODE="$2" ; shift 2 ;; |
118 |
-d|--defaultsql) CLO_DEFAULTSQL="$2" ; shift 2 ;; |
212 |
-d|--defaultsql) CLO_DEFAULTSQL="$2" ; shift 2 ;; |
119 |
-f|--configfile) configfile="$2" ; shift 2 ;; |
213 |
-f|--configfile) configfile="$2" ; shift 2 ;; |
120 |
-s|--passwdfile) CLO_PASSWDFILE="$2" ; shift 2 ;; |
214 |
-s|--passwdfile) CLO_PASSWDFILE="$2" ; shift 2 ;; |
Lines 158-163
then
Link Here
|
158 |
PASSWDFILE="$CLO_PASSWDFILE" |
252 |
PASSWDFILE="$CLO_PASSWDFILE" |
159 |
fi |
253 |
fi |
160 |
|
254 |
|
|
|
255 |
if [ "$CLO_BIBLIOS_INDEXING_MODE" != "" ]; then |
256 |
BIBLIOS_INDEXING_MODE=$CLO_BIBLIOS_INDEXING_MODE |
257 |
fi |
258 |
|
259 |
set_biblios_indexing_mode $BIBLIOS_INDEXING_MODE $ZEBRA_MARC_FORMAT |
260 |
|
261 |
|
262 |
if [ "$CLO_AUTHORITIES_INDEXING_MODE" != "" ]; then |
263 |
AUTHORITIES_INDEXING_MODE=$CLO_AUTHORITIES_INDEXING_MODE |
264 |
fi |
265 |
|
266 |
set_authorities_indexing_mode $AUTHORITIES_INDEXING_MODE $ZEBRA_MARC_FORMAT |
267 |
|
161 |
name="$1" |
268 |
name="$1" |
162 |
|
269 |
|
163 |
opacdomain="$OPACPREFIX$name$OPACSUFFIX$DOMAIN" |
270 |
opacdomain="$OPACPREFIX$name$OPACSUFFIX$DOMAIN" |
Lines 261-266
eof
Link Here
|
261 |
# Generate and install Zebra config files. |
368 |
# Generate and install Zebra config files. |
262 |
generate_config_file zebra-biblios-site.cfg.in \ |
369 |
generate_config_file zebra-biblios-site.cfg.in \ |
263 |
"/etc/koha/sites/$name/zebra-biblios.cfg" |
370 |
"/etc/koha/sites/$name/zebra-biblios.cfg" |
|
|
371 |
generate_config_file zebra-biblios-dom-site.cfg.in \ |
372 |
"/etc/koha/sites/$name/zebra-biblios-dom.cfg" |
264 |
generate_config_file zebra-authorities-site.cfg.in \ |
373 |
generate_config_file zebra-authorities-site.cfg.in \ |
265 |
"/etc/koha/sites/$name/zebra-authorities.cfg" |
374 |
"/etc/koha/sites/$name/zebra-authorities.cfg" |
266 |
generate_config_file zebra-authorities-dom-site.cfg.in \ |
375 |
generate_config_file zebra-authorities-dom-site.cfg.in \ |