Balena wifi-connect running script after setup

Hello just after some ideas for how to run a script after making a connection using wifi-connect using python/bash command etc using a raspberry pi 3, buster

Currently, I have set up a bash command that checks connectivity on loop and executes wifi-connect if not found

In addition, I have a service script that waits for a network connection and starts a separate python script that I need to start each time the unit starts.

If starting the system with no connection wifi connect boots up and connects, however, the service script seems to kick off when the initial client network is created and doesn’t kick off after the initial connection is made again.

Likewise, if the network was already known, wifi-connect remembers the credentials and the script runs ok.

New to python so scratching my head trying to think of a way to only start the script after wifi-connect is confirmed to have found the network. but also not repeat its self every time my current script loops.

#!/bin/sh -e


sleep 15

while [[ true ]]; do

    echo "Checking internet connectivity ..."
    wget --spider --no-check-certificate > /dev/null 2>&1
    if [ $? -eq 0 ]; then
        echo "Your device is already connected to the internet."
        echo "Skipping setting up Wifi-Connect Access Point. Will check again in $freq seconds"
        echo "Your device is not connected to the internet."
        echo "Starting up Wifi-Connect.\n Connect to the Access Point and configure the SSID and Passphrase for the network to connect to."
        python3 /home/pi/iow/wifiSetup/ 

    sleep $freq


Hello @vernon

I havent’ tested that much but a developer from the community (@mithundotdas ) made a similar script that maybe you can test

Let us know if that works.

1 Like

Thanks for that mpous, looks like it might do the trick! Will have a play tomorrow :raised_hands:t3::raised_hands:t3::raised_hands:t3:

Let us know if that works!

1 Like

Hey just letting you know i havent forgotten and hope to test out the change in the coming weeks!