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 <jonathan.druart@bugs.koha-community.org> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
This commit is contained in:
parent
34d1eea049
commit
28109bbc5e
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
Loading…
Reference in New Issue