#!/bin/bash # Copyright (C) 2024 Pädagogisches Landesinstitut Rheinland-Pfalz # Copyright (C) 2024 Daniel Teichmann # Copyright (C) 2023 Mike Gabriel # # 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.content-filter 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}: Content filter"}" db_title "${PRODUCTNAME_PLUGIN}" # Directories for selected categories SELECT_CATEGORIES_DIR="/var/lib/debian-edu-router/d-e-r-p.c-f/blacklists-toulouse.selected_categories/" # 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 function unmask_squid_service() { deb-systemd-helper unmask squid } case "${1}" in 'purge') # Remove documentation files. rm -fv /usr/share/doc/debian-edu-router-plugin.content-filter/*.md # purge uif config snippets rm -fv /etc/uif/uif.conf.d/??_d-e-r-p.c-f_* rm -fv /etc/uif/uif-ipv4-networks.inc.d/??_d-e-r-p.c-f_* rm -fv /etc/uif/uif-ipv6-networks.inc.d/??_d-e-r-p.c-f_* # purge content-filter related config files rm -fv /etc/squid/conf.d/debian-edu-router-plugin.content-filter/??_*d-e-r-p.c-f_*.conf rm -fv /etc/squid/snippets.d/??_*d-e-r-p.c-f.conf rm -fv /etc/squid/conf.d/debian-edu-router-plugin.content-filter/local-users.passwd rm -fv /etc/e2guardian/debian-edu-router-plugin.content-filter/e2guardian.conf # Selected Uni-Toulouse blacklists categories are not needed after purge. rm -fv "${SELECT_CATEGORIES_DIR}"/blacklisted_categories rm -fv "${SELECT_CATEGORIES_DIR}"/whitelisted_categories # purge Squid spool dirs rm -Rfv /var/spool/squid/d-e-r_*_Network # purge Squid MiTM SSL certificates database rm -Rfv /var/lib/debian-edu-router/ssl_db/ # purge cron jobs / systemd timerd services. rm -fv /etc/cron.d/squid_d-e-r_refresh-blacklists rm -fv /usr/lib/systemd/system/squid_d-e-r_refresh-blacklists.* # remove our filterlists # FIXME: Ask for confirmation here via debconf! rm -fv /var/lib/debian-edu-router/filterlists.d/*.local rm -fv /var/lib/debian-edu-router/filterlists.d/*.org rm -fv /var/lib/debian-edu-router/filterlists.d/*.generated rm -fv /etc/debian-edu-router/www/index.html rm -fv /etc/debian-edu-router/www/wpad.dat rm -fv /etc/debian-edu-router/ssl/openssl.d-e-r_sslmitm-ca.cnf rm -fv /etc/debian-edu-router/ssl/certs/d-e-r_sslmitm-ca.crt rm -fv /etc/debian-edu-router/ssl/certs/d-e-r_sslmitm-ca.der rm -fv /etc/debian-edu-router/ssl/private/d-e-r_sslmitm-ca.key rm -fv /usr/share/debian-edu-router/ldap-connector/LDAP-server_end-entity.crt rm -fv /usr/share/debian-edu-router/content-filter/static/content-filter-errorpage.css rm -f /var/lib/debian-edu-router/d-e-r-p.c-f/enabled unmask_squid_service ;; 'remove'|'failed-upgrade'|'abort-install'|'abort-upgrade'|'disappear') # Also remove cron jobs / systemd timerd services with broken state. rm -fv /etc/cron.d/squid_d-e-r_refresh-blacklists rm -fv /usr/lib/systemd/system/squid_d-e-r_refresh-blacklists.* rm -f /var/lib/debian-edu-router/d-e-r-p.c-f/enabled unmask_squid_service ;; '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 'e2guardian_d-e-r.service' 'squid_d-e-r.target' 'squid_d-e-r_acl_watcher.path' 'squid_d-e-r_refresh-blacklists.service' 'squid_d-e-r_refresh-blacklists.timer' 'squid_d-e-r_refresh-generated-ips.service' 'squid_d-e-r_refresh-generated-ips.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'