#!/bin/sh set -e RUNAS=qpsmtpd SPOOLDIR=/var/spool/qpsmtpd GREYLISTDIR=/var/lib/qpsmtpd/greylisting LOGDIR=/var/log/qpsmtpd PIDDIR=/var/run/qpsmtpd if [ -e /etc/qpsmtpd/debconf-settings ] ; then . /etc/qpsmtpd/debconf-settings fi if [ -e /usr/share/debconf/confmodule ] ; then . /usr/share/debconf/confmodule fi setup_debconf() { # extract the configuration from debconf and write it where qpsmtpd # can find it, now that the destination exists db_get qpsmtpd/startup_enabled ENABLED="$RET" db_get qpsmtpd/server_type SERVER="$RET" db_get qpsmtpd/listen_interfaces INTERFACES="$RET" db_get qpsmtpd/queue_plugin QUEUE_PLUGIN="$RET" db_get qpsmtpd/queue_maildir_destination QUEUE_MAILDIR_DESTINATION="$RET" db_get qpsmtpd/queue_smtp_proxy_destination QUEUE_PROXY_DESTINATION="$RET" db_get qpsmtpd/rcpthosts RCPTHOSTS="$RET" TMP=`mktemp /etc/qpsmtpd/.tmp.debconf-settings.$$.XXXXXX` ( echo "# auto-generated by $0 at `date`" ; cat <<"EOT" # # This is a copy of the qpsmtpd debconf settings for use at startup time. # Please don't edit it directly -- if you need to change any of these # settings, run 'dpkg-reconfigure qpsmtpd'. EOT echo "ENABLED=\"$ENABLED\"" echo "SERVER=\"$SERVER\"" echo "INTERFACES=\"$INTERFACES\"" echo "QUEUE_PLUGIN=\"$QUEUE_PLUGIN\"" echo "QUEUE_MAILDIR_DESTINATION=\"$QUEUE_MAILDIR_DESTINATION\"" echo "QUEUE_PROXY_DESTINATION=\"$QUEUE_PROXY_DESTINATION\"" ) > "$TMP" mv -f "$TMP" "/etc/qpsmtpd/debconf-settings" || ( rm -f "$TMP" && false ) chmod 0644 "/etc/qpsmtpd/debconf-settings" TMP=`mktemp /etc/qpsmtpd/.tmp.debconf-queue-select.$$.XXXXXX` ( echo "# auto-generated by $0 at `date`" ; cat <<"EOT" # # This is the qpsmtpd queue plugin selection generated by debconf at # package installation. It reflects the choice of queue method selected # by the debconf UI. Please do not edit it directly -- it will be overwritten # on subsequent package upgrades. To change the queueing/delivery # method, either run 'dpkg-reconfigure qpsmtpd' and pick a different method, # or edit /etc/qpsmtpd/plugins to remove the $include reference to this file, # then pick whatever queue plugin you prefer. EOT if [ "$QUEUE_PLUGIN" = "exim" ] ; then echo "queue/exim-bsmtp" elif [ "$QUEUE_PLUGIN" = "postfix" ] ; then echo "queue/postfix-queue" elif [ "$QUEUE_PLUGIN" = "proxy" ] ; then echo -n "queue/smtp-forward " echo "$QUEUE_PROXY_DESTINATION" | tr ":" " " elif [ "$QUEUE_PLUGIN" = "qmail" ] ; then echo "queue/qmail-queue /usr/sbin/qmail-queue" elif [ "$QUEUE_PLUGIN" = "maildir" ] ; then echo "queue/maildir $QUEUE_MAILDIR_DESTINATION" fi echo ) > "$TMP" mv -f "$TMP" "/etc/qpsmtpd/debian-queue-method" chmod 0644 "/etc/qpsmtpd/debian-queue-method" TMP=`mktemp /etc/qpsmtpd/.tmp.debconf-rcpthosts.$$.XXXXXX` ( echo "# auto-generated by $0 at `date`" ; cat <<"EOT" # # This is the Debian-specific qpsmtpd rcpthosts setting, containing the list of # host and domain names for which qpsmtpd will accept mail. It should include # all locally-delivered domain names as well as those for which you wish to # relay mail. This file was generated by debconf when qpsmtpd was installed or # (re)configured. To alter it, please run 'dpkg-reconfigure qpsmtpd'. If you # prefer to edit the rcpthosts list manually, edit /etc/qpstmpd/rcpthosts and # remove the $include reference to this file. EOT echo "$RCPTHOSTS" | perl -pe 's/[\s,]+/\n/g' ) > "$TMP" mv -f "$TMP" "/etc/qpsmtpd/debian-rcpthosts" chmod 0644 "/etc/qpsmtpd/debian-rcpthosts" } setup_user() { if ( ! getent passwd "$RUNAS" > /dev/null ) ; then adduser --quiet \ --system --home "$SPOOLDIR" \ --gecos "qpsmtpd daemon user" \ --group "$RUNAS" fi if [ "x$QUEUE_PLUGIN" = "xpostfix" ] ; then if ( ! getent group "postdrop" | \ tr ":" "\n" | \ grep -q "^$RUNAS\$" ) ; then adduser --quiet "$RUNAS" "postdrop" fi fi } setup_perms() { if ( ! dpkg-statoverride --list "$SPOOLDIR" > /dev/null ) ; then dpkg-statoverride --update --add "$RUNAS" "$RUNAS" 2700 "$SPOOLDIR" fi if ( ! dpkg-statoverride --list "$GREYLISTDIR" > /dev/null ) ; then dpkg-statoverride --update --add "$RUNAS" "$RUNAS" 2700 "$GREYLISTDIR" fi if ( ! dpkg-statoverride --list "$LOGDIR" > /dev/null ) ; then dpkg-statoverride --update --add "$RUNAS" adm 2750 "$LOGDIR" fi if ( ! dpkg-statoverride --list "$PIDDIR" > /dev/null ) ; then dpkg-statoverride --update --add "$RUNAS" adm 2755 "$PIDDIR" fi } setup_maildir_spool() { if [ "x$QUEUE_PLUGIN" = "xmaildir" -a \ "x$QUEUE_MAILDIR_DESTINATION" != "x" ] ; then if [ ! -d "$QUEUE_MAILDIR_DESTINATION" ] ; then [ -d "`dirname "$QUEUE_MAILDIR_DESTINATION"`" ] || \ mkdir -m 0755 -p "`dirname "$QUEUE_MAILDIR_DESTINATION"`" [ -d "$QUEUE_MAILDIR_DESTINATION" ] || \ mkdir -m 0700 -p "$QUEUE_MAILDIR_DESTINATION" for d in "$QUEUE_MAILDIR_DESTINATION/new" \ "$QUEUE_MAILDIR_DESTINATION/cur" \ "$QUEUE_MAILDIR_DESTINATION/tmp" ; do if [ ! -d "$d" ] ; then mkdir -m 0700 "$d" fi done chown -R $RUNAS "$QUEUE_MAILDIR_DESTINATION" fi fi } upgrade_config() { from_version="$1" ; shift if dpkg --compare-versions "$from_version" lt 0.32 ; then if [ -f /var/log/qpsmtpd/qpsmtpd.log ] ; then chown qpsmtpd /var/log/qpsmtpd/qpsmtpd.log fi fi if dpkg --compare-versions "$from_version" le 0.94-1 ; then # "check_" prefix was removed in upstream change # b1c2fa16b5fda84f361abf15764501fd11e84022 db_input high qpsmtpd/pre094_checkplugin_warning || true db_go fi } case "$1" in configure) previous="$2" setup_debconf setup_user setup_perms setup_maildir_spool upgrade_config "$previous" ;; abort-upgrade|abort-remove|abort-deconfigure) # no-op ;; *) echo "Unrecognized postinst argument '$1'" ;; esac # Automatically added by dh_installinit/13.11.4 if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then if [ -z "${DPKG_ROOT:-}" ] && [ -x "/etc/init.d/qpsmtpd" ]; then update-rc.d qpsmtpd defaults >/dev/null if [ -n "$2" ]; then _dh_action=restart else _dh_action=start fi invoke-rc.d qpsmtpd $_dh_action || exit 1 fi fi # End automatically added section db_stop exit 0