Last active
August 29, 2015 13:56
-
-
Save MarcelloDuarte/9018637 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env php | |
<?php | |
function restart_web($interface) { | |
passthru("ifconfig $interface down"); | |
passthru("ifconfig $interface up"); | |
sleep(5); | |
} | |
function ping($host) { | |
return (boolean) @fsockopen($host, 80, $errno, $errstr, 10); | |
} | |
while(1) { | |
sleep(2); | |
if (!ping("www.google.co.uk")) { | |
echo "Looks like the connection is down. Let me restart it for you...\n"; | |
restart_web("en0"); | |
continue; | |
} | |
echo "Looking good\n"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment