rev |
line source |
meillo@51
|
1 #!/bin/sh
|
meillo@51
|
2 set -e
|
meillo@0
|
3
|
meillo@0
|
4 # source debconf library
|
meillo@0
|
5 . /usr/share/debconf/confmodule
|
meillo@0
|
6
|
meillo@0
|
7 CONFIGFILE=/etc/masqmail/masqmail.conf
|
meillo@0
|
8 WORKTMP=$CONFIGFILE.tmp
|
meillo@0
|
9 DEBCONFTMP=$CONFIGFILE.debconf
|
meillo@0
|
10
|
meillo@0
|
11 DEFAULTSFILE=/etc/default/masqmail
|
meillo@0
|
12 DEBDEFTMP=$DEFAULTSFILE.debconf
|
meillo@0
|
13
|
meillo@0
|
14 create_db_conf (){
|
meillo@0
|
15 rm -f $WORKTMP $DEBCONFTMP
|
meillo@0
|
16
|
meillo@0
|
17 cat >> $DEBCONFTMP << EOF
|
meillo@0
|
18 ### BEGIN DEBCONF SECTION
|
meillo@0
|
19 # Do not edit within this region if you want your changes to be preserved by
|
meillo@0
|
20 # debconf. Instead, make changes after the "### END DEBCONF SECTION" line.
|
meillo@0
|
21 EOF
|
meillo@0
|
22
|
meillo@0
|
23 db_get masqmail/host_name || true
|
meillo@0
|
24 echo "host_name=\"$RET\"" >> $DEBCONFTMP
|
meillo@0
|
25 db_get masqmail/local_hosts || true
|
meillo@0
|
26 echo "local_hosts=\"$RET\"" >> $DEBCONFTMP
|
meillo@0
|
27 db_get masqmail/local_nets || true
|
meillo@0
|
28 echo "local_nets=\"$RET\"" >> $DEBCONFTMP
|
meillo@0
|
29 db_get masqmail/listen_addresses || true
|
meillo@0
|
30 echo "listen_addresses=\"$RET\"" >> $DEBCONFTMP
|
meillo@0
|
31
|
meillo@0
|
32 echo "spool_dir=\"/var/spool/masqmail\"" >> $DEBCONFTMP
|
meillo@0
|
33 echo "mail_dir=\"/var/mail\"" >> $DEBCONFTMP
|
meillo@0
|
34 echo "log_dir=\"/var/log/masqmail\"" >> $DEBCONFTMP
|
meillo@0
|
35 echo "do_queue=false" >> $DEBCONFTMP
|
meillo@0
|
36
|
meillo@0
|
37 db_get masqmail/use_syslog || true
|
meillo@0
|
38 echo "use_syslog=$RET" >> $DEBCONFTMP
|
meillo@0
|
39
|
meillo@0
|
40 db_get masqmail/online_detect || true
|
meillo@0
|
41 echo "online_detect=$RET" >> $DEBCONFTMP
|
meillo@0
|
42 if [ "$RET" = "file" ] ; then
|
meillo@0
|
43 db_get masqmail/online_file || true
|
meillo@0
|
44 echo "online_file=\"$RET\"" >> $DEBCONFTMP
|
meillo@0
|
45 else
|
meillo@0
|
46 db_get masqmail/online_pipe || true
|
meillo@0
|
47 echo "online_pipe=\"$RET\"" >> $DEBCONFTMP
|
meillo@0
|
48 fi
|
meillo@0
|
49
|
meillo@0
|
50 db_get masqmail/mbox_default || true
|
meillo@0
|
51 echo "mbox_default=$RET" >> $DEBCONFTMP
|
meillo@0
|
52 db_get masqmail/mda || true
|
meillo@0
|
53 echo "mda=\"$RET\"" >> $DEBCONFTMP
|
meillo@0
|
54
|
meillo@0
|
55 echo "alias_file=/etc/aliases" >> $DEBCONFTMP
|
meillo@0
|
56 db_get masqmail/alias_local_caseless || true
|
meillo@0
|
57 echo "alias_local_caseless=\"$RET\"" >> $DEBCONFTMP
|
meillo@0
|
58
|
meillo@0
|
59 cat >> $DEBCONFTMP << EOF
|
meillo@0
|
60 ### END DEBCONF SECTION
|
meillo@0
|
61 EOF
|
meillo@0
|
62 }
|
meillo@0
|
63
|
meillo@0
|
64 write_db_conf (){
|
meillo@0
|
65
|
meillo@0
|
66 if [ -e $CONFIGFILE ]; then
|
meillo@0
|
67 # does the file have debconf markers in it?
|
meillo@0
|
68 if egrep -q '^### BEGIN DEBCONF SECTION' $CONFIGFILE && \
|
meillo@0
|
69 egrep -q '^### END DEBCONF SECTION' $CONFIGFILE; then
|
meillo@0
|
70 # see if the beginning of the file was left alone; sed cannot backtrack in
|
meillo@0
|
71 # an address range
|
meillo@0
|
72 if ! head -1 $CONFIGFILE | egrep -q '^### BEGIN DEBCONF SECTION'; then
|
meillo@0
|
73 # sick, sick, sick
|
meillo@0
|
74 LINES=$(sed -n '1,/^### BEGIN DEBCONF SECTION/p' < $CONFIGFILE | wc -l)
|
meillo@0
|
75 sed -n 1,$(( $LINES - 1 ))p < $CONFIGFILE > $WORKTMP
|
meillo@0
|
76 fi
|
meillo@0
|
77 cat $DEBCONFTMP >> $WORKTMP
|
meillo@0
|
78 sed -n '/^### END DEBCONF SECTION/,$p' < $CONFIGFILE | tail -n +2 >> $WORKTMP
|
meillo@0
|
79 else
|
meillo@0
|
80 echo "Existing $CONFIGFILE has missing or half-open debconf region;" >&2;
|
meillo@0
|
81 echo "not writing masqmail configuration file." >&2;
|
meillo@0
|
82 exit 1
|
meillo@0
|
83 fi
|
meillo@0
|
84 else
|
meillo@0
|
85 cat >> $DEBCONFTMP << EOF
|
meillo@0
|
86 #
|
meillo@0
|
87 # include the locations of your route and get configurations here.
|
meillo@0
|
88 # Examples:
|
meillo@0
|
89 # online_routes.default = "/etc/masqmail/default.route"
|
meillo@0
|
90 # online_gets.default = "/etc/masqmail/default.get"
|
meillo@0
|
91 # You can have more of those, with '.default' replaced with other
|
meillo@0
|
92 # names. See man 8 masqmail.conf.
|
meillo@0
|
93 #
|
meillo@0
|
94 EOF
|
meillo@0
|
95 cp $DEBCONFTMP $WORKTMP
|
meillo@0
|
96 fi
|
meillo@0
|
97
|
meillo@0
|
98 mv $WORKTMP $CONFIGFILE
|
meillo@0
|
99
|
meillo@0
|
100 # rm -f $WORKTMP $DEBCONFTMP
|
meillo@0
|
101 }
|
meillo@0
|
102
|
meillo@0
|
103 create_db_defaults () {
|
meillo@0
|
104 cat >> $DEBDEFTMP << EOF
|
meillo@0
|
105 #
|
meillo@0
|
106 # better use 'dpkg-reconfigure masqmail'
|
meillo@0
|
107 # instead of editing by hand
|
meillo@0
|
108 #
|
meillo@0
|
109 EOF
|
meillo@0
|
110
|
meillo@0
|
111 db_get masqmail/init_smtp_daemon || true
|
meillo@0
|
112 echo "INIT_SMTP_DAEMON=\"$RET\"" >> $DEBDEFTMP
|
meillo@0
|
113 db_get masqmail/init_queue_daemon || true
|
meillo@0
|
114 echo "INIT_QUEUE_DAEMON=\"$RET\"" >> $DEBDEFTMP
|
meillo@0
|
115 db_get masqmail/init_fetch_daemon || true
|
meillo@0
|
116 echo "INIT_FETCH_DAEMON=\"$RET\"" >> $DEBDEFTMP
|
meillo@0
|
117
|
meillo@0
|
118 echo "#" >> $DEBDEFTMP
|
meillo@0
|
119
|
meillo@0
|
120 db_get masqmail/queue_daemon_ival || true
|
meillo@0
|
121 echo "QUEUE_DAEMON_IVAL=\"$RET\"" >> $DEBDEFTMP
|
meillo@0
|
122 db_get masqmail/fetch_daemon_ival || true
|
meillo@0
|
123 echo "FETCH_DAEMON_IVAL=\"$RET\"" >> $DEBDEFTMP
|
meillo@0
|
124
|
meillo@0
|
125 echo "#" >> $DEBDEFTMP
|
meillo@0
|
126
|
meillo@0
|
127 db_get masqmail/ipup_runqueue || true
|
meillo@0
|
128 echo "IPUP_RUNQUEUE=\"$RET\"" >> $DEBDEFTMP
|
meillo@0
|
129 db_get masqmail/ipup_fetch || true
|
meillo@0
|
130 echo "IPUP_FETCH=\"$RET\"" >> $DEBDEFTMP
|
meillo@0
|
131
|
meillo@0
|
132 db_get masqmail/ifup_ifaces || true
|
meillo@0
|
133 echo "IFUP_IFACES=\"$RET\"" >> $DEBDEFTMP
|
meillo@0
|
134 }
|
meillo@0
|
135
|
meillo@0
|
136 write_db_defaults () {
|
meillo@0
|
137 mv $DEBDEFTMP $DEFAULTSFILE
|
meillo@0
|
138 }
|
meillo@0
|
139
|
meillo@0
|
140 case "$1" in
|
meillo@0
|
141 configure)
|
meillo@0
|
142
|
meillo@0
|
143 # Create spool and log directories
|
meillo@0
|
144 install -d -omail -gmail /var/log/masqmail
|
meillo@0
|
145 install -d -omail -gmail /var/spool/masqmail
|
meillo@0
|
146 install -d -omail -gmail /var/spool/masqmail/input
|
meillo@0
|
147 install -d -omail -gmail /var/spool/masqmail/lock
|
meillo@0
|
148 install -d -omail -gmail /var/spool/masqmail/popuidl
|
meillo@0
|
149
|
meillo@0
|
150 db_get masqmail/manage_config_with_debconf || true
|
meillo@0
|
151 if [ "$RET" = "true" ]; then
|
meillo@0
|
152 db_get masqmail/move_existing_nondebconf_config || true
|
meillo@0
|
153 if [ "$RET" = "true" ]; then
|
meillo@0
|
154 create_db_conf
|
meillo@0
|
155 write_db_conf
|
meillo@0
|
156 fi
|
meillo@0
|
157 create_db_defaults
|
meillo@0
|
158 write_db_defaults
|
meillo@0
|
159 fi
|
meillo@0
|
160
|
meillo@0
|
161 ;;
|
meillo@0
|
162
|
meillo@0
|
163 abort-upgrade|abort-remove|abort-deconfigure)
|
meillo@0
|
164 ;;
|
meillo@0
|
165 esac
|
meillo@0
|
166
|
meillo@0
|
167 #DEBHELPER#
|