From cfcb9dc30437fe959e52f5847bc12819935d2bf5 Mon Sep 17 00:00:00 2001 From: Andrew Date: Mon, 23 Oct 2023 18:58:13 +0100 Subject: [PATCH] make keep_trying.sh poll repeatedly to see if connection has gone down --- keep_trying.sh | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/keep_trying.sh b/keep_trying.sh index 01079eb..164d524 100755 --- a/keep_trying.sh +++ b/keep_trying.sh @@ -1,3 +1,16 @@ #!/bin/sh -# one-lienr to attempt to connect to wifi network, and keep trying until it succeeds -nmcli con up || while [ "$?" != "0" ]; do nmcli con up ; done +# simple script to fix my broken wifi +# it checks if wifi is connected every 5 seconds, and if not, repeatedly attempts to connect + +network="" +interface="" + +while [ true ]; do + # if wifi is connected, do nothing for 5 seconds + if [ -n "$(nmcli connection show | grep '.*'"$network"'.*'"$interface"'.*')" ]; then + sleep 5 + # else, wifi is not connected so attempt to connect to wifi network, and keep trying until it succeeds + else + nmcli con up "$network" || while [ "$?" != "0" ]; do nmcli con up "$network"; done + fi +done