Greetings! This is my first forum post and I am a relative NOOB when it comes to the Pi. I have a 3b running the latest version of Raspberry Pi OS. I have a script set up to run at startup which checks for network connectivity. If a valid ping of Google occurs then a local web page is opened in kiosk mode. If a valid ping does not occur then the web page does not open. When I execute this script from the command line it behaves as expected. However, when I reboot the Pi and let it run the web page opens in kiosk mode when I do not have a valid network connection. Below is the script I am running:
#!/bin/bash
ping -c 1 8.8.8.8 > /dev/null 2>&1
if [ $? -eq 0 ]; then
sudo -u pi chromium-browser --kiosk --incognito http://localhost/index.php
fi
Why does the page open when the network is down when the script is called during boot, but works properly when run from the command line?