meillo@0: #!/bin/bash -e meillo@0: meillo@0: # Source debconf library. meillo@0: . /usr/share/debconf/confmodule meillo@0: meillo@0: db_version 2.0 meillo@0: meillo@0: # This conf script is capable of backing up meillo@0: db_capb backup meillo@0: meillo@0: # shamelessly copied from xserver-common.config. meillo@0: # Thanks to Branden. :-) meillo@0: meillo@0: CONFIGFILE=/etc/masqmail/masqmail.conf meillo@0: meillo@0: ASK_TO_REPLACE= meillo@0: if [ -e $CONFIGFILE ]; then meillo@0: # does the file have debconf markers in it? meillo@0: if egrep -q '^### BEGIN DEBCONF SECTION' $CONFIGFILE && \ meillo@0: egrep -q '^### END DEBCONF SECTION' $CONFIGFILE; then meillo@0: PRIORITY=medium meillo@0: else meillo@0: ASK_TO_REPLACE=yes meillo@0: PRIORITY=high meillo@0: fi meillo@0: else meillo@0: PRIORITY=medium meillo@0: # this is for the postinst, which tests this: meillo@0: db_set masqmail/move_existing_nondebconf_config "true" meillo@0: fi meillo@0: meillo@0: # use debconf to manage configuration file? meillo@0: db_input $PRIORITY masqmail/manage_config_with_debconf || true meillo@0: db_go meillo@0: db_get masqmail/manage_config_with_debconf meillo@0: if [ "$RET" = "false" ]; then meillo@0: exit 0 meillo@0: fi meillo@0: meillo@0: # move existing configuration file out of meillo@0: # the way? meillo@0: if [ x"$ASK_TO_REPLACE" = x"yes" ]; then meillo@0: db_input $PRIORITY masqmail/move_existing_nondebconf_config || true meillo@0: db_go meillo@0: db_get masqmail/move_existing_nondebconf_config || true meillo@0: if [ "$RET" = "true" ]; then meillo@0: mv $CONFIGFILE $CONFIGFILE.debconf-backup meillo@0: else meillo@0: exit 0 meillo@0: fi meillo@0: fi meillo@0: meillo@0: if [ -f /etc/mailname ] ; then meillo@0: hostfqdn=`cat /etc/mailname` meillo@0: else meillo@0: hostfqdn=`hostname -f` meillo@0: fi meillo@0: hostname=`hostname` meillo@0: meillo@0: db_fget masqmail/host_name seen meillo@0: if [ "$RET" = "false" ]; then meillo@0: db_set masqmail/host_name ${hostfqdn} meillo@0: fi meillo@0: db_fget masqmail/local_hosts seen meillo@0: if [ "$RET" = "false" ]; then meillo@0: db_set masqmail/local_hosts "localhost;${hostname};${hostfqdn}" meillo@0: fi meillo@0: meillo@0: STATE=1 meillo@0: while [ "$STATE" != 0 -a "$STATE" != 19 ]; do meillo@0: case "$STATE" in meillo@0: 1) meillo@0: db_input medium masqmail/host_name || true meillo@0: ;; meillo@0: 2) meillo@0: db_input medium masqmail/local_hosts || true meillo@0: ;; meillo@0: 3) meillo@0: db_input medium masqmail/local_nets || true meillo@0: ;; meillo@0: 4) meillo@0: db_input medium masqmail/listen_addresses || true meillo@0: ;; meillo@0: 5) meillo@0: db_input low masqmail/use_syslog || true meillo@0: ;; meillo@0: 6) meillo@0: db_input medium masqmail/online_detect || true meillo@0: ;; meillo@0: 7) meillo@0: db_get masqmail/online_detect meillo@0: if [ "$RET" = "file" ] ; then meillo@0: db_input low masqmail/online_file || true meillo@0: else meillo@0: db_input medium masqmail/online_pipe || true meillo@0: fi meillo@0: ;; meillo@0: 8) meillo@0: db_input medium masqmail/mbox_default || true meillo@0: ;; meillo@0: 9) meillo@0: db_get masqmail/mbox_default meillo@0: if [ "$RET" = "mda" ] ; then meillo@0: db_input medium masqmail/mda || true meillo@0: else meillo@0: db_input low masqmail/mda || true meillo@0: fi meillo@0: ;; meillo@0: 10) meillo@0: db_input low masqmail/alias_local_caseless || true meillo@0: ;; meillo@0: 11) meillo@0: db_input low masqmail/init_smtp_daemon || true meillo@0: ;; meillo@0: 12) meillo@0: db_input low masqmail/init_queue_daemon || true meillo@0: ;; meillo@0: 13) meillo@0: db_get masqmail/init_queue_daemon meillo@0: if [ "$RET" = "true" ] ; then meillo@0: db_input low masqmail/queue_daemon_ival || true meillo@0: fi meillo@0: ;; meillo@0: 14) meillo@0: db_input medium masqmail/init_fetch_daemon || true meillo@0: ;; meillo@0: 15) meillo@0: db_get masqmail/init_fetch_daemon meillo@0: if [ "$RET" = "true" ] ; then meillo@0: db_input low masqmail/fetch_daemon_ival || true meillo@0: fi meillo@0: ;; meillo@0: 16) meillo@0: db_input medium masqmail/ipup_runqueue || true meillo@0: ;; meillo@0: 17) meillo@0: db_input medium masqmail/ipup_fetch || true meillo@0: ;; meillo@0: 18) meillo@0: db_input medium masqmail/ifup_ifaces || true meillo@0: ;; meillo@0: meillo@0: esac meillo@0: meillo@0: if db_go; then meillo@0: STATE=$(($STATE + 1)) meillo@0: else meillo@0: STATE=$(($STATE - 1)) meillo@0: fi meillo@0: done meillo@0: meillo@0: # dpkg-reconfigure does not stop services: meillo@0: # (cause of Bug#151528) meillo@0: # in debhelper version < 1.2.9 meillo@0: meillo@0: DH_VERSION=`dpkg -l debconf | awk ' /^ii/ { print $3 }'` meillo@0: meillo@0: if dpkg --compare-versions $DH_VERSION lt "1.2.9" ; then meillo@0: if [ x"$1" = x"reconfigure" ] ; then meillo@1: if which invoke-rc.d >/dev/null 2>&1; then meillo@1: invoke-rc.d masqmail stop meillo@1: else meillo@1: if [ -x "/etc/init.d/masqmail" ]; then meillo@1: /etc/init.d/masqmail stop || true meillo@1: fi meillo@0: fi meillo@0: fi meillo@0: fi meillo@0: meillo@0: exit 0