#!/bin/sh
# This is a very basic init.d script but it will work with
# any linux distribution
#
# network       Bring up/down networking
#
# description: Activates/Deactivates all network interfaces configured to 
#              start at boot time.
# probe: true
# this key word is required  : action :

# Source ifconfig_llp.txt file
. /etc/ifconfig_llp.txt

[ -x /sbin/ifconfig ] || exit 0
CWD=`pwd`
# See how we were called.
case "$1" in
  start)
    # load the module for your network card
    # !!change this!! 
    echo "loading 8390 module"; modprobe 8390
    # -- loop back device
    if (ifconfig | egrep -q '^lo' ); then
        echo "lo already up ..."
    else
        echo -n "Bringing up interface lo:"
        ifconfig lo 127.0.0.1 netmask 255.0.0.0 up || exit 1
        route add -net 127.0.0.0 netmask 255.0.0.0 dev lo || exit 1
        if ifconfig | egrep -q '^lo' ; then
            echo "lo startup ok"
        else
            echo "lo startup failed"
        fi
    fi
    # -- ethernet device
    if (ifconfig | egrep -q '^eth0' ); then
        echo "eth0 already up ..."
    else
        echo -n "Bringing up interface eth0:"
        ifconfig eth0 $IPADDR netmask  $NETMASK up
        route add -host $GATEWAY netmask $NETMASK dev eth0
        route add default gw $GATEWAY eth0
        if ifconfig | egrep -q '^eth0' ; then
            echo "eth0 startup ok"
        else
            echo "eth0 startup failed"
        fi
    fi
    #
    #
    # start the LCD driver:
    # !!change this!! (ttyS1 or ttyS0)
    /usr/sbin/llp.pl /dev/ttyS1&
    #
    touch /var/lock/subsys/network
    ;;
  stop)
	for i in `/sbin/ifconfig | grep '^[a-z]' | awk '{print $1}'` ; do
		echo "Shutting down interface $i"; ifconfig ${i} down
	done
    rm -f /var/lock/subsys/network
    ;;
  status)
    echo "Currently active devices:"
    echo `/sbin/ifconfig | grep '^[a-z]' | awk '{print $1}'`
	;;
  restart)
        cd $CWD
	$0 stop
	$0 start
	;;
  reload)
    cd $CWD
    $0 restart
	;;
  probe)
    exit 0
	;;
  *)
    echo "Usage: network {start|stop|restart|reload|status|probe}"
    exit 1
esac

exit 0
# vim: set sw=4 ts=4 et:
