#!/bin/sh
[ -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 /etc/rc.conf -a "$RM_calledfrom" != "1" ]
then
	if [ "$1" != "-f" ]
	then
		echo "/etc/rc.conf already exists!"
		echo "use 'cfg_rc -f' to force overwrite"
		exit 1
	fi
fi

if [ "$RM_calledfrom" != "1" ]
then
	replimenu -f /usr/share/replimenu/rc.menu
else
#Bodge to generate new lines as \n doesn't seem to work....
echo "Generating /etc/rc.conf"
echo "# Generated by cfg_rc
hostname=$RM_hostname
enable_network_on_boot=$RM_enable_network_on_boot
start_inetd=$RM_start_inetd
start_openvpn=$RM_start_openvpn
start_esd=$RM_esd
show_firmware_version=$RM_show_firmware_version
start_syslogd=$RM_start_syslogd
start_boa=$RM_start_boa
start_inadyn=$RM_start_inadyn
check_update=$RM_check_update
start_hinged=$RM_start_hinged
start_pixil=$RM_start_pixil
" > /etc/rc.conf 
export RM_calledfrom=
if [ "$RM_network_method" = "1" ]
then
	echo "Network method 1"
	/usr/bin/cfg_netmanual
fi

if [ "$RM_network_method" = "2" ]
then
	echo "Network method 1"
	/usr/bin/cfg_netwfc
fi

if [ "$RM_network_method" = "3" ]
then
	echo "Network method 3"
	/usr/bin/wnc.sh
fi

echo "Finished"
exit 0 
fi
