#!/bin/bash # Copyright (C) 2010-2023 Pädagogisches Landesinstitut Rheinland-Pfalz # Copyright (C) 2022-2023 Mike Gabriel # Copyright (C) 2022-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. # preinst 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}" # summary of how this script can be called: # * `install' # * `install' # * `upgrade' # * `abort-upgrade' # for details, see http://www.debian.org/doc/debian-policy/ or # the debian-policy package case "$1" in install|upgrade) mkdir -p /etc/e2guardian/debian-edu-router-plugin.content-filter/ || true mkdir -p /var/log/debian-edu-router/e2guardian/ || true # Make sure Squid can write into log files. # Squid does not like it, if its log files are not writeable, at all. mkdir -p /var/log/debian-edu-router/squid/ || true chown proxy:proxy /var/log/debian-edu-router/squid # Make sure e2guardian can write into log files. logdir="/var/log/debian-edu-router/e2guardian" mkdir -p "${logdir}" || true chown "e2guardian:e2guardian" "$logdir" || true chmod u=rwx "${logdir}" || true chown "e2guardian:e2guardian" "${logdir}/"* 2>/dev/null || true chmod u=rw "${logdir}/"* 2>/dev/null || true # Make sure symlinks are actually symlinks and not real directories. symlinks=( "/etc/debian-edu-router/e2guardian.d" "/etc/debian-edu-router/squid.d" "/etc/debian-edu-router/squid-snippet.d" ) for link in "${symlinks[@]}"; do if [ ! -L "${link}" ] && [ -e "${link}" ]; then if [[ -d "${link}" && -z "$( ls ${link} -A )" ]]; then rm -r "${link}" notice_log "Directory '$link' was not a symlink! It was empty, removed it." else backup_dir="${link}.no-symlink-$(date +%Y.%m.%d-%H:%M:%S)" mv "${link}" "${backup_dir}" warning_log "Directory '$link' was not a symlink! Moved it to '$backup_dir'." fi fi done ;; abort-upgrade) ;; *) echo "preinst called with unknown argument \`$1'" >&2 exit 1 ;; esac # dh_installdeb will replace this with shell code automatically # generated by other debhelper scripts. exit 0