#!/bin/sh  -e
# postinst for djbdns
# written by Adam McKenna
# <adam@debian.org>

#DEBCONF_DEBUG=1
#export DEBCONF_DEBUG

case "$1" in
    configure)
	# continue below
    ;;

    abort-upgrade|abort-remove|abort-deconfigure)
	exit 0
    ;;

    *)
	echo "postinst called with unknown argument \`$1'" >&2
	exit 0
    ;;
esac


umask 022


RET=true
test -e /usr/share/debconf/confmodule && {
  . /usr/share/debconf/confmodule
#  db_version 2.0
  db_get xtelld/from_inetd
  }
if [ "$RET" = "false" ]; then
  FROMINETD="no"
else
  FROMINETD="yes"
fi

/etc/init.d/xtell stop || true

echo "FROMINETD=$FROMINETD" > /etc/xtelldrc

if [ "$FROMINETD" = "no" ]; then
    update-inetd --remove '4224\t.*'
    update-inetd --remove 'xtell\t.*'
else
    update-inetd --group OTHER --add "xtell		stream	tcp	nowait	xtelld.tty	/usr/sbin/tcpd	/usr/sbin/xtelld"
fi

/etc/init.d/xtell start || true


#DEBHELPER#
test -e /usr/share/debconf/confmodule && {
  db_stop
}

exit 0
