#!/bin/sh

CNT_FORCE=`rdcsman 0x8001000E u16`

# main ##########################################################

case "$1" in

	start)
		if [ $CNT_FORCE = 1 ] ; then
			l2tp-stop
		fi
		uvm /usr/uo/pap-secrets.uo > /etc/ppp/pap-secrets 
   	 	uvm /usr/uo/chap-secrets.uo > /etc/ppp/chap-secrets  
   	 	uvm /usr/uo/l2tp.conf.uo > /etc/l2tp/l2tp.conf
   	 					
   	 	l2tp-start

		if [ $CNT_FORCE = 1 ] ; then
			wrcsman "0x8001000E 0x00"
		fi

		if [ $? = 0 ] ; then
			exit 0
   	 	else
   	 		wrcsman "0x80060700 0x03 && 0x80010007 0x03"
    		exit 1	
   	 	fi	
		
		;;
	
	stop)
		l2tp-stop
		RET=$?				
		wrcsman "0x80060200 0x00 && \
			 	 0x80060300 0x00 && \
			 	 0x80060400 0x00 && \
				 0x80060500 0x00 && \
				 0x80060600 0x00 && \
				 0x80060700 0x00 && \
				 0x80010002 0x00 && \
				 0x80010003 0x00 && \
				 0x80010004 0x00 && \
				 0x80010005 0x00 && \
				 0x80010006 0x00 && \
				 0x80010007 0x00"
		exit $RET		
		
		;;	
			
	*)
		exit 1
esac

exit 0		
			
		
		
	
			
