#!/bin/sh
#TODO: check for file existance
#Use system var for rc.conf location
[ -e /etc/rc.defaults ] && . /etc/rc.defaults
[ -e /etc/rc.conf ] && . /etc/rc.conf

if [ -z $RM_calledfrom ]
then
	RM_calledfrom=0
fi

if [ -e $inetd_config -a "$RM_calledfrom" != "1" ]
then
	if [ "$1" != "-f" ]
	then
		echo "$inetd_config already exists!"
		echo "use 'cfg_inetd -f' to force overwrite"
		exit 1
	fi
fi

if [ "$RM_calledfrom" != "1" ]
then
	replimenu -f /usr/share/replimenu/inetd.menu
else
#Bodge to generate new lines as \n doesn't seem to work....
echo "Generating $inetd_config"
echo "#Generated by xxx
$RM_telnetd
$RM_sshd
$RM_ftpd
$RM_smbd
$RM_advent4
$RM_dungeon
" > $inetd_config
echo "Finished"
export RM_calledfrom=
exit 0 
fi
