#!/bin/sh

function show_opts()
{
	clear
	echo "                             NETWORK CONFIGURATION"
	echo "                             ====================="
	echo
	echo
	echo
        echo "                             A) System name"
	echo
        echo "                             B) Network interfaces"
	echo
        echo "                             C) Name servers"
	echo
	echo "                             D) Gateways"
	echo
	echo
	echo
}


function do_option()
{
	case "$1" in
		A|a)	# Name
			sh /etc/config/name
			;;
		B|b)	# Interfaces
			sh /etc/config/interfaces
			;;
		C|c)	# Name servers
			sh /etc/config/nameservers
			;;
		D|d)	# Gateways
			sh /etc/config/gateways
			;;
		*)	echo
			echo "Invalid option $1"
			echo
			return 1
			;;
	esac

	return 0
}


opt=
show_opts
while [ "$opt" != "quit" ]
do
	echo -n "Enter option (blank to redisplay, quit when done) "
	read opt
	if [ -z "$opt" ]; then
		show_opts
	elif [ "$opt" != "quit" ]; then
		do_option $opt
		if [ $? -ne 1 ]; then
			show_opts
		fi
	fi
done
