diff options
author | Erich Eckner <git@eckner.net> | 2020-10-10 20:08:55 +0200 |
---|---|---|
committer | Erich Eckner <git@eckner.net> | 2020-10-10 20:08:55 +0200 |
commit | fb789e7d52cc67d3f5a3e713a355e121e772ebcb (patch) | |
tree | 362526a14dcf4361ec113ed84af5ae1e4f514841 /reboot-if-no-net-connection | |
download | reboot-if-no-net-connection-fb789e7d52cc67d3f5a3e713a355e121e772ebcb.tar.xz |
initial commit
Diffstat (limited to 'reboot-if-no-net-connection')
-rwxr-xr-x | reboot-if-no-net-connection | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/reboot-if-no-net-connection b/reboot-if-no-net-connection new file mode 100755 index 0000000..bb8c43d --- /dev/null +++ b/reboot-if-no-net-connection @@ -0,0 +1,23 @@ +#!/bin/bash + +for i in {1..300}; do + + default_gateway=$( + ip route \ + | sed ' + s/^default\s\+\S\+\s\+\(\S\+\)\s.*$/\1/ + t + d + ' + ) + + if [ -n "${default_gateway}" ] \ + && ping -c1 "${default_gateway}" >/dev/null 2>&1; then + exit + fi + + sleep 1 + +done + +reboot |