Last active
August 15, 2020 14:11
-
-
Save libbymiller/e8fe6821e122e0a0ac921c8e557320a9 to your computer and use it in GitHub Desktop.
A version of https://github.com/balena-io/wifi-connect/blob/master/scripts/start.sh for raspberry pis
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# export DBUS_SYSTEM_BUS_ADDRESS=unix:path=/host/run/dbus/system_bus_socket | |
# ^^^ this can cause barfing and isn't needed | |
# Choose a condition for running WiFi Connect according to your use case: | |
# 1. Is there a default gateway? | |
# ip route | grep default | |
# 2. Is there Internet connectivity? | |
# nmcli -t g | grep full | |
# 3. Is there Internet connectivity via a google ping? | |
# wget --spider http://google.com 2>&1 | |
# 4. Is there an active WiFi connection? | |
sleep 30s | |
iwgetid -r | |
if [ $? -eq 0 ]; then | |
printf 'Skipping WiFi Connect\n' | |
else | |
printf 'Starting WiFi Connect\n' | |
wifi-connect -o 7777 | |
fi | |
# Start your application here. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you! I've updated it to add in a delay (and also I'm running it on a different port).