debian/masqmail-debian

annotate postinst @ 32:6293062092d1

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