5,337
edits
Line 452: | Line 452: | ||
TMP_FILE=/tmp/inet_up | TMP_FILE=/tmp/inet_up | ||
# Edit this function if you want to do something besides reboot | # Edit this function if you want to do something besides reboot | ||
no_inet_action() { | no_inet_action() { | ||
rm -f $TMP_FILE | if [ "$1" -eq 1 ]; then | ||
systemctl restart network-manager | |||
elif [ "$1" -ge 2 ]; then | |||
rm -f $TMP_FILE | |||
shutdown -r now "No Internet" | |||
fi | |||
} | } | ||
Line 464: | Line 467: | ||
echo 0 > $TMP_FILE | echo 0 > $TMP_FILE | ||
fi | fi | ||
oldnum= | oldnum=$(cut -d ',' -f2 $TMP_FILE) | ||
newnum= | newnum=$(("$oldnum" + 1)) | ||
sed -i "s/$oldnum\$/$newnum/g" $TMP_FILE | sed -i "s/$oldnum\$/$newnum/g" $TMP_FILE | ||
} | } | ||
Line 471: | Line 474: | ||
if ping -c5 google.com; then | if ping -c5 google.com; then | ||
echo 0 > $TMP_FILE | echo 0 > $TMP_FILE | ||
date > /tmp/inet_up_last_check | |||
else | else | ||
increment_tmp_file | increment_tmp_file | ||
oldnum= | oldnum=$(cut -d ',' -f2 $TMP_FILE) | ||
no_inet_action "$oldnum" | |||
fi | fi | ||
</syntaxhighlight> | </syntaxhighlight> | ||