From 4f5c0df5a4a832e57433fd2bb161d53bac9057d5 Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Fri, 25 Mar 2022 08:20:46 +0000 Subject: [PATCH] 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 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 Signed-off-by: Nick Clemens Signed-off-by: Martin Renvoize Signed-off-by: Fridolin Somers Signed-off-by: Kyle M Hall --- debian/scripts/koha-create | 16 +++++++++++++++- debian/templates/koha-conf-site.xml.in | 1 + 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/debian/scripts/koha-create b/debian/scripts/koha-create index 1f761e95ea..c833b451ad 100755 --- a/debian/scripts/koha-create +++ b/debian/scripts/koha-create @@ -90,6 +90,8 @@ Options: --mb-pass pass RabbitMQ password (default: guest) --mb-vhost vhost RabbitMQ vhost (default: koha_) + --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} ${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/ __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) diff --git a/debian/templates/koha-conf-site.xml.in b/debian/templates/koha-conf-site.xml.in index 5147ab0d93..20d217222d 100644 --- a/debian/templates/koha-conf-site.xml.in +++ b/debian/templates/koha-conf-site.xml.in @@ -449,6 +449,7 @@ __END_SRU_PUBLICSERVER__ __MESSAGE_BROKER_VHOST__ + __KEEP_COOKIE__