# 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
}
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
koha-stop-zebra $name || /bin/true
instancefile=$(get_apache_config_for $name)
+ le_opacdomain=$(letsencrypt_get_opacdomain_for $name)
[ -f "$instancefile" ] && \
rm "$instancefile"
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"