#!/bin/sh
#
# /etc/rc.d/init.d/isdnstart
#
# (c) 1999 Tilmann Bitterberg (tilmann.bitterberg@gmx.net)
#
# Loading ISDN modules and starting isdn4linux 
# tested  only with a 2.2.0-final and Red Hat 5.2 isdn4linux-beta2
#
# For nonPnP Devices (these are only examples)

# Card 0,1
HISAX_IO=0xd80,0xf80
HISAX_IRQ=10,5

# Protokol:  "1" for German 1TR6, "2" for (Euro ISDN) and "3" for leased lines
HISAX_PROT=2,2

# Typ der Karte(n) (see /usr/src/linux/Documentation/isdn/README.HiSax)
HISAX_TYPE=3,3

# Bezeichnung (beliebig)
HISAX_ID1=teles
HISAX_ID2=echo

HISAXPARM="io=$HISAX_IO irq=$HISAX_IRQ protocol=$HISAX_PROT type=$HISAX_TYPE id=$HISAX_ID1%$HISAX_ID2"

# isdn option file(s)
ISDNPATH=/etc/isdn
ISDNLOGFILE=$ISDNPATH/isdnlog.options 
ISDNCONFILE=$ISDNPATH/isdn.conf
ISDNPPPFILE=/etc/ppp/options.ippp0

# See how we were called.
case "$1" in
  start)
   	echo Using your settings
	echo $HISAXPARM
	
	echo Loading ISDN Device Drivers ...
	insmod slhc
	insmod isdn
	insmod hisax $HISAXPARM

	echo Enable HiSax D-Channel logging ...
	hisaxctrl $HISAX_ID1 1  4
	hisaxctrl $HISAX_ID2 1  4

	# lets start isdnlog
	if [ -f $ISDNLOGFILE ];
	   then
	   	echo Starting isdnlog with $ISDNLOGFILE on /dev/isdnctrl ...
		/sbin/isdnlog -f$ISDNLOGFILE /dev/isdnctrl
	   else
	   	echo -n ERROR! Starting isdnlog with 
		echo $ISDNLOGFILE on /dev/isdnctrl FAILED!
	   	# exit 1 # Abbruch
	fi # von isdnlog

	if [ -f /etc/isdn/isdn.conf ]; 
	   then
		echo Configure INTERFACES in $ISDNCONFILE ...
		isdnctrl readconf
	   else 
	   	echo ERROR! Configure INTERFACES in $ISDNCONFILE FAILED!
		# exit 1
	fi  # von isdnctrl

	if [ -f $ISDNPPPFILE ];
	   then
	   	echo Starting IPPPD ...
		/sbin/ipppd pidfile /var/run/ipppd.ippp0.pid file $ISDNPPPFILE
		echo doing ifconfig on ippp0
		/sbin/ifconfig ippp0 193.196.136.143 pointopoint 193.196.136.244 up 
	   else
	   	echo ERROR! Starting of ipppd FAILED!
		# exit 1
	fi  # von ipppd
    ;;
  stop)
	echo shutting down complete ISDN
	killall ipppd
	killall isdnlog
	rmmod hisax
	rmmod isdn
	rmmod slhc
    ;;
  *)
        echo "Usage: $0: {start|stop}"
        exit 0
esac

# /sbin/ipchains  -A forward -j MASQ -s 192.168.10.0/24 -d 0.0.0.0/0
