#! /bin/sh
#
# netconfig	This shell script boots up or shuts down the base INET system.
#
# Version:	@(#)/etc/init.d/netconfig 1.00 96-03-31 patrol Exp $
#               customized for sinux
#

HOSTNAME=`hostname`

case "$1" in
  start)
    echo Configuring network interfaces...
    # Attach the loopback device.
    /sbin/ifconfig lo 127.0.0.1
    /sbin/route add -net 127.0.0.0 netmask 255.0.0.0 dev lo

    # IF YOU HAVE AN ETHERNET CONNECTION, use these lines below to configure the 
    # eth0 interface. If you're only using loopback or SLIP, don't include the
    # rest of the lines in this file.

    # Edit for your setup.
    IPADDR="62.168.0.1"  # REPLACE with YOUR IP address!
    NETMASK="255.255.255.240"  # REPLACE with YOUR netmask!
    NETWORK="62.168.0.0"  # REPLACE with YOUR network address!
    BROADCAST="62.168.0.15"  # REPLACE with YOUR broadcast address, if you
 			      # have one. If not, leave blank and edit below.
    #GATEWAY="147.32.192.1"  # REPLACE with YOUR gateway address!

    # Configure the ethernet adaptor.
    /sbin/ifconfig eth1 ${IPADDR} broadcast ${BROADCAST} netmask ${NETMASK}

    # Set the network route to the ethernet network.
    # /sbin/route add -net ${NETWORK} netmask ${NETMASK} dev eth0

    # Set the default gateway, if one exists
    #/sbin/route add default gw ${GATEWAY} metric 1

    # Make local host accessible via its ethernet address
    # /sbin/route add 194.213.33.1 gw localhost

    # Enable gatewaying under 2.1
    echo 1 >/proc/sys/net/ipv4/ip_forwarding
    
    # PUT OTHER CONFIGURATION COMMANDS HERE (as starting SLIP or PPP fixed lines)
    # slip #0 /dev/cua3 - sinus
    /sbin/slattach -L -s 115200 -p cslip /dev/ttyS3 2>/dev/null &
    /usr/bin/sleep 2
    /sbin/ifconfig sl0 62.168.0.37 netmask 255.255.255.252 broadcast 62.168.0.39
    # /sbin/route add -host sinus dev sl0
    # /sbin/arp -s sinus 00:a0:24:70:04:b7 pub

    # Setup for Zakupy
    /sbin/modprobe ipip
    /sbin/modprobe tunnel
    /sbin/ifconfig eth0 194.88.37.18 netmask 255.255.255.248 broadcast 194.88.37.23
    /sbin/ifconfig tunl0 194.88.37.18 pointopoint 194.213.32.1
    /sbin/ifconfig tunl0:1 ${IPADDR} pointopoint 194.213.32.1
    /sbin/route add 194.213.32.1 gw 194.88.37.17
    /sbin/route add -net 62.168.0.0 netmask 255.255.255.0 gw 62.168.0.2
    /sbin/route add default dev tunl0:1
    /sbin/slattach -L -s 57600 -p cslip /dev/ttyS1 2>/dev/null &
    /sbin/ifconfig sl1 62.168.0.41 netmask 255.255.255.252 broadcast 62.168.0.43

    ;;
  stop)
    # These commands are executed when the network has to be shut down.
    echo Unconfiguring network interfaces...
    /usr/bin/killall slattach
    /sbin/ifconfig eth0 down
    /sbin/ifconfig lo down

    # Shut down Loucovice
    #/sbin/ifconfig tunl0 down
    #/sbin/ifconfig eth1 down
    #/sbin/rmmod ipip
    ;;
  *)
    echo "Usage: netconfig {start|stop}"
    exit 1
esac
exit 0
# End of netconfig
