Debian Codegraph @

debian/qpsmtpd.config

raw
1 #!/bin/bash
2 #
3 # qpsmtpd package debconf configuration script
4 #
5
6 set -e
7
8 ENABLED=""
9 INTERFACES=""
10 QUEUE_PLUGIN=""
11 QUEUE_MAILDIR_DESTINATION=""
12 QUEUE_NONE_CONFIRM=""
13 QUEUE_PROXY_DESTINATION=""
14 RCPTHOSTS=""
15
16 . /usr/share/debconf/confmodule
17 db_version 2.0
18
19 db_beginblock
20 db_input medium qpsmtpd/startup_enabled || true
21 db_endblock
22 db_go
23
24 db_get qpsmtpd/startup_enabled
25 ENABLED="$RET"
26
27 if [ "$ENABLED" = "true" ] ; then
28 db_get qpsmtpd/listen_interfaces
29 INTERFACES="$RET"
30
31 if [ "$INTERFACES" = "unset" -o -z "$INTERFACES" ] ; then
32 INTERFACES=$(ifconfig -a |
33 grep 'inet addr' |
34 tr : ' ' |
35 awk '{print $3}' |
36 sort | uniq |
37 tr '\n' ' ' |
38 sed 's/ *$//')
39 fi
40 db_set qpsmtpd/listen_interfaces "$INTERFACES"
41
42 db_beginblock
43 db_input medium qpsmtpd/listen_interfaces || true
44 db_endblock
45 db_go
46 db_get qpsmtpd/listen_interfaces
47 INTERFACES="$RET"
48
49 # try to guess the local MTA, to select defaults
50 if ( readlink /usr/sbin/sendmail 2>/dev/null | grep -q exim ) ; then
51 LOCAL_MTA=exim
52 elif [ -e /var/spool/postfix/public/cleanup ] ; then
53 LOCAL_MTA=postfix
54 elif [ -x /usr/sbin/qmail-queue -o -x /var/qmail/bin/qmail-queue ] ; then
55 LOCAL_MTA=qmail
56 fi
57
58 # loop until we get to an acceptable state (e.g. confirmed queue-none)
59 db_get qpsmtpd/queue_plugin
60 QUEUE_PLUGIN="$RET"
61 # echo "initial queue_plugin=$QUEUE_PLUGIN"
62 # echo "none_confirm=$QUEUE_NONE_CONFIRM"
63
64 iter=0
65 while [[ ( "$iter" == "0" ) ||
66 ( "x$QUEUE_PLUGIN" == "" ) ||
67 ( "x$QUEUE_PLUGIN" == "xnone" &&
68 "x$QUEUE_NONE_CONFIRM" != "xtrue" ) ]] ; do
69 iter=1
70 # echo "loop queue_plugin=$QUEUE_PLUGIN"
71 if [ "x$QUEUE_PLUGIN" = "x" ] ; then
72 QUEUE_PLUGIN="$LOCAL_MTA"
73 [ ! -z "$QUEUE_PLUGIN" ] && db_set qpsmtpd/queue_plugin "$QUEUE_PLUGIN"
74 fi
75 db_beginblock
76 db_input medium qpsmtpd/queue_plugin || true
77 db_endblock
78 db_go
79
80 db_get qpsmtpd/queue_plugin
81 QUEUE_PLUGIN="$RET"
82 if [ "x$QUEUE_PLUGIN" = "xproxy" ] ; then
83 db_beginblock
84 db_input medium qpsmtpd/queue_smtp_proxy_destination || true
85 db_endblock
86 db_go
87
88 db_get qpsmtpd/queue_smtp_proxy_destination
89 QUEUE_PROXY_DESTINATION="$RET"
90 if [ "x$QUEUE_PROXY_DESTINATION" = "x" ] ; then
91 QUEUE_PROXY_DESTINATION="localhost"
92 fi
93 elif [ "x$QUEUE_PLUGIN" = "xmaildir" ] ; then
94 db_beginblock
95 db_input medium qpsmtpd/queue_maildir_destination || true
96 db_endblock
97 db_go
98
99 db_get qpsmtpd/queue_maildir_destination
100 QUEUE_MAILDIR_DESTINATION="$RET"
101 if [ "x$QUEUE_MAILDIR_DESTINATION" = "x" ] ; then
102 db_set qpsmtpd/queue_maildir_destination \
103 "/var/spool/qpsmtpd/Maildir"
104 fi
105 elif [ "x$QUEUE_PLUGIN" = "xnone" -o "x$QUEUE_PLUGIN" = "x" ] ; then
106 db_beginblock
107 db_input high qpsmtpd/queue_none_confirm || true
108 db_endblock
109 db_go
110
111 db_get qpsmtpd/queue_none_confirm
112 QUEUE_NONE_CONFIRM="$RET"
113 fi
114
115 db_get qpsmtpd/rcpthosts
116 RCPTHOSTS="$RET"
117 # if rcpthosts has never been set, try to guess a default
118 if [ "x$RCPTHOSTS" = "xunset" ] ; then
119 RCPTHOSTS=""
120 if [ "x$QUEUE_PLUGIN" = "xexim" ] ; then
121 db_get exim4/dc_relay_domains
122 EXIM_RELAYDOMAINS=`echo "$RET" | \
123 tr ',' ' '`
124 db_get exim4/dc_other_hostnames
125
126 EXIM_OTHERHOSTNAMES=`echo "$RET" | \
127 tr ',' ' '`
128 db_get exim4/dc_relay_domains
129 RCPTHOSTS=`echo "$EXIM_RELAYDOMAINS $EXIM_OTHERHOSTNAMES" | sed 's/ $//'`
130 elif [ "x$QUEUE_PLUGIN" = "xpostfix" ] ; then
131 RCPTHOSTS=`postconf -h mydestination 2>/dev/null |
132 perl -pe 's/[,\s]+/ /g' | uniq`
133 elif [ "x$QUEUE_PLUGIN" = "xqmail" ] ; then
134 for qetc in /etc/qmail /var/qmail/control ; do
135 if [ -e "$qetc/rcpthosts" ] ; then
136 RCPTHOSTS=`cat $qetc/rcpthosts |
137 grep '^[a-zA-Z0-9-.]' |
138 tr '\n' ' '`
139 fi
140 done
141 fi
142 db_set qpsmtpd/rcpthosts "$RCPTHOSTS"
143 fi
144
145 db_beginblock
146 db_input medium qpsmtpd/rcpthosts || true
147 db_endblock
148 db_go
149 db_get qpsmtpd/rcpthosts
150 RCPTHOSTS="$RET"
151
152 db_beginblock
153 db_input medium qpsmtpd/server_type || true
154 db_endblock
155 db_go
156 db_get qpsmtpd/server_type
157 SERVER="$RET"
158 done
159 fi
160
161 db_stop
162
163 exit 0
164