#!/bin/bash # # qpsmtpd package debconf configuration script # set -e ENABLED="" INTERFACES="" QUEUE_PLUGIN="" QUEUE_MAILDIR_DESTINATION="" QUEUE_NONE_CONFIRM="" QUEUE_PROXY_DESTINATION="" RCPTHOSTS="" . /usr/share/debconf/confmodule db_version 2.0 db_beginblock db_input medium qpsmtpd/startup_enabled || true db_endblock db_go db_get qpsmtpd/startup_enabled ENABLED="$RET" if [ "$ENABLED" = "true" ] ; then db_get qpsmtpd/listen_interfaces INTERFACES="$RET" if [ "$INTERFACES" = "unset" -o -z "$INTERFACES" ] ; then INTERFACES=$(ifconfig -a | grep 'inet addr' | tr : ' ' | awk '{print $3}' | sort | uniq | tr '\n' ' ' | sed 's/ *$//') fi db_set qpsmtpd/listen_interfaces "$INTERFACES" db_beginblock db_input medium qpsmtpd/listen_interfaces || true db_endblock db_go db_get qpsmtpd/listen_interfaces INTERFACES="$RET" # try to guess the local MTA, to select defaults if ( readlink /usr/sbin/sendmail 2>/dev/null | grep -q exim ) ; then LOCAL_MTA=exim elif [ -e /var/spool/postfix/public/cleanup ] ; then LOCAL_MTA=postfix elif [ -x /usr/sbin/qmail-queue -o -x /var/qmail/bin/qmail-queue ] ; then LOCAL_MTA=qmail fi # loop until we get to an acceptable state (e.g. confirmed queue-none) db_get qpsmtpd/queue_plugin QUEUE_PLUGIN="$RET" # echo "initial queue_plugin=$QUEUE_PLUGIN" # echo "none_confirm=$QUEUE_NONE_CONFIRM" iter=0 while [[ ( "$iter" == "0" ) || ( "x$QUEUE_PLUGIN" == "" ) || ( "x$QUEUE_PLUGIN" == "xnone" && "x$QUEUE_NONE_CONFIRM" != "xtrue" ) ]] ; do iter=1 # echo "loop queue_plugin=$QUEUE_PLUGIN" if [ "x$QUEUE_PLUGIN" = "x" ] ; then QUEUE_PLUGIN="$LOCAL_MTA" [ ! -z "$QUEUE_PLUGIN" ] && db_set qpsmtpd/queue_plugin "$QUEUE_PLUGIN" fi db_beginblock db_input medium qpsmtpd/queue_plugin || true db_endblock db_go db_get qpsmtpd/queue_plugin QUEUE_PLUGIN="$RET" if [ "x$QUEUE_PLUGIN" = "xproxy" ] ; then db_beginblock db_input medium qpsmtpd/queue_smtp_proxy_destination || true db_endblock db_go db_get qpsmtpd/queue_smtp_proxy_destination QUEUE_PROXY_DESTINATION="$RET" if [ "x$QUEUE_PROXY_DESTINATION" = "x" ] ; then QUEUE_PROXY_DESTINATION="localhost" fi elif [ "x$QUEUE_PLUGIN" = "xmaildir" ] ; then db_beginblock db_input medium qpsmtpd/queue_maildir_destination || true db_endblock db_go db_get qpsmtpd/queue_maildir_destination QUEUE_MAILDIR_DESTINATION="$RET" if [ "x$QUEUE_MAILDIR_DESTINATION" = "x" ] ; then db_set qpsmtpd/queue_maildir_destination \ "/var/spool/qpsmtpd/Maildir" fi elif [ "x$QUEUE_PLUGIN" = "xnone" -o "x$QUEUE_PLUGIN" = "x" ] ; then db_beginblock db_input high qpsmtpd/queue_none_confirm || true db_endblock db_go db_get qpsmtpd/queue_none_confirm QUEUE_NONE_CONFIRM="$RET" fi db_get qpsmtpd/rcpthosts RCPTHOSTS="$RET" # if rcpthosts has never been set, try to guess a default if [ "x$RCPTHOSTS" = "xunset" ] ; then RCPTHOSTS="" if [ "x$QUEUE_PLUGIN" = "xexim" ] ; then db_get exim4/dc_relay_domains EXIM_RELAYDOMAINS=`echo "$RET" | \ tr ',' ' '` db_get exim4/dc_other_hostnames EXIM_OTHERHOSTNAMES=`echo "$RET" | \ tr ',' ' '` db_get exim4/dc_relay_domains RCPTHOSTS=`echo "$EXIM_RELAYDOMAINS $EXIM_OTHERHOSTNAMES" | sed 's/ $//'` elif [ "x$QUEUE_PLUGIN" = "xpostfix" ] ; then RCPTHOSTS=`postconf -h mydestination 2>/dev/null | perl -pe 's/[,\s]+/ /g' | uniq` elif [ "x$QUEUE_PLUGIN" = "xqmail" ] ; then for qetc in /etc/qmail /var/qmail/control ; do if [ -e "$qetc/rcpthosts" ] ; then RCPTHOSTS=`cat $qetc/rcpthosts | grep '^[a-zA-Z0-9-.]' | tr '\n' ' '` fi done fi db_set qpsmtpd/rcpthosts "$RCPTHOSTS" fi db_beginblock db_input medium qpsmtpd/rcpthosts || true db_endblock db_go db_get qpsmtpd/rcpthosts RCPTHOSTS="$RET" db_beginblock db_input medium qpsmtpd/server_type || true db_endblock db_go db_get qpsmtpd/server_type SERVER="$RET" done fi db_stop exit 0