Bug 29957: Add --keep-cookie option to koha-create

As requested on comment99. Personally I do not feel that it
should be a requirement for adding a koha-conf entry though.
Note that koha-create does/did not even support adding multiple
line entries to koha-conf like we do here now.
But it might be a start for adding them?

Test plan:
The following tweak might help you to test without running the
complete koha-create, while still convincing you:

[1] cp debian/templates/koha-conf-site.xml.in /etc/koha/test.conf
[2] Add the following line in debian/scripts/koha-create. Append
    if after the BCRYPT_SETTINGS= line on L652:
    generate_config_file test.conf test.xml; exit
[3] Run debian/scripts/koha-create --keep-cookie A
[4] Check if you see <do_not_remove_cookie>A<..> in test.xml.
[5] Run debian/scripts/koha-create --keep-cookie A --keep-cookie B
[6] Check for two lines in test.xml
[7] Run debian/scripts/koha-create clone_name
[8] Check that the __KEEP_COOKIE__ line is gone in test.xml.
[9] Undo the tweak by removing test.xml and /etc/koha/test.conf,
    and removing the added line from koha-create.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
This commit is contained in:
Marcel de Rooy 2022-03-25 08:20:46 +00:00 committed by Fridolin Somers
parent bc75c5acf2
commit 1e32b6bc44
2 changed files with 16 additions and 1 deletions

View File

@ -90,6 +90,8 @@ Options:
--mb-pass pass RabbitMQ password (default: guest)
--mb-vhost vhost RabbitMQ vhost (default: koha_<instance>)
--keep-cookie NAME Do not clear this cookie at logout (can be repeated)
--help,-h Show this help.
Note: the instance name cannot be longer that 11 chars.
@ -105,6 +107,13 @@ generate_config_file() {
# Bug 28364: the z3950 responder needs other permissions
[ "$1" = "log4perl-site.conf.in" ] && chown "$username:$username" "$2"
# Handle repeated command line options (KEEP_COOKIE)
keep_cookie_lines=""
for cookie in "${KEEP_COOKIE[@]}"
do
keep_cookie_lines="${keep_cookie_lines} <do_not_remove_cookie>${cookie}<\/do_not_remove_cookie>\\n"
done
chmod 0640 "$2"
sed -e "s/__KOHA_CONF_DIR__/\/etc\/koha\/sites\/$name/g" \
-e "s/__KOHASITE__/$name/g" \
@ -147,6 +156,7 @@ generate_config_file() {
-e "s/__MESSAGE_BROKER_USER__/$MESSAGE_BROKER_USER/g" \
-e "s/__MESSAGE_BROKER_PASS__/$MESSAGE_BROKER_PASS/g" \
-e "s/__MESSAGE_BROKER_VHOST__/$MESSAGE_BROKER_VHOST/g" \
-e "s/ <do_not_remove_cookie>__KEEP_COOKIE__<\/do_not_remove_cookie>/$keep_cookie_lines/" \
"/etc/koha/$1" > "$2"
}
@ -475,6 +485,8 @@ END_SRU_PUBLICSERVER="-->"
APACHE_CONFIGFILE=""
declare -a KEEP_COOKIE
if [ -e /etc/koha/koha-sites.conf ]
then
. /etc/koha/koha-sites.conf
@ -482,7 +494,7 @@ fi
[ $# -ge 1 ] && [ $# -le 16 ] || ( usage ; die "Error: wrong parameters" )
TEMP=`getopt -o chrpm:l:d:f:b:a: -l create-db,request-db,populate-db,use-db,enable-sru,sru-port:,help,marcflavor:,auth-idx:,biblio-idx:,zebralang:,defaultsql:,configfile:,passwdfile:,dbhost:,database:,elasticsearch-server:,adminuser:,memcached-servers:,memcached-prefix:,template-cache-dir:,timezone:,upload-path:,tmp-path:,smtp-host:,smtp-port:,smtp-timeout:,smtp-ssl-mode:,smtp-user-name:,smtp-password:,smtp-debug,mb-host:,mb-port:,mb-user:,mb-pass:,mb-vhost:,letsencrypt, \
TEMP=`getopt -o chrpm:l:d:f:b:a: -l create-db,request-db,populate-db,use-db,enable-sru,sru-port:,help,marcflavor:,auth-idx:,biblio-idx:,zebralang:,defaultsql:,configfile:,passwdfile:,dbhost:,database:,elasticsearch-server:,adminuser:,memcached-servers:,memcached-prefix:,template-cache-dir:,timezone:,upload-path:,tmp-path:,smtp-host:,smtp-port:,smtp-timeout:,smtp-ssl-mode:,smtp-user-name:,smtp-password:,smtp-debug,mb-host:,mb-port:,mb-user:,mb-pass:,mb-vhost:,letsencrypt,keep-cookie:, \
-n "$0" -- "$@"`
# Note the quotes around `$TEMP': they are essential!
@ -549,6 +561,8 @@ while true ; do
CLO_ADMINUSER="$2" ; shift 2 ;;
--enable-sru)
ENABLE_SRU="yes" ; shift ;;
--keep-cookie)
KEEP_COOKIE+=("$2"); shift 2;;
--mb-host)
CLO_MESSAGE_BROKER_HOST="$2" ; shift 2 ;;
--mb-port)

View File

@ -449,6 +449,7 @@ __END_SRU_PUBLICSERVER__
<vhost>__MESSAGE_BROKER_VHOST__</vhost>
</message_broker>
<do_not_remove_cookie>__KEEP_COOKIE__</do_not_remove_cookie>
<!-- Uncomment lines like hereunder to not clear cookies at logout:
The cookie name is case sensitive.
<do_not_remove_cookie>KohaOpacLanguage</do_not_remove_cookie>