#!/bin/sh # Post-installation script for greylistd. # see: dh_installdeb(1) # # 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 set -e . /usr/share/debconf/confmodule db_version 2.0 owner=greylistd initscript=/etc/init.d/greylist running_exim4() { test -x /usr/sbin/exim4 -a -d /etc/exim4 } copyfile () { if [ -f "$1" -a '!' -f "$2" ] then echo -n "Copying $1 to ${2%/*}: " cp -f "$1" "$2" && echo " Done." fi } movefile () { if [ -f "$1" -a '!' -f "$2" ] then echo -n "Moving $1 to $2: " mv -f "$1" "$2" && echo " Done." fi } removefile () { if [ -f "$1" ] then echo -n "Removing $1:" rm -f "$1" && echo " Done." fi } set_config_value() { file=$1 option=$2 value=$3 text=$(sed "s/\($option[[:space:]]*=[[:space:]]*\).*/\1$value/" "$file") && echo "$text" > "$file" } add_user () { user=$1 group=$2 for membership in $(id -Gn "$user" 2>/dev/null) do [ "$membership" = "$group" ] && return 1 done adduser "$user" "$group" return 0 } do_configure() { oldversion=$1 username=greylist groupname=greylist datadir=/var/lib/greylistd rundir=/var/run/greylistd docdir=/usr/share/doc/greylistd confdir=/etc/greylistd ### The following keeps "make" silent during adduser/deluser operations ### on YP/NIS systems. export MAKEFLAGS MAKEFLAGS=-s ### If the user does not already exist, create it. id -u "$username" >/dev/null 2>&1 || adduser --system --group --disabled-password \ --home "$datadir" --no-create-home "$username" ### If we are using Exim 4, and the Debian-exim user is not in the ### group, add it and then restart Exim. restart_exim=no if running_exim4 && add_user Debian-exim "$groupname" then db_get "$owner/restartexim" $RET && restart_exim=yes fi db_stop || true invoke-rc.d --query exim4 restart && ret=0 || ret=$? [ "$restart_exim" != 'no' ] && [ "$ret" = "104" ] && invoke-rc.d exim4 restart ### Create working directories for dir in "$datadir" "$rundir" do if [ ! -d "$dir" ] then echo -n "Creating directory $dir:" mkdir "$dir" && echo " Done." fi chown -R "$username:$groupname" "$dir" done removefile /etc/default/greylistd removefile /etc/default/greylist movefile "$datadir/data" "$datadir/states" copyfile "$docdir/examples/whitelist-hosts" "$confdir/whitelist-hosts" } case "$1" in configure|reconfigure) do_configure $2 ;; abort-upgrade|abort-remove|abort-deconfigure) ;; *) echo "greylistd.postinst 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_installdeb/13.10 dpkg-maintscript-helper rm_conffile /etc/init.d/greylist 0.8.8.5\~ -- "$@" # End automatically added section # Automatically added by dh_installinit/13.10 if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then if [ -z "${DPKG_ROOT:-}" ] && [ -x "/etc/init.d/greylistd" ]; then update-rc.d greylistd defaults >/dev/null if [ -n "$2" ]; then _dh_action=restart else _dh_action=start fi invoke-rc.d --skip-systemd-native greylistd $_dh_action || exit 1 fi fi # End automatically added section # Automatically added by dh_installsystemd/13.10 if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then # The following line should be removed in trixie or trixie+1 deb-systemd-helper unmask 'greylistd.service' >/dev/null || true # was-enabled defaults to true, so new installations run enable. if deb-systemd-helper --quiet was-enabled 'greylistd.service'; then # Enables the unit on first installation, creates new # symlinks on upgrades if the unit file has changed. deb-systemd-helper enable 'greylistd.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 'greylistd.service' >/dev/null || true fi fi # End automatically added section # Automatically added by dh_installsystemd/13.10 if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then # The following line should be removed in trixie or trixie+1 deb-systemd-helper unmask 'greylistd.socket' >/dev/null || true # was-enabled defaults to true, so new installations run enable. if deb-systemd-helper --quiet was-enabled 'greylistd.socket'; then # Enables the unit on first installation, creates new # symlinks on upgrades if the unit file has changed. deb-systemd-helper enable 'greylistd.socket' >/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 'greylistd.socket' >/dev/null || true fi fi # End automatically added section # Automatically added by dh_installsystemd/13.10 if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then if [ -d /run/systemd/system ]; then systemctl --system daemon-reload >/dev/null || true if [ -n "$2" ]; then _dh_action=restart else _dh_action=start fi deb-systemd-invoke $_dh_action 'greylistd.service' 'greylistd.socket' >/dev/null || true fi fi # End automatically added section exit 0