Hi,
I have been reading back through the thread, and I can see that a number of things have been suggested & tried. Sorry that this is not as straightforward as it should be. First of all, could I clarify some things so that we can get a new start point, as there are a few points I think need clarifying:
- Are you running on macOS, Windows or Linux?
Line endings can get borked on Windows when using GIT and that can impact how Linux systems operate when using those files.
- Are you always running/testing by pushing the above compose/dockerfiles to a balenaCloud app?
It isnât clear because you mentioned ...solution doesnât seem to work if youâre running inside a container and using dbus
so I just want to be 100% sure of the scenario here.
- Without modifying the
wifi-connect
source/UI it works 100% as expected?
This will help in terms of determining the delta between a working setup and a customised one.
Thanks, I hope we can all sort this one out for you
I seem to have FINALLY figured it out lol. Taking bits and pieces from suggestions would work sometimes but then not work with one another. I have now confirmed that it will work for multiple networks each time. I have tested 3 different networks now.
From the top:
Dockerfile compose
wifi-connect:
build: ./wifi-connect
network_mode: "host"
restart: always
privileged: true
labels:
io.balena.features.dbus: '1'
io.balena.features.firmware: '1'
DO NOT ADD ANYTHING EXTRA. No environment, no cap-add, nothing. Regardless of what the wifi-connect github says in its readme.
Dockerfile
FROM balenalib/%%BALENA_MACHINE_NAME%%-ubuntu:latest
ENV DBUS_SYSTEM_BUS_ADDRESS=unix:path=/host/run/dbus/system_bus_socket
RUN sudo apt-get -y update && \
sudo apt-get -y install dnsmasq wireless-tools && \
sudo apt-get clean && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
WORKDIR /usr/src/wifi-connect
RUN curl https://api.github.com/repos/balena-io/wifi-connect/releases/latest -s \
| grep -hoP 'browser_download_url": "\K.*%%BALENA_ARCH%%\.tar\.gz' \
| xargs -n1 curl -Ls \
| tar -xvz -C /usr/src/wifi-connect/
WORKDIR /usr/src/wifi-connect/
COPY start.sh ./
COPY ui ui
CMD ./start.sh
I tried to use the raspberry pi image but that didnât want to work. I suspect it doesnât include everything for dbus? I even installed dbus as a install_package.
start.sh
#!/usr/bin/env bash
export DBUS_SYSTEM_BUS_ADDRESS=unix:path=/host/run/dbus/system_bus_socket
sleep 10
while [[ true ]]; do
# 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?
iwgetid -r
if [ $? -eq 0 ]; then
printf 'Skipping Wifi-Connect\n'
else
printf 'Starting Wifi-Connect\n'
./wifi-connect --ui-directory ui -a 600 -s Custom-SSID -o 80
fi
sleep 5
done
For some reason --ui ./ui
was not going to work but --ui-directory ui does.
Also, be sure to use option 4 in the start.sh as shown above. The default options cause problems for me.
1 Like
Nice! Thanks for updating this thread for anybody running into this in the future