#!/bin/sh

# Source function library.
. /etc/rc.d/init.d/functions

#LOC_IP=0.0.0.0
#NETMASK=255.255.255.255
#GW=0.0.0.0

# set to correct product (USB or PCI)
UNICORN="unicorn_pci_eth"
#UNICORN="unicorn_usb_eth"

# ANSI=1,G.lite=2,MULTI=3,G.dmt=4,
MODULATION=1

# default VPI, VCI and encapsulation
VPI=8
VCI=35

# standard setting for IP over ATM
PROTOCOL=ipoatm
ENCAPS=null

echo -n "$1 $UNICORN $PROTOCOL $VPI.$VCI $ENCAPS"

stop () {
	/sbin/ifconfig dsl0 down >/dev/null 2>&1
	/sbin/modprobe -r $UNICORN >/dev/null 2>&1
	return $?
}

start() {
	/sbin/modprobe $UNICORN PROTOCOL=$PROTOCOL ActivationMode=$MODULATION VPI=$VPI VCI=$VCI
   	[ ! "$?" = 0 ] && return $?
	/sbin/ifconfig dsl0 up
	#/sbin/ifconfig dsl $LOC_IP netmask $NETMASK
	#/sbin/route add gw $GW
	return 0
}

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

RETVAL=$?
if [ $RETVAL = 0 ]; then
    echo_success
else 
    echo_failure
fi
echo
exit $RETVAL
