Since ppp program does not restart once remote echo requests stop, and we can not send our own echo requests, because the provider does reply with bongled ones, we need a script to watch PPP(oE):
/root/bin/watch_ppp.sh
Code:
#!/bin/sh
export dslif=epair1b
export dslpkts=0
export dslfails=0
export pppstatus=""
watch_dsl_line() {
old_dslpkts=$dslpkts
dslpkts=`netstat -f link -I $dslif | cut -w -f 5 | tail -n 1`
if [ $dslpkts -le $old_dslpkts ]
then \
dslfails=`expr $dslfails \+ 1`
if [ $dslfails -gt 1 ]
then \
echo "`date`: ERROR DSL Line inactive, stopping"
service ppp stop
fi
else \
echo "`date`: WARNING DSL Line catched up"
dslfails=0
fi
}
start_dsl_line() {
dslfails=0
echo "`date`: WARNING PPP was not running, starting"
service ppp start
}
while true
do \
sleep 30
pppstatus="`service ppp status`"
case "$pppstatus" in
"ppp is not running." ) start_dsl_line ;;
"ppp is running as pid"* ) watch_dsl_line ;;
esac
done
/etc/rc.d/watch_ppp_service
Code:
#!/bin/sh
# PROVIDE: watch_ppp_service
# REQUIRE: NETWORKING
. /etc/rc.subr
name="watch_ppp"
rcvar="watch_ppp_enable"
start_cmd="start_watch_ppp"
start_watch_ppp() {
/usr/sbin/daemon -o /var/log/watch_ppp.log /root/bin/watch_ppp.sh
}
load_rc_config $name
run_rc_command "$1"