• 3 Posts
  • 6 Comments
Joined 1 year ago
cake
Cake day: December 30th, 2023

help-circle






  • Nice. I will try the systemd unit. Meanwhile, i have added a loop in the script, which helps a little bit:

    maxwait=15
    if [[ $(nm-online -x) != *"online"* ]]; then
    	echo "missing internet connection, waiting..."
    	for (( i = 1; i <= maxwait; ++i )); do
    		sleep 1 &
    		echo $i
    		if [[ $(nm-online -x) == *"online"* ]]; then
    			break
    		fi
    
    		if [[ $i -eq $maxwait ]]; then
    			echo "No internet connection"
    			exit 1
    		fi
    		wait
    	done 
    fi
    

    In my test, this exits the script after 15 seconds without connection, but continues, when the connection is available or is established within this time.

    But i think, its a nice idea, to add this to the script AND use the systemd unit together.