#!/bin/sh -e

if test -e /usr/share/debconf/confmodule; then
	. /usr/share/debconf/confmodule
fi

if test "$1" = "configure"
then
	if command -v install-docs >/dev/null 2>&1
	then
		install-docs -i /usr/share/doc-base/pop3lite-admin
	fi
fi

if test -e /usr/share/debconf/confmodule; then
	db_get pop3lite/run-from-inetd
	if ! test -e /etc/pop3lite-start.conf; then
		cat > /etc/pop3lite-start.conf <<EOF
#
# pop3lite-start.conf - POP3Lite starter configuration
#

# from_inetd: wheter we're running from inetd, or as standalone
from_inetd=$RET
EOF
	else
		sed -e "s/from_inetd=.*/from_inetd=$RET/g" < /etc/pop3lite-start.conf \
			> /etc/pop3lite-start.conf.new
		rm -f /etc/pop3lite-start.conf && mv /etc/pop3lite-start.conf.new \
			/etc/pop3lite-start.conf
	fi

	case $RET in
		yes)
			update-inetd --add \
			'pop-3          stream  tcp     nowait  root    /usr/sbin/tcpd  /usr/sbin/pop3lite' || true
			;;
		no)
			update-inetd --pattern "pop3lite" --disable pop-3 || true
			;;
	esac
fi

#DEBHELPER#


syntax highlighted by Code2HTML, v. 0.9.1