#!/bin/bash # Copyright (C) 2023 Pädagogisches Landesinstitut Rheinland-Pfalz # Copyright (C) 2023 Mike Gabriel # Copyright (C) 2023 Daniel Teichmann # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the # Free Software Foundation, Inc., # 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. # postrm script for debian-edu-router-plugin.ldap-connector set -e . /usr/share/debconf/confmodule || exit 255 # prepare debconf export DC_PRIO_LOW="medium" export DC_PRIO_HIGH="high" if [ -e /etc/debian-edu/router.conf ]; then source /etc/debian-edu/router.conf fi PRODUCTNAME="${PRODUCTNAME:-"Debian Edu Router"}" PRODUCTNAME_PLUGIN_SUFFIX="${PRODUCTNAME_PLUGIN_SUFFIX:-"Plugin"}" PRODUCTNAME_PLUGIN="${PRODUCTNAME_PLUGIN:-"${PRODUCTNAME} ${PRODUCTNAME_PLUGIN_SUFFIX}: LDAP/AD Connector"}" db_title "${PRODUCTNAME_PLUGIN}" # summary of how this script can be called: # * `remove' # * `purge' # * `upgrade' # * `failed-upgrade' # * `abort-install' # * `abort-install' # * `abort-upgrade' # * `disappear' # # for details, see https://www.debian.org/doc/debian-policy/ or # the debian-policy package CA_CERT_FILE="/var/lib/debian-edu-router/certs/D-E-R-P.L-C_LDAP_CA.crt" LDAP_CONFIG_FILE="/etc/debian-edu-router/ldap.d/ldap_d-e-r-p.l-c.conf" LDAP_SECRET_FILE="/etc/debian-edu-router/ldap.d/ldap_d-e-r-p.l-c.secret" LDAP_GROUP_MATCHING_CFG_FILE="/etc/debian-edu-router/ldap.d/ldap-groups-to-squid-acl-matching.sh" case "${1}" in 'purge') rm -fv /var/lib/debian-edu-router/d-e-r-p.l-c/enabled # remove our filterlists # FIXME: Ask for confirmation here via debconf! rm -fv /var/lib/debian-edu-router/filterlists.d/*.ldap # purge cron jobs / systemd timerd services. rm -fv /etc/cron.d/squid_d-e-r_refresh-ldap-filterlists rm -fv /usr/lib/systemd/system/squid_d-e-r_refresh-ldap-filterlists.* rm -fv "${CA_CERT_FILE}" rm -fv "${LDAP_CONFIG_FILE}" rm -fv "${LDAP_SECRET_FILE}" rm -fv "${LDAP_GROUP_MATCHING_CFG_FILE}" rm -fv /etc/squid/conf.d/debian-edu-router-plugin.content-filter/??_*d-e-r-p.l-c_*.conf rm -fv /etc/squid/snippets.d/??_*d-e-r-p.l-c.conf ;; 'remove'|'failed-upgrade'|'abort-install'|'abort-upgrade'|'disappear') rm -fv /var/lib/debian-edu-router/d-e-r-p.l-c/enabled # Also remove cron jobs / systemd timerd services with broken state. rm -fv /etc/cron.d/squid_d-e-r_refresh-ldap-filterlists rm -fv /usr/lib/systemd/system/squid_d-e-r_refresh-ldap-filterlists.* rm -fv /etc/squid/conf.d/debian-edu-router-plugin.content-filter/??_*d-e-r-p.l-c_*.conf rm -fv /etc/squid/snippets.d/??_*d-e-r-p.l-c.conf FILTERLIST_BACKUP_DIR="/var/lib/debian-edu-router/filterlists.d/d-e-r-p.l-c.$(date "+%Y-%m-%d_%H:%M").removalbackup" mkdir -p "${FILTERLIST_BACKUP_DIR}" mv -v /var/lib/debian-edu-router/filterlists.d/*.ldap.backup "${FILTERLIST_BACKUP_DIR}" || true mv -v /var/lib/debian-edu-router/filterlists.d/*.ldap "${FILTERLIST_BACKUP_DIR}" || true ;; 'upgrade') echo > /dev/null ;; *) echo "postrm called with unknown argument '${1}'" >&2 exit '1' ;; esac # dh_installdeb will replace this with shell code automatically # generated by other debhelper scripts. # Automatically added by dh_installsystemd/13.24.2 if [ "$1" = remove ] && [ -d /run/systemd/system ] ; then systemctl --system daemon-reload >/dev/null || true fi # End automatically added section # Automatically added by dh_installsystemd/13.24.2 if [ "$1" = "purge" ]; then if [ -x "/usr/bin/deb-systemd-helper" ]; then deb-systemd-helper purge 'squid_d-e-r_refresh-ldap-filterlists.service' 'squid_d-e-r_refresh-ldap-filterlists.timer' >/dev/null || true fi fi # End automatically added section # Automatically added by dh_installdebconf/13.24.2 if [ "$1" = purge ] && [ -e /usr/share/debconf/confmodule ]; then . /usr/share/debconf/confmodule db_purge fi # End automatically added section exit '0'