masqmail-0.2

diff debian/postinst @ 0:08114f7dcc23

this is masqmail-0.2.21 from oliver kurth
author meillo@marmaro.de
date Fri, 26 Sep 2008 17:05:23 +0200
parents
children af25f5c39d90
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/debian/postinst	Fri Sep 26 17:05:23 2008 +0200
     1.3 @@ -0,0 +1,166 @@
     1.4 +#!/bin/sh -e
     1.5 +
     1.6 +# source debconf library
     1.7 +. /usr/share/debconf/confmodule
     1.8 +
     1.9 +CONFIGFILE=/etc/masqmail/masqmail.conf
    1.10 +WORKTMP=$CONFIGFILE.tmp
    1.11 +DEBCONFTMP=$CONFIGFILE.debconf
    1.12 +
    1.13 +DEFAULTSFILE=/etc/default/masqmail
    1.14 +DEBDEFTMP=$DEFAULTSFILE.debconf
    1.15 +
    1.16 +create_db_conf (){
    1.17 +    rm -f $WORKTMP $DEBCONFTMP
    1.18 +
    1.19 +    cat >> $DEBCONFTMP << EOF
    1.20 +### BEGIN DEBCONF SECTION
    1.21 +# Do not edit within this region if you want your changes to be preserved by
    1.22 +# debconf.  Instead, make changes after the "### END DEBCONF SECTION" line.
    1.23 +EOF
    1.24 +
    1.25 +    db_get masqmail/host_name || true
    1.26 +    echo "host_name=\"$RET\"" >> $DEBCONFTMP
    1.27 +    db_get masqmail/local_hosts || true
    1.28 +    echo "local_hosts=\"$RET\"" >> $DEBCONFTMP
    1.29 +    db_get masqmail/local_nets || true
    1.30 +    echo "local_nets=\"$RET\"" >> $DEBCONFTMP
    1.31 +    db_get masqmail/listen_addresses || true
    1.32 +    echo "listen_addresses=\"$RET\"" >> $DEBCONFTMP
    1.33 +
    1.34 +    echo "spool_dir=\"/var/spool/masqmail\"" >> $DEBCONFTMP
    1.35 +    echo "mail_dir=\"/var/mail\"" >> $DEBCONFTMP
    1.36 +    echo "log_dir=\"/var/log/masqmail\"" >> $DEBCONFTMP
    1.37 +    echo "do_queue=false" >> $DEBCONFTMP
    1.38 +
    1.39 +    db_get masqmail/use_syslog || true
    1.40 +    echo "use_syslog=$RET" >> $DEBCONFTMP
    1.41 +
    1.42 +    db_get masqmail/online_detect || true
    1.43 +    echo "online_detect=$RET" >> $DEBCONFTMP
    1.44 +    if [ "$RET" = "file" ] ; then
    1.45 +	db_get masqmail/online_file || true
    1.46 +	echo "online_file=\"$RET\"" >> $DEBCONFTMP
    1.47 +    else
    1.48 +	db_get masqmail/online_pipe || true
    1.49 +	echo "online_pipe=\"$RET\"" >> $DEBCONFTMP
    1.50 +    fi
    1.51 +
    1.52 +    db_get masqmail/mbox_default || true
    1.53 +    echo "mbox_default=$RET" >> $DEBCONFTMP
    1.54 +    db_get masqmail/mda || true
    1.55 +    echo "mda=\"$RET\"" >> $DEBCONFTMP
    1.56 +
    1.57 +    echo "alias_file=/etc/aliases" >> $DEBCONFTMP
    1.58 +    db_get masqmail/alias_local_caseless || true
    1.59 +    echo "alias_local_caseless=\"$RET\"" >> $DEBCONFTMP
    1.60 +
    1.61 +    cat >> $DEBCONFTMP << EOF
    1.62 +### END DEBCONF SECTION
    1.63 +EOF
    1.64 +}
    1.65 +
    1.66 +write_db_conf (){
    1.67 +
    1.68 +  if [ -e $CONFIGFILE ]; then
    1.69 +    # does the file have debconf markers in it?
    1.70 +    if egrep -q '^### BEGIN DEBCONF SECTION' $CONFIGFILE && \
    1.71 +       egrep -q '^### END DEBCONF SECTION' $CONFIGFILE; then
    1.72 +      # see if the beginning of the file was left alone; sed cannot backtrack in
    1.73 +      # an address range
    1.74 +      if ! head -1 $CONFIGFILE | egrep -q '^### BEGIN DEBCONF SECTION'; then
    1.75 +        # sick, sick, sick
    1.76 +        LINES=$(sed -n '1,/^### BEGIN DEBCONF SECTION/p' < $CONFIGFILE | wc -l)
    1.77 +        sed -n 1,$(( $LINES - 1 ))p < $CONFIGFILE > $WORKTMP
    1.78 +      fi
    1.79 +      cat $DEBCONFTMP >> $WORKTMP
    1.80 +      sed -n '/^### END DEBCONF SECTION/,$p' < $CONFIGFILE | tail +2 >> $WORKTMP
    1.81 +    else
    1.82 +      echo "Existing $CONFIGFILE has missing or half-open debconf region;" >&2;
    1.83 +      echo "not writing masqmail configuration file." >&2;
    1.84 +      exit 1
    1.85 +    fi
    1.86 +  else
    1.87 +    cat >> $DEBCONFTMP << EOF
    1.88 +#
    1.89 +# include the locations of your route and get configurations here.
    1.90 +# Examples:
    1.91 +# online_routes.default = "/etc/masqmail/default.route"
    1.92 +# online_gets.default = "/etc/masqmail/default.get"
    1.93 +# You can have more of those, with '.default' replaced with other
    1.94 +# names. See man 8 masqmail.conf.
    1.95 +#
    1.96 +EOF
    1.97 +    cp $DEBCONFTMP $WORKTMP
    1.98 +  fi
    1.99 +
   1.100 +  mv $WORKTMP $CONFIGFILE
   1.101 +
   1.102 +#  rm -f $WORKTMP $DEBCONFTMP
   1.103 +}
   1.104 +
   1.105 +create_db_defaults () {
   1.106 +    cat >> $DEBDEFTMP << EOF
   1.107 +#
   1.108 +# better use 'dpkg-reconfigure masqmail'
   1.109 +# instead of editing by hand
   1.110 +#
   1.111 +EOF
   1.112 +
   1.113 +    db_get masqmail/init_smtp_daemon || true
   1.114 +    echo "INIT_SMTP_DAEMON=\"$RET\"" >> $DEBDEFTMP
   1.115 +    db_get masqmail/init_queue_daemon || true
   1.116 +    echo "INIT_QUEUE_DAEMON=\"$RET\"" >> $DEBDEFTMP
   1.117 +    db_get masqmail/init_fetch_daemon || true
   1.118 +    echo "INIT_FETCH_DAEMON=\"$RET\"" >> $DEBDEFTMP
   1.119 +
   1.120 +    echo "#" >> $DEBDEFTMP
   1.121 +
   1.122 +    db_get masqmail/queue_daemon_ival || true
   1.123 +    echo "QUEUE_DAEMON_IVAL=\"$RET\"" >> $DEBDEFTMP
   1.124 +    db_get masqmail/fetch_daemon_ival || true
   1.125 +    echo "FETCH_DAEMON_IVAL=\"$RET\"" >> $DEBDEFTMP
   1.126 +
   1.127 +    echo "#" >> $DEBDEFTMP
   1.128 +
   1.129 +    db_get masqmail/ipup_runqueue || true
   1.130 +    echo "IPUP_RUNQUEUE=\"$RET\"" >> $DEBDEFTMP
   1.131 +    db_get masqmail/ipup_fetch || true
   1.132 +    echo "IPUP_FETCH=\"$RET\"" >> $DEBDEFTMP
   1.133 +
   1.134 +    db_get masqmail/ifup_ifaces || true
   1.135 +    echo "IFUP_IFACES=\"$RET\"" >> $DEBDEFTMP
   1.136 +}
   1.137 +   
   1.138 +write_db_defaults () {
   1.139 +    mv $DEBDEFTMP $DEFAULTSFILE
   1.140 +}
   1.141 +
   1.142 +case "$1" in
   1.143 +    configure)
   1.144 +
   1.145 +        # Create spool and log directories
   1.146 +        install -d -omail -gmail /var/log/masqmail
   1.147 +        install -d -omail -gmail /var/spool/masqmail
   1.148 +        install -d -omail -gmail /var/spool/masqmail/input
   1.149 +        install -d -omail -gmail /var/spool/masqmail/lock
   1.150 +        install -d -omail -gmail /var/spool/masqmail/popuidl
   1.151 +
   1.152 +	db_get masqmail/manage_config_with_debconf || true
   1.153 +	if [ "$RET" = "true" ]; then
   1.154 +	    db_get masqmail/move_existing_nondebconf_config || true
   1.155 +	    if [ "$RET" = "true" ]; then
   1.156 +		create_db_conf
   1.157 +		write_db_conf
   1.158 +	    fi
   1.159 +	    create_db_defaults
   1.160 +	    write_db_defaults
   1.161 +	fi
   1.162 +
   1.163 +        ;;
   1.164 +
   1.165 +    abort-upgrade|abort-remove|abort-deconfigure)
   1.166 +        ;;
   1.167 +esac
   1.168 +
   1.169 +#DEBHELPER#