#!/bin/sh
# vim:ts=2:sts=2:et

set -e

INETD_SCR="/etc/init.d/inetd"
INETD_CONF="/etc/inetd.conf"
RLINCONFDIR="/etc/rlinetd.d/"
UCFDIR="/var/lib/rlinetd/ucf/"


if [ "$1" = "configure" ]; then
  if [ -f "$INETD_CONF" ] && [ -z "`ls -1 $UCFDIR`" ]; then

    # source debconf library
    . /usr/share/debconf/confmodule
    db_get rlinetd/convert_from_inetd
    if [ "x$RET" = "xtrue" ] ; then
      inetd2rlinetd --add-from-comment -f "$INETD_CONF" "$RLINCONFDIR"
    fi

    inetd2rlinetd --add-from-comment --force-overwrite -f "$INETD_CONF" "$UCFDIR"

    db_stop
  fi
fi

#DEBHELPER#
