#!/bin/bash
########################################################################
# Begin $rc_base/init.d/setlcd
#
# Description : Show IP Addresses on LCD Panel
#
# Author      : Jim Gifford - jim@linuxfromscratch.org
#
# Version     : 00.00
#
# Notes       :
#
########################################################################

. /tools/etc/sysconfig/rc
. $rc_functions

case "$1" in
	start)
		ip addr show dev eth0 > /dev/null 2>&1
		if [ "$?" = "0" ]; then
			IFACE1_IP="`ip addr show dev eth0 | grep inet | cut -d / -f 1 | cut -d t  -f 2 | cut -d' ' -f 2 `"
			IFACE1="$IFACE1_IP"
		fi
		ip addr show dev eth1 > /dev/null 2>&1
		if [ "$?" = "0" ]; then
			IFACE2_IP="`ip addr show dev eth1 | grep inet | cut -d / -f 1 | cut -d t  -f 2 | cut -d' ' -f 2 `"
			IFACE2="$IFACE2_IP"
		fi
		if [ "$IFACE2" = "" ]; then
			$LCD_PROG "Lan1 $IFACE1"
		else
			$LCD_PROG "Lan1 $IFACE1" "Lan2 $IFACE2"
		fi

	;;

        stop)
		$LCD_PROG "	" "	"
                ;;

        restart)
                ${0} stop
                sleep 1
                ${0} start
                ;;

	*)
		echo "Usage: {start|stop|restart}"
		exit 1
		;;
esac

# End $rc_base/init.d/setlcd

