Homemade laptop lojack: ping website early in boot process

James Gray james at gray.net.au
Sun Jul 6 21:29:17 UTC 2008


On 07/07/2008, at 7:16 AM, James Gray wrote:
> On 07/07/2008, at 5:08 AM, Dotan Cohen wrote:
>
>> I'd like to have my laptop try to ping a website that I control as
>> early in the boot process as possible, preferably as soon as the wifi
>> is enabled. How is this done? Thanks.
>
> How about, as soon as the interface is up...soon enough? ;)
>
> man interfaces
> ...
> IFACE OPTIONS
> ...
>        post-up _command_
>               Run command after bringing the interface up.  If this
>               command fails then ifup aborts, refraining from marking
>               the interface as configured (even though it has really
>               been configured), prints an error message, and  exits
>               with status 0.  This behavior may change in the future.
>
> The easiest way to avoid the potential "if the command fails"...you
> simply wrap the whole ping up in a script that returns zero and
> execute that script as the post-up command.  In pure Debian land,
> there is a directory "/etc/network/if-post-up.d" which will execute
> all the scripts in it when an interface comes up (not sure if Ubuntu
> support this method though as the directory doesn't exist on my
> systems).

Poor form replying to my own post...but if I'd been smarter I'd have  
read the rest of the text on the man page:

"There exists for each of the above mentioned options a directory /etc/ 
network/if-<option>.d/ the scripts in which are run (with no  
arguments) using run-parts(8) after the option itself has been  
processed."

So Ubuntu *does* support the Debian-style up/down pre/post directory  
structures.  There are also a raft of environment variables passed to  
the commands in both the "interfaces" file and /etc/network/if- 
<option>.d/ scripts which may prove to be useful.

Cheers,

James

PS. I shall now go and slap myself around with a large, wet, trout  
while chanting the mantra "RTFM, RTFM"





More information about the ubuntu-users mailing list