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 |
--letsencrypt Set up a https-only site with letsencrypt certificates |
74 |
--help,-h Show this help. |
75 |
--help,-h Show this help. |
75 |
|
76 |
|
76 |
Note: the instance name cannot be longer that 11 chars. |
77 |
Note: the instance name cannot be longer that 11 chars. |
Lines 194-199
EOM
Link Here
|
194 |
die |
195 |
die |
195 |
fi |
196 |
fi |
196 |
|
197 |
|
|
|
198 |
# Check that mod_ssl is installed and enabled. |
199 |
if [ "$CLO_LETSENCRYPT" = "yes" ]; then |
200 |
if ! /usr/sbin/apachectl -M 2> /dev/null | grep -q 'ssl_module'; then |
201 |
cat 1>&2 <<EOM |
202 |
|
203 |
Koha requires mod_ssl to be enabled within Apache in order to run with --letsencrypt. |
204 |
Typically this can be enabled with: |
205 |
|
206 |
sudo a2enmod ssl |
207 |
EOM |
208 |
die |
209 |
fi |
210 |
fi |
211 |
|
197 |
} |
212 |
} |
198 |
|
213 |
|
199 |
set_biblios_indexing_mode() |
214 |
set_biblios_indexing_mode() |
Lines 313-318
enable_sru_server()
Link Here
|
313 |
fi |
328 |
fi |
314 |
} |
329 |
} |
315 |
|
330 |
|
|
|
331 |
check_letsencrypt() |
332 |
{ |
333 |
if [ $(dpkg-query -W -f='${Status}' letsencrypt 2>/dev/null | grep -c "ok installed") -eq 0 ]; then |
334 |
apt-cache show letsencrypt &>/dev/null |
335 |
if [ $? -eq 0 ]; then |
336 |
read -r -p "The letsencrypt package is not installed. Do it now? [y/N] " response |
337 |
if [[ $response =~ ^([yY][eE][sS]|[yY])$ ]]; then |
338 |
apt-get install -y letsencrypt |
339 |
else |
340 |
die "You have to install letsencrypt to use the --letsencrypt parameter." |
341 |
fi |
342 |
else |
343 |
echo "No installation candidate available for package letsencrypt." |
344 |
read -r -p "If you have a symlink from /usr/bin/letsencrypt to letsencrypt-auto, it should work. [y/N] " response |
345 |
if [[ ! $response =~ ^([yY][eE][sS]|[yY])$ ]]; then |
346 |
die "You have to install letsencrypt to use the --letsencrypt parameter." |
347 |
fi |
348 |
fi |
349 |
fi |
350 |
} |
351 |
|
352 |
letsencrypt_instance() |
353 |
{ |
354 |
# Get letsencrypt certificates |
355 |
letsencrypt --agree-tos --renew-by-default --webroot --staging certonly \ |
356 |
-w /usr/share/koha/opac/htdocs/ -d $opacdomain -w /usr/share/koha/intranet/htdocs/ -d $intradomain |
357 |
# enable all ssl settings (apache won't start with these before certs are present) |
358 |
sed -i "s:^\s*#\(\s*SSL.*\)$:\1:" "/etc/apache2/sites-available/$name.conf" |
359 |
# change port from 80 to 443. (apache won't start if it is 443 without certs present) |
360 |
sed -i "s:^\s*\(<VirtualHost \*\:\)80> #https$:\1443>:" "/etc/apache2/sites-available/$name.conf" |
361 |
# enable redirect from http to https on port 80 |
362 |
sed -i "s:^\s*#\(.*\)#nohttps$:\1:" "/etc/apache2/sites-available/$name.conf" |
363 |
# make koha-list --letsencrypt aware of this instance # could be done by checking apache conf instead |
364 |
touch /var/lib/koha/$name/letsencrypt.enabled |
365 |
# restart apache with working certs |
366 |
service apache2 restart |
367 |
} |
368 |
|
316 |
# Set defaults and read config file, if it exists. |
369 |
# Set defaults and read config file, if it exists. |
317 |
DOMAIN="" |
370 |
DOMAIN="" |
318 |
OPACPORT="80" |
371 |
OPACPORT="80" |
Lines 356-361
END_BIBLIOS_RETRIEVAL_INFO=""
Link Here
|
356 |
START_AUTHORITIES_RETRIEVAL_INFO="" |
409 |
START_AUTHORITIES_RETRIEVAL_INFO="" |
357 |
END_AUTHORITIES_RETRIEVAL_INFO="" |
410 |
END_AUTHORITIES_RETRIEVAL_INFO="" |
358 |
|
411 |
|
|
|
412 |
APACHE_CONFIGFILE="" |
413 |
|
359 |
if [ -e /etc/koha/koha-sites.conf ] |
414 |
if [ -e /etc/koha/koha-sites.conf ] |
360 |
then |
415 |
then |
361 |
. /etc/koha/koha-sites.conf |
416 |
. /etc/koha/koha-sites.conf |
Lines 363-369
fi
Link Here
|
363 |
|
418 |
|
364 |
[ $# -ge 1 ] && [ $# -le 16 ] || ( usage ; die "Error: wrong parameters" ) |
419 |
[ $# -ge 1 ] && [ $# -le 16 ] || ( usage ; die "Error: wrong parameters" ) |
365 |
|
420 |
|
366 |
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:, \ |
421 |
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:,letsencrypt, \ |
367 |
-n "$0" -- "$@"` |
422 |
-n "$0" -- "$@"` |
368 |
|
423 |
|
369 |
# Note the quotes around `$TEMP': they are essential! |
424 |
# Note the quotes around `$TEMP': they are essential! |
Lines 379-385
CLO_AUTHORITIES_INDEXING_MODE=""
Link Here
|
379 |
CLO_MEMCACHED_SERVERS="" |
434 |
CLO_MEMCACHED_SERVERS="" |
380 |
CLO_MEMCACHED_PREFIX="" |
435 |
CLO_MEMCACHED_PREFIX="" |
381 |
CLO_UPLOAD_PATH="" |
436 |
CLO_UPLOAD_PATH="" |
382 |
|
437 |
CLO_LETSENCRYPT="" |
383 |
|
438 |
|
384 |
while true ; do |
439 |
while true ; do |
385 |
case "$1" in |
440 |
case "$1" in |
Lines 421-426
while true ; do
Link Here
|
421 |
SRU_SERVER_PORT="$2" ; shift 2 ;; |
476 |
SRU_SERVER_PORT="$2" ; shift 2 ;; |
422 |
--upload-path) |
477 |
--upload-path) |
423 |
CLO_UPLOAD_PATH="$2" ; shift 2 ;; |
478 |
CLO_UPLOAD_PATH="$2" ; shift 2 ;; |
|
|
479 |
--letsencrypt) |
480 |
CLO_LETSENCRYPT="yes" ; shift ;; |
424 |
-h|--help) |
481 |
-h|--help) |
425 |
usage ; exit 0 ;; |
482 |
usage ; exit 0 ;; |
426 |
--) |
483 |
--) |
Lines 516-521
check_apache_config
Link Here
|
516 |
opacdomain="$OPACPREFIX$name$OPACSUFFIX$DOMAIN" |
573 |
opacdomain="$OPACPREFIX$name$OPACSUFFIX$DOMAIN" |
517 |
intradomain="$INTRAPREFIX$name$INTRASUFFIX$DOMAIN" |
574 |
intradomain="$INTRAPREFIX$name$INTRASUFFIX$DOMAIN" |
518 |
|
575 |
|
|
|
576 |
# Check everything is ok with letsencrypt, die otherwise |
577 |
check_letsencrypt |
519 |
|
578 |
|
520 |
if [ -f $PASSWDFILE ] && [ `cat $PASSWDFILE | grep "^$name:"` ] |
579 |
if [ -f $PASSWDFILE ] && [ `cat $PASSWDFILE | grep "^$name:"` ] |
521 |
then |
580 |
then |
Lines 600-607
FLUSH PRIVILEGES;
Link Here
|
600 |
eof |
659 |
eof |
601 |
fi #` |
660 |
fi #` |
602 |
|
661 |
|
|
|
662 |
if [ "$CLO_LETSENCRYPT" = "yes" ]; then |
663 |
APACHE_CONFIGFILE="apache-site-https.conf.in" |
664 |
else |
665 |
APACHE_CONFIGFILE="apache-site.conf.in" |
666 |
fi |
603 |
# Generate and install Apache site-available file and log dir. |
667 |
# Generate and install Apache site-available file and log dir. |
604 |
generate_config_file apache-site.conf.in \ |
668 |
generate_config_file $APACHE_CONFIGFILE \ |
605 |
"/etc/apache2/sites-available/$name.conf" |
669 |
"/etc/apache2/sites-available/$name.conf" |
606 |
mkdir "/var/log/koha/$name" |
670 |
mkdir "/var/log/koha/$name" |
607 |
chown "$username:$username" "/var/log/koha/$name" |
671 |
chown "$username:$username" "/var/log/koha/$name" |
Lines 710-715
then
Link Here
|
710 |
# Start Indexer daemon |
774 |
# Start Indexer daemon |
711 |
koha-indexer --start "$name" |
775 |
koha-indexer --start "$name" |
712 |
fi |
776 |
fi |
|
|
777 |
|
778 |
if [ "$CLO_LETSENCRYPT" = "yes" ]; then |
779 |
# Get letsencrypt certificates |
780 |
letsencrypt_instance |
781 |
fi |
713 |
fi |
782 |
fi |
714 |
|
783 |
|
715 |
|
784 |
|