Skip to content

Commit 46e20d5

Browse files
authored
Start PhotonVision after network.target is reached (#114)
PV tries to access networking information fairly early in the startup process and, when NetworkManager isn't ready, PV cannot get the information it needs about the network hardware. This PR configures the photonvision service to start after NetworkManager is running. The change is only made when PV is configured to manage networking. This should reduce the need for PhotonVision/photonvision#2240, but it's safer to have both.
1 parent 8698691 commit 46e20d5

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

install.sh

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ if grep -iq "systemcore" /etc/os-release; then
111111
fi
112112

113113
INSTALL_NETWORK_MANAGER="ask"
114+
DISABLE_NETWORKING="false"
114115
VERSION="latest"
115116

116117
while getopts "hlva:mnqt-:" OPT; do
@@ -228,7 +229,7 @@ DISTRO=$(lsb_release -is)
228229
# i.e. the distro is Ubuntu, you haven't requested disabling networking,
229230
# and you have requested a quiet install.
230231
if [[ "$INSTALL_NETWORK_MANAGER" == "ask" ]]; then
231-
if [[ "$DISTRO" != "Ubuntu" || -n "$DISABLE_NETWORKING" || -n "$QUIET" ]] ; then
232+
if [[ "$DISTRO" != "Ubuntu" || "$DISABLE_NETWORKING" == "true" || -n "$QUIET" ]] ; then
232233
INSTALL_NETWORK_MANAGER="no"
233234
fi
234235
fi
@@ -301,7 +302,6 @@ debug "Downloaded PhotonVision."
301302

302303
debug "Creating the PhotonVision systemd service..."
303304

304-
305305
if [[ -z $TEST ]]; then
306306
# service --status-all doesn't list photonvision on OrangePi use systemctl instead:
307307
if [[ $(systemctl --quiet is-active photonvision) = "active" ]]; then
@@ -317,6 +317,8 @@ if [[ -z $TEST ]]; then
317317
cat > /lib/systemd/system/photonvision.service <<EOF
318318
[Unit]
319319
Description=Service that runs PhotonVision
320+
# Uncomment the next line to have photonvision startup wait for NetworkManager startup
321+
# After=network.target
320322
321323
[Service]
322324
WorkingDirectory=/opt/photonvision
@@ -336,8 +338,12 @@ RestartSec=1
336338
WantedBy=multi-user.target
337339
EOF
338340

339-
if [ "$DISABLE_NETWORKING" = "true" ]; then
341+
if [[ "$DISABLE_NETWORKING" == "true" ]]; then
342+
debug "Adding -n switch to photonvision startup to disable network management"
340343
sed -i "s/photonvision.jar/photonvision.jar -n/" /lib/systemd/system/photonvision.service
344+
else
345+
debug "Setting photonvision.service to start after network.target is reached"
346+
sed -i "s/# After=network.target/After=network.target/g" /lib/systemd/system/photonvision.service
341347
fi
342348

343349
if grep -q "RK3588" /proc/cpuinfo; then

0 commit comments

Comments
 (0)