Lines 71-76
Options:
Link Here
|
71 |
conjunction with --defaultsql and --populate-db. |
71 |
conjunction with --defaultsql and --populate-db. |
72 |
--upload-path dir Set a user defined upload_path. It defaults to |
72 |
--upload-path dir Set a user defined upload_path. It defaults to |
73 |
/var/lib/koha/<instance>/uploads |
73 |
/var/lib/koha/<instance>/uploads |
|
|
74 |
--force-https Set up a https-only site with letsencrypt certificates |
75 |
--letsencrypt Path to the letsencrypt folder |
74 |
--help,-h Show this help. |
76 |
--help,-h Show this help. |
75 |
|
77 |
|
76 |
Note: the instance name cannot be longer that 11 chars. |
78 |
Note: the instance name cannot be longer that 11 chars. |
Lines 192-197
EOM
Link Here
|
192 |
die |
194 |
die |
193 |
fi |
195 |
fi |
194 |
|
196 |
|
|
|
197 |
# Check that mod_ssl is installed and enabled. |
198 |
if [ "$USE_HTTPS" = "yes" ]; then |
199 |
if ! /usr/sbin/apachectl -M 2> /dev/null | grep -q 'ssl_module'; then |
200 |
cat 1>&2 <<EOM |
201 |
|
202 |
Koha requires mod_ssl to be enabled within Apache in order to run with --force-https. |
203 |
Typically this can be enabled with: |
204 |
|
205 |
sudo a2enmod ssl |
206 |
EOM |
207 |
die |
208 |
fi |
209 |
fi |
210 |
|
195 |
} |
211 |
} |
196 |
|
212 |
|
197 |
set_biblios_indexing_mode() |
213 |
set_biblios_indexing_mode() |
Lines 311-316
enable_sru_server()
Link Here
|
311 |
fi |
327 |
fi |
312 |
} |
328 |
} |
313 |
|
329 |
|
|
|
330 |
letsencrypt_instance() |
331 |
{ |
332 |
# Get letsencrypt certificates |
333 |
$LETSENCRYPT_PATH/letsencrypt-auto --agree-tos --renew-by-default --webroot --server https://acme-v01.api.letsencrypt.org/directory certonly \ |
334 |
-w /usr/share/koha/opac/htdocs/ -d $opacdomain -w /usr/share/koha/intranet/htdocs/ -d $intradomain |
335 |
# enable all ssl settings (apache won't start with these before certs are present) |
336 |
sed -i "s:^\s*#\(\s*SSL.*\)$:\1:" "/etc/apache2/sites-available/$name.conf" |
337 |
# change port from 80 to 443. (apache won't start if it is 443 without certs present) |
338 |
sed -i "s:^\s*\(<VirtualHost \*\:\)80> #https$:\1443>:" "/etc/apache2/sites-available/$name.conf" |
339 |
# enable redirect from http to https on port 80 |
340 |
sed -i "s:^\s*#\(.*\)#nohttps$:\1:" "/etc/apache2/sites-available/$name.conf" |
341 |
# make koha-list --letsencrypt aware of this instance # could be done by checking apache conf instead |
342 |
touch /var/lib/koha/$name/letsencrypt.enabled |
343 |
# restart apache with working certs |
344 |
service apache2 restart |
345 |
} |
346 |
|
314 |
# Set defaults and read config file, if it exists. |
347 |
# Set defaults and read config file, if it exists. |
315 |
DOMAIN="" |
348 |
DOMAIN="" |
316 |
OPACPORT="80" |
349 |
OPACPORT="80" |
Lines 354-359
END_BIBLIOS_RETRIEVAL_INFO=""
Link Here
|
354 |
START_AUTHORITIES_RETRIEVAL_INFO="" |
387 |
START_AUTHORITIES_RETRIEVAL_INFO="" |
355 |
END_AUTHORITIES_RETRIEVAL_INFO="" |
388 |
END_AUTHORITIES_RETRIEVAL_INFO="" |
356 |
|
389 |
|
|
|
390 |
APACHE_CONFIGFILE="" |
391 |
LETSENCRYPT_PATH="/usr/bin/" |
392 |
|
357 |
if [ -e /etc/koha/koha-sites.conf ] |
393 |
if [ -e /etc/koha/koha-sites.conf ] |
358 |
then |
394 |
then |
359 |
. /etc/koha/koha-sites.conf |
395 |
. /etc/koha/koha-sites.conf |
Lines 361-367
fi
Link Here
|
361 |
|
397 |
|
362 |
[ $# -ge 1 ] && [ $# -le 16 ] || ( usage ; die "Error: wrong parameters" ) |
398 |
[ $# -ge 1 ] && [ $# -le 16 ] || ( usage ; die "Error: wrong parameters" ) |
363 |
|
399 |
|
364 |
TEMP=`getopt -o chrpm:l:d:f:b:a: -l create-db,request-db,populate-db,use-db,use-memcached,enable-sru,sru-port:,help,marcflavor:,auth-idx:,biblio-idx:,zebralang:,defaultsql:,configfile:,passwdfile:,database:,adminuser:,memcached-servers:,memcached-prefix:,upload-path:, \ |
400 |
TEMP=`getopt -o chrpm:l:d:f:b:a: -l create-db,request-db,populate-db,use-db,use-memcached,enable-sru,sru-port:,help,marcflavor:,auth-idx:,biblio-idx:,zebralang:,defaultsql:,configfile:,passwdfile:,database:,adminuser:,memcached-servers:,memcached-prefix:,upload-path:,force-https,letsencrypt:, \ |
365 |
-n "$0" -- "$@"` |
401 |
-n "$0" -- "$@"` |
366 |
|
402 |
|
367 |
# Note the quotes around `$TEMP': they are essential! |
403 |
# Note the quotes around `$TEMP': they are essential! |
Lines 378-384
CLO_MEMCACHED_SERVERS=""
Link Here
|
378 |
CLO_MEMCACHED_PREFIX="" |
414 |
CLO_MEMCACHED_PREFIX="" |
379 |
CLO_UPLOAD_PATH="" |
415 |
CLO_UPLOAD_PATH="" |
380 |
|
416 |
|
381 |
|
|
|
382 |
while true ; do |
417 |
while true ; do |
383 |
case "$1" in |
418 |
case "$1" in |
384 |
-c|--create-db) |
419 |
-c|--create-db) |
Lines 419-424
while true ; do
Link Here
|
419 |
SRU_SERVER_PORT="$2" ; shift 2 ;; |
454 |
SRU_SERVER_PORT="$2" ; shift 2 ;; |
420 |
--upload-path) |
455 |
--upload-path) |
421 |
CLO_UPLOAD_PATH="$2" ; shift 2 ;; |
456 |
CLO_UPLOAD_PATH="$2" ; shift 2 ;; |
|
|
457 |
--force-https) |
458 |
USE_HTTPS="yes" ; shift ;; |
459 |
--letsencrypt) |
460 |
LETSENCRYPT_PATH="$2" ; shift 2 ;; |
422 |
-h|--help) |
461 |
-h|--help) |
423 |
usage ; exit 0 ;; |
462 |
usage ; exit 0 ;; |
424 |
--) |
463 |
--) |
Lines 514-519
check_apache_config
Link Here
|
514 |
opacdomain="$OPACPREFIX$name$OPACSUFFIX$DOMAIN" |
553 |
opacdomain="$OPACPREFIX$name$OPACSUFFIX$DOMAIN" |
515 |
intradomain="$INTRAPREFIX$name$INTRASUFFIX$DOMAIN" |
554 |
intradomain="$INTRAPREFIX$name$INTRASUFFIX$DOMAIN" |
516 |
|
555 |
|
|
|
556 |
# Check if letsencrypt path is valid, die otherwise |
557 |
if [ ! -e "$LETSENCRYPT_PATH/letsencrypt-auto" ]; then |
558 |
die "Cannot find letsencrypt-auto in $LETSENCRYPT_PATH" |
559 |
fi |
517 |
|
560 |
|
518 |
if [ -f $PASSWDFILE ] && [ `cat $PASSWDFILE | grep "^$name:"` ] |
561 |
if [ -f $PASSWDFILE ] && [ `cat $PASSWDFILE | grep "^$name:"` ] |
519 |
then |
562 |
then |
Lines 598-605
FLUSH PRIVILEGES;
Link Here
|
598 |
eof |
641 |
eof |
599 |
fi #` |
642 |
fi #` |
600 |
|
643 |
|
|
|
644 |
if [ "$USE_HTTPS" = "yes" ]; then |
645 |
APACHE_CONFIGFILE="apache-site-https.conf.in" |
646 |
else |
647 |
APACHE_CONFIGFILE="apache-site.conf.in" |
648 |
fi |
601 |
# Generate and install Apache site-available file and log dir. |
649 |
# Generate and install Apache site-available file and log dir. |
602 |
generate_config_file apache-site.conf.in \ |
650 |
generate_config_file $APACHE_CONFIGFILE \ |
603 |
"/etc/apache2/sites-available/$name.conf" |
651 |
"/etc/apache2/sites-available/$name.conf" |
604 |
mkdir "/var/log/koha/$name" |
652 |
mkdir "/var/log/koha/$name" |
605 |
chown "$username:$username" "/var/log/koha/$name" |
653 |
chown "$username:$username" "/var/log/koha/$name" |
Lines 708-713
then
Link Here
|
708 |
# Start Indexer daemon |
756 |
# Start Indexer daemon |
709 |
koha-indexer --start "$name" |
757 |
koha-indexer --start "$name" |
710 |
fi |
758 |
fi |
|
|
759 |
|
760 |
if [ "$USE_HTTPS" = "yes" ]; then |
761 |
# Get letsencrypt certificates |
762 |
letsencrypt_instance |
763 |
fi |
711 |
fi |
764 |
fi |
712 |
|
765 |
|
713 |
|
766 |
|