View Single Post
Old 27th July 2009
jggimi's Avatar
jggimi jggimi is offline
More noise than signal
 
Join Date: May 2008
Location: USA
Posts: 7,983
Default

Quote:
Originally Posted by plexter View Post
Would you have an example? I have not determined how to check if the pppoe connection is active. I can tell if it has an IP address but that is all.
I don't use pppoe or ppp. So I don't know what your symptoms of "down" are. If pppoe and ppp cease operation, then your script can use pgrep(1) to determine if one or the other are running. If the daemons continue to run, your script could use your routing table (assuming the link drops), or ping(1), to determine if the network is operational.

My recommendation is to stop yanking on cables.

You can write a script myriad ways. Here are three examples, depending on what fails when you pull a cable.

Testing with pgrep:

#!/bin/sh
pgrep ppp > /dev/null || return
[your restarting script begins here...]

Testing with routing. No default route = link down:

#!/bin/sh
route -n show inet | grep default > /dev/null && return
[your restarting script begins here

Testing with ping:

#!/bin/sh
ping -c 1 [an external IP] > /dev/null || return
[your restarting script begins here... I'd use the most recent default gateway for the ping test, above, obtained from a route command]
Quote:
As of yet I seem to get no connection whenever the "proper" gateway is set.
I think you may misunderstand routing. The routing table requires directly addressable IP addresses. If the "proper" gateway is not on an addressable subnet or at the far end of the ppp connection, you break your routing table when you use it.
Reply With Quote