debian/masqmail-debian

view postinst @ 38:c66ad5310835

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