#!/bin/sh # Source function library. #. /etc/init.d/functions echo_success() { printf "[ \033[32;1mOK\033[0;37m ]\n" return 0 } echo_failure() { printf "[ \033[31;1mFAILED\033[0;37m ]\n" return 1 } # set to correct product (USB or PCI) UNICORN="unicorn_pci" #UNICORN="unicorn_usb" VPI=8 VCI=35 # Module parameters # ANSI=1,G.lite=2,MULTI=3,G.dmt=4, MODE=1 MODPROBE="/sbin/modprobe" PPPD="/usr/sbin/pppd" PLUGIN="/usr/lib/pppd/2.4.1/pppoatm.so" USER=airmex@net1.dual.nerim cleanup() { echo "" echo "initialization of ADSL PPPoATM failed!" echo "" $MODPROBE -r $UNICORN >/dev/null 2>&1 break } EXITCODE=1 case "$1" in reload) echo -n "Killing pppd " kill `ps -fu root | grep $USER | grep -v 'grep' | awk '{ print $2 }'` if test $? -eq 0; then echo_success else echo_failure fi echo "Starting ppd" $PPPD user $USER plugin $PLUGIN $VPI.$VCI > /dev/null 2>&1 if test $? -eq 0; then echo_success else echo_failure fi ;; check) echo -n "Testing ADSL link " ps -fu root | grep $USER | grep -v 'grep' | wc -l | grep 0 > /dev/null 2>&1 if test $? -eq 0; then echo_failure exit 1 else echo_success fi ;; check-start) $0 check if test $? -eq 1; then echo Restarting ADSL Link... $0 start fi ;; restart) $0 stop $0 start ;; stop) echo "killing pppd" kill `ps -fu root | grep $USER | grep -v 'grep' | awk '{ print $2 }'` echo -n "removing $UNICORN" $MODPROBE -r $UNICORN >/dev/null 2>&1 if test $? -eq 0; then echo_success else echo_failure fi echo ;; start) echo -n "loading $UNICORN, mode=$MODE " $MODPROBE pppoatm > /dev/null 2>&1 $MODPROBE $UNICORN ActivationMode=$MODE > /dev/null 2>&1 if test $? -eq 0; then echo_success else echo_failure cleanup fi echo echo -n "Attente synchro du modem " retry=60 while [ -z "`/bin/cat /proc/net/atm/UNICORN\:0 | fgrep "SHOWTIME L0"`" -a "$retry" -gt 0 ] do sleep 1 echo -n "." retry=$[$retry-1] done if test "$retry" -gt 0 ; then echo_success else echo_failure cleanup fi echo -n "ADSL synchro found, starting pppd " $PPPD user $USER plugin $PLUGIN $VPI.$VCI > /dev/null 2>&1 if test $? -eq 0; then echo_success else echo_failure cleanup fi echo ;; *) echo "Usage: $0 start|stop|restart|reload|check|check-start" exit 2 ;; esac EXITCODE=0 exit $EXITCODE