#! /bin/sh # postinst script for amavisd-new # $Id: amavisd-new.postinst 908 2006-06-09 03:42:01Z hmh $ # # see: dh_installdeb(1) set -e # summary of how this script can be called: # * `configure' # * `abort-upgrade' # * `abort-remove' `in-favour' # # * `abort-deconfigure' `in-favour' # `removing' # # for details, see http://www.debian.org/doc/debian-policy/ or # the debian-policy package # # quoting from the policy: # Any necessary prompting should almost always be confined to the # post-installation script, and should be protected with a conditional # so that unnecessary prompting doesn't happen if a package's # installation fails and the `postinst' is called with `abort-upgrade', # `abort-remove' or `abort-deconfigure'. case "$1" in configure) # add amavis system user and group (requires adduser >= 3.34) # don't muck around with this unless you KNOW what you're doing # also, don't attempt to second guess what kind of fucked up # mistakes other amavis packages might have made. Tell the user # to kill the bogus entry. We can't simply overwrite it with # usermod, since that would certainly cause severe headaches for # a sysadmin out there... # # I don't care that users migrating from other amavis packages # will have extra work. Someone lost 30GB because we tried to # be nice once. See #190414. echo "Creating/updating amavis user account..." >&2 if ! getent group amavis > /dev/null ; then addgroup --quiet --system amavis || { # addgroup failed. Why? if ! getent group amavis >/dev/null ; then echo "Could not create system group amavis." >&2 exit 1 fi # well, the group is there, so just ignore the error } fi if ! getent passwd amavis > /dev/null ; then adduser --system --ingroup amavis --home /var/lib/amavis \ --gecos "AMaViS system user" --shell /bin/sh \ --quiet --disabled-password amavis || { # adduser failed. Why? if getent passwd amavis >/dev/null ; then echo "Non-system user amavis found. I will not overwrite a non-system" >&2 echo "user. Remove the user and reinstall amavisd-new." >&2 exit 1 fi # unknown adduser error, simply exit exit 1 } fi # Clean up after #190414 homedir=$(getent passwd amavis | cut -d : -f 6) if [ "x${homedir}" = "x/" ] ; then echo 'WARNING! Homedir of user amavis was set to "/", this is' >&2 echo 'extremely dangerous! Overriding it to /var/lib/amavis...' >&2 homedir=/var/lib/amavis usermod -d "${homedir}" amavis fi # Sanity-checks (see #367807) if [ ! -d "${homedir}" ] ; then echo "Broken amavis system user found. To insure data-safety," >&2 echo "it is up to you the local administrator to remove the broken" >&2 echo "amavis user, or repair it so that it is sane" >&2 exit 1 fi # in order to give all critical dirs sane permissions we first check # if we have the packages standard permissions, if yes we delete them, # if no we alert the admin. for i in /var/lib/amavis:755:0750:amavis:amavis /var/lib/amavis/db:755:0750:amavis:amavis \ /var/lib/amavis/tmp:755:0770:amavis:amavis /var/lib/amavis/virusmails:755:0750:amavis:amavis do dir=$(echo $i | cut -d : -f 1) perms_local=$(dpkg-statoverride --list "$dir" | awk '{print $4,$3,$1,$2}' | tr -s " " ":") if [ "$perms_local" ] ; then perms_old=$(echo $i | cut -d : -f 1,2,4,5) perms_new=$(echo $i | cut -d : -f 1,3,4,5) mode_others=$(dpkg-statoverride --list "$dir" | awk '{print $3}' | sed 's/.*\([0-9]\{1\}\)$/\1/') if [ "$perms_local" = "$perms_old" ] ; then dpkg-statoverride --remove "$dir" elif [ "$perms_local" != "$perms_new" ] && [ "$mode_others" != "0" ] ; then echo echo "WARNING: $dir has set custom permissions which may be too open - please take a look at README.Debian!" echo fi fi done umask 022 for i in /var/lib/amavis:0750 /var/lib/amavis/db:0750 /var/lib/amavis/tmp:0770 \ /var/lib/amavis/virusmails:0750 /var/run/amavis:0755 do dir=$(echo $i | cut -d : -f 1) perm=$(echo $i | cut -d : -f 2) if [ ! -d "$dir" ] ; then mkdir -p "$dir" fi if ! dpkg-statoverride --list "$dir" > /dev/null ; then dpkg-statoverride --update --add amavis amavis "$perm" "$dir" fi done # # Conffile upgrade handling # # Work around dpkg not deleting removed conffiles # (template directories (with files) removed in 1:2.3.3-2) if dpkg --compare-versions "1:2.3.3-2" gt-nl "$2" ; then for i in pt_BR fr it_IT de_DE ; do if [ -e "/etc/amavis/$i" ] ; then echo "Moving outdated l10n template to /etc/amavis/${i}.outdated_for_2.3.3-2" >&2 mv "/etc/amavis/$i" "/etc/amavis/${i}.outdated_for_2.3.3-2" fi done fi ;; abort-upgrade|abort-remove|abort-deconfigure) ;; *) echo "postinst called with unknown argument \`$1'" >&2 exit 1 ;; esac # dh_installdeb will replace this with shell code automatically # generated by other debhelper scripts. init_failed () { echo "WARNING: Starting amavisd-new failed. Please check your configuration." } # Automatically added by dh_installsystemd/13.6 if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then # This will only remove masks created by d-s-h on package removal. deb-systemd-helper unmask 'amavis.service' >/dev/null || true # was-enabled defaults to true, so new installations run enable. if deb-systemd-helper --quiet was-enabled 'amavis.service'; then # Enables the unit on first installation, creates new # symlinks on upgrades if the unit file has changed. deb-systemd-helper enable 'amavis.service' >/dev/null || true else # Update the statefile to add new symlinks (if any), which need to be # cleaned up on purge. Also remove old symlinks. deb-systemd-helper update-state 'amavis.service' >/dev/null || true fi fi # End automatically added section # Automatically added by dh_installsystemd/13.6 if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then if [ -z "${DPKG_ROOT:-}" ] && [ -d /run/systemd/system ]; then systemctl --system daemon-reload >/dev/null || true deb-systemd-invoke restart 'amavis.service' >/dev/null || true fi fi # End automatically added section # Automatically added by dh_installsystemd/13.6 if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then if deb-systemd-helper debian-installed 'amavis-mc.service'; then # This will only remove masks created by d-s-h on package removal. deb-systemd-helper unmask 'amavis-mc.service' >/dev/null || true if deb-systemd-helper --quiet was-enabled 'amavis-mc.service'; then # Create new symlinks, if any. deb-systemd-helper enable 'amavis-mc.service' >/dev/null || true fi fi # Update the statefile to add new symlinks (if any), which need to be cleaned # up on purge. Also remove old symlinks. deb-systemd-helper update-state 'amavis-mc.service' >/dev/null || true fi # End automatically added section # Automatically added by dh_installsystemd/13.6 if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then if [ -z "${DPKG_ROOT:-}" ] && [ -d /run/systemd/system ]; then systemctl --system daemon-reload >/dev/null || true deb-systemd-invoke restart 'amavis-mc.service' >/dev/null || true fi fi # End automatically added section # Automatically added by dh_installsystemd/13.6 if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then if deb-systemd-helper debian-installed 'amavisd-snmp-subagent.service'; then # This will only remove masks created by d-s-h on package removal. deb-systemd-helper unmask 'amavisd-snmp-subagent.service' >/dev/null || true if deb-systemd-helper --quiet was-enabled 'amavisd-snmp-subagent.service'; then # Create new symlinks, if any. deb-systemd-helper enable 'amavisd-snmp-subagent.service' >/dev/null || true fi fi # Update the statefile to add new symlinks (if any), which need to be cleaned # up on purge. Also remove old symlinks. deb-systemd-helper update-state 'amavisd-snmp-subagent.service' >/dev/null || true fi # End automatically added section # Automatically added by dh_installsystemd/13.6 if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then if [ -z "${DPKG_ROOT:-}" ] && [ -d /run/systemd/system ]; then systemctl --system daemon-reload >/dev/null || true deb-systemd-invoke restart 'amavisd-snmp-subagent.service' >/dev/null || true fi fi # End automatically added section # Automatically added by dh_installinit/13.6 if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then if [ -z "${DPKG_ROOT:-}" ] && [ -x "/etc/init.d/amavis" ]; then update-rc.d amavis defaults >/dev/null invoke-rc.d --skip-systemd-native amavis restart || exit 1 fi fi # End automatically added section # Automatically added by dh_installinit/13.6 if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then if [ -z "${DPKG_ROOT:-}" ] && [ -x "/etc/init.d/amavisd-snmp-subagent" ]; then update-rc.d amavisd-snmp-subagent defaults-disabled >/dev/null invoke-rc.d --skip-systemd-native amavisd-snmp-subagent restart || exit 1 fi fi # End automatically added section # Automatically added by dh_installinit/13.6 if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then if [ -z "${DPKG_ROOT:-}" ] && [ -x "/etc/init.d/amavis-mc" ]; then update-rc.d amavis-mc defaults-disabled >/dev/null invoke-rc.d --skip-systemd-native amavis-mc restart || exit 1 fi fi # End automatically added section # Automatically added by dh_installsystemd/13.6 if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then # This will only remove masks created by d-s-h on package removal. deb-systemd-helper unmask 'amavis-mc.service' >/dev/null || true # was-enabled defaults to true, so new installations run enable. if deb-systemd-helper --quiet was-enabled 'amavis-mc.service'; then # Enables the unit on first installation, creates new # symlinks on upgrades if the unit file has changed. deb-systemd-helper enable 'amavis-mc.service' >/dev/null || true else # Update the statefile to add new symlinks (if any), which need to be # cleaned up on purge. Also remove old symlinks. deb-systemd-helper update-state 'amavis-mc.service' >/dev/null || true fi fi # End automatically added section # Automatically added by dh_installsystemd/13.6 if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then # This will only remove masks created by d-s-h on package removal. deb-systemd-helper unmask 'amavis.service' >/dev/null || true # was-enabled defaults to true, so new installations run enable. if deb-systemd-helper --quiet was-enabled 'amavis.service'; then # Enables the unit on first installation, creates new # symlinks on upgrades if the unit file has changed. deb-systemd-helper enable 'amavis.service' >/dev/null || true else # Update the statefile to add new symlinks (if any), which need to be # cleaned up on purge. Also remove old symlinks. deb-systemd-helper update-state 'amavis.service' >/dev/null || true fi fi # End automatically added section # Automatically added by dh_installsystemd/13.6 if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then # This will only remove masks created by d-s-h on package removal. deb-systemd-helper unmask 'amavisd-snmp-subagent.service' >/dev/null || true # was-enabled defaults to true, so new installations run enable. if deb-systemd-helper --quiet was-enabled 'amavisd-snmp-subagent.service'; then # Enables the unit on first installation, creates new # symlinks on upgrades if the unit file has changed. deb-systemd-helper enable 'amavisd-snmp-subagent.service' >/dev/null || true else # Update the statefile to add new symlinks (if any), which need to be # cleaned up on purge. Also remove old symlinks. deb-systemd-helper update-state 'amavisd-snmp-subagent.service' >/dev/null || true fi fi # End automatically added section # Automatically added by dh_installsystemd/13.6 if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then if [ -z "${DPKG_ROOT:-}" ] && [ -d /run/systemd/system ]; then systemctl --system daemon-reload >/dev/null || true deb-systemd-invoke restart 'amavis-mc.service' 'amavis.service' 'amavisd-snmp-subagent.service' >/dev/null || true fi fi # End automatically added section exit 0