Open benjamink opened 9 months ago
Another option is to make start.sh
wait for pypi.org
to be available before running the pip install
. Something like this would work:
until ping -c1 -q pypi.org >/dev/null; do sleep 2; done;
This will just do a DNS query rather than try to communicate with the remote site:
until getent hosts pypi.org >/dev/null; do sleep 2; done;
Maybe something like:
for i in {1..30}; do
sleep 3
getent hosts pypi.org >/dev/null 2&>1 && break;
done
if [ $? -ne 0 ]; then
echo "DNS resolution failure - pypi.org"
ERROR=1
fi
This tries to resolve it 30 times with 3 second gaps between attempts, then exits with the above error.
Needs to go before line 33 (currently) where ERROR is checked.
Note: The sleep needs to occur before getent, else you'll be checking the exit value of the sleep command.
Note: Exiting if there is no internet might not be the best idea though, as this stops people being able to use the web interface on a local network that has no internet connection. Maybe putting something similar in a function and calling it when net is absolutely needed and spitting out a msg when it can't resolve the name instead.
A longer term way to fix this is proposed in #1153 , which aims to set up a proper pip local cache to avoid going to the net where possible.
Something changed with the Raspberry Pi Imager between v1.7.4 & v1.8.1 that seems to affect network startup & the 1st run of the
piscsi-web
service (which runspiscsi/python/web/start.sh
). The initialpip install
fails leaving thebjoern
package broken. Looking at the beginning of thepiscsi-web
log seems to indicatepip
can't access the Internet right away:This page talks about how to properly wait for networking to actually be available as a prerequisite in Systemd init scripts:
https://www.freedesktop.org/wiki/Software/systemd/NetworkTarget/
Steps to fix appear to be:
Enable the proper
systemd-networkd-wait-online.service
is enabledAdd a
Wants
line to thepiscsi-web.service
init so it looks like this: