Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Is there a way in upstart to code an event to start when network connectivity to a specific machine becomes available? Something based on a ping result would work in my case. The task being started will crash if networking dies, so respawn can start it easily enough, but if the network connection isn't available when it starts it will hang and upstart won't catch it (it's an ffmpeg instance streaming from the local ffserver to another ffserver if that helps highlight the use case).

share|improve this question
add comment

1 Answer

If you know the IP address of the machine you can confirm it's the 'right' machine by confirming the MAC address with something like:

arp -an 192.168.1.123

You will likely need to ping it first so that arp can find it.

Here's a script I'm using that does the same thing:

#!/bin/bash

ip=192.168.1.123 
mac=00:aa:bb:cc:dd:ee


if ping -c 1 -t 1 ${ip} > /dev/null && arp -an ${ip} | grep ${mac}; then
    echo "${ip} has the expected mac addy." 

    # Mount my nfs share (requires sudo, but whatever)
    mount -t nfs -o proto=tcp,port=2049 ${ip}:/ /mnt 
else
    echo "This isn't the network I'm looking for."   
fi
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.