Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
network-rescue / usr / local / lib / network-rescue / check-online.sh
Size: Mime:
#!/usr/bin/env bash

if [ "$(id -u)" != "0" ]; then
	echo "This script must be run as 'root'"
	exit 1
fi

echo `date "+%Y%m%d %T"`
# TODO Add retry
echo -e "GET http://google.com HTTP/1.0\n\n" | nc google.com 80 > /dev/null 2>&1
if [ $? -eq 0 ]; then
	echo "Online"
else
	echo "Offline"
	logger Rebooting OS by check-online.sh due to no access to Internet
	shutdown -r +1
fi