#!/bin/sh###################################################### NUMBER OF REBOOTS TO PERFORM IF PPPOE HAS NO IPv4 ######################################################rebootnr=10;###################################################sleep 60dtstart=$(date '+%d/%m/%Y %H:%M:%S');echo "Started at $dtstart" > /root/pppoerebootlog.txt[ -e /root/pppoerebootcount.txt ] || echo "0" > /root/pppoerebootcount.txt; pppoeif=$(ifconfig pppoe0 | grep "inet ")if [ ! -z "$pppoeif" ]; then echo "IPv4: $pppoeif" >> /root/pppoerebootlog.txt; echo "0" > /root/pppoerebootcount.txt; else pppoerebootcount=$(head -1 /root/pppoerebootcount.txt); echo $(((pppoerebootcount+=1))) > /root/pppoerebootcount.txt;fisleep 1pppoerebootcount=$(head -1 /root/pppoerebootcount.txt);if [ "$pppoerebootcount" -gt "0" ] && [ "$pppoerebootcount" -le "$rebootnr" ]; then echo "$dtstart PPPoE down, rebooting..." > /root/pppoe_lastreboot.txt echo "PPPoE down, rebooting..." >> /root/pppoerebootlog.txt sleep 1 rebootelse if [ "$pppoerebootcount" -le "$rebootnr" ]; then echo "Franco, all good, PPPoE is up, no need to reboot" >> /root/pppoerebootlog.txt else echo "We reached the max number of reboots!" >> /root/pppoerebootlog.txt fifi
[pppoereboot]command:/root/pppoe.shparameters:type:scriptmessage:Check if PPPoE is down, reboot if it isdescription:Check if PPPoE is down, reboot if it is