From 66472db87ae7468123242f99fab75c85745711de Mon Sep 17 00:00:00 2001 From: Mirko Tietgen Date: Fri, 15 Apr 2016 13:35:16 +0200 Subject: [PATCH] Bug 15303 Followup for koha-remove This patch makes koha-remove take care of /etc/letsencrypt/renewal/$opacdomain.conf /var/lib/koha/$site/letsencrypt.enabled It also adds a few helper functions. To test - create a koha instance with LE - observe you got both files mentioned above - remove that instance - verify the files are gone Signed-off-by: Jonathan Druart --- debian/scripts/koha-create | 2 +- debian/scripts/koha-functions.sh | 40 ++++++++++++++++++++++++++++++++++++++++ debian/scripts/koha-remove | 5 +++++ 3 files changed, 46 insertions(+), 1 deletion(-) diff --git a/debian/scripts/koha-create b/debian/scripts/koha-create index 4484910..263ee14 100755 --- a/debian/scripts/koha-create +++ b/debian/scripts/koha-create @@ -361,7 +361,7 @@ letsencrypt_instance() # enable redirect from http to https on port 80 sed -i "s:^\s*#\(.*\)#nohttps$:\1:" "/etc/apache2/sites-available/$name.conf" # make koha-list --letsencrypt aware of this instance # could be done by checking apache conf instead - touch /var/lib/koha/$name/letsencrypt.enabled + echo -e "opacdomain=\"$opacdomain\"\nintradomain=\"$intradomain\"" > /var/lib/koha/$name/letsencrypt.enabled # restart apache with working certs service apache2 restart } diff --git a/debian/scripts/koha-functions.sh b/debian/scripts/koha-functions.sh index ef71a3a..1c309fc 100755 --- a/debian/scripts/koha-functions.sh +++ b/debian/scripts/koha-functions.sh @@ -43,6 +43,46 @@ get_apache_config_for() fi } +get_opacdomain_for() +{ + local site=$1 + + if [ -e /etc/koha/koha-sites.conf ]; then + . /etc/koha/koha-sites.conf + else + echo "Error: /etc/koha/koha-sites.conf not present." 1>&2 + exit 1 + fi + local opacdomain="$OPACPREFIX$site$OPACSUFFIX$DOMAIN" + echo "$opacdomain" +} + +get_intradomain_for() +{ + local site=$1 + + if [ -e /etc/koha/koha-sites.conf ]; then + . /etc/koha/koha-sites.conf + else + echo "Error: /etc/koha/koha-sites.conf not present." 1>&2 + exit 1 + fi + local intradomain="$INTRAPREFIX$site$INTRASUFFIX$DOMAIN" + echo "$intradomain" +} + +letsencrypt_get_opacdomain_for() +{ + local site=$1 + + if [ -e /var/lib/koha/$site/letsencrypt.enabled ]; then + . /var/lib/koha/$site/letsencrypt.enabled + else + local opacdomain=$(get_opacdomain_for $site) + fi + echo "$opacdomain" +} + is_enabled() { local site=$1 diff --git a/debian/scripts/koha-remove b/debian/scripts/koha-remove index 88392ba..4342c5d 100755 --- a/debian/scripts/koha-remove +++ b/debian/scripts/koha-remove @@ -80,6 +80,7 @@ eof koha-stop-zebra $name || /bin/true instancefile=$(get_apache_config_for $name) + le_opacdomain=$(letsencrypt_get_opacdomain_for $name) [ -f "$instancefile" ] && \ rm "$instancefile" @@ -97,6 +98,10 @@ eof rm "/etc/koha/sites/$name/zebra-authorities-dom.cfg" [ -f "/etc/koha/sites/$name/zebra.passwd" ] && \ rm "/etc/koha/sites/$name/zebra.passwd" + [ -f "/var/lib/koha/$name/letsencrypt.enabled" ] && \ + rm -r "/var/lib/koha/$name/letsencrypt.enabled" + [ -f "/etc/letsencrypt/renewal/$le_opacdomain.conf" ] && \ + rm -r "/etc/letsencrypt/renewal/$le_opacdomain.conf" # Maybe a user has left something in the config directory they want to keep? We won't delete it here, nor throw an error if the have. [ -d "/etc/koha/sites/$name" ] && \ rmdir --ignore-fail-on-non-empty "/etc/koha/sites/$name" -- 2.7.0