Skip to content

Commit 1f8da85

Browse files
committed
fix(install): survive a reboot
Two independent reasons the bridge stayed down after a reboot, both found by actually rebooting a Venus device instead of reading the script: - /service is a tmpfs, so the symlink is gone at boot and rc.local re-runs install.sh. The old check ('no symlink' = first install) then dropped the 'down' marker again and supervise left the bridge off. A persistent .installed marker now separates a genuine first install from a boot re-entry; uninstall.sh removes it again. - Venus only executes /data/rc.local when it carries the executable bit (/etc/init.d/custom-rc-late.sh). install.sh only chmod'ed the file when it created it, so an existing 0644 rc.local disabled the autostart silently. It is now chmod'ed on every install. Verified by two reboots of the testberry: before the fix no service and no /run/venus/custom-rc marker, after it the bridge was up 35 seconds after boot with DeviceInstances 49/55/56 and its counters unchanged.
1 parent 33c3f05 commit 1f8da85

3 files changed

Lines changed: 38 additions & 9 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,14 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
4646
write, so no migration step is needed.
4747

4848
### Fixed
49+
- **The bridge now survives a reboot.** `/service` is a tmpfs, so rc.local
50+
re-runs `install.sh` on every boot - and that looked like a first install,
51+
which dropped the `down` marker again and left the bridge off until someone
52+
noticed the chargers missing in VRM. A persistent `.installed` marker now
53+
tells the two cases apart.
54+
- `install.sh` makes `/data/rc.local` executable on every run. Venus only runs
55+
it when it is (`/etc/init.d/custom-rc-late.sh`: `if [ -x /data/rc.local ]`),
56+
and a non-executable file silently disabled the autostart.
4957
- `service/run` no longer restarts the bridge in a tight loop after a
5058
configuration error. daemontools respawns immediately, and that spin is
5159
enough to trip the Venus load watchdog (`/etc/watchdog.conf`: `max-load-5 =

‎install.sh‎

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,29 +11,47 @@ chmod 755 "$SCRIPT_DIR/service/run" "$SCRIPT_DIR/service/log/run"
1111
# Ensure log directory exists (multilog needs it writable)
1212
mkdir -p "/data/log/$SERVICE_NAME"
1313

14-
# Symlink into daemontools. On FIRST install we drop a 'down' marker so
14+
# Symlink into daemontools. On the FIRST install we drop a 'down' marker so
1515
# supervise does not auto-start the bridge before the operator has run
16-
# seed_state.py (otherwise fresh DIs get allocated and the legacy title->DI
17-
# mapping is lost). On re-install (e.g. rc.local re-entry after reboot) the
18-
# symlink already exists -> no 'down' file is created -> service comes back up.
16+
# seed_state.py (otherwise fresh DeviceInstances get allocated and the legacy
17+
# title->DI mapping is lost).
18+
#
19+
# /service is a tmpfs, so after a reboot the symlink is gone and rc.local runs
20+
# this script again. That must NOT look like a first install - it used to drop
21+
# the 'down' marker again and the bridge stayed off until someone noticed the
22+
# chargers missing in VRM. The marker file below survives the reboot and tells
23+
# the two cases apart.
24+
INSTALL_MARKER="$SCRIPT_DIR/.installed"
1925
if [ ! -L "/service/$SERVICE_NAME" ]; then
20-
touch "$SCRIPT_DIR/service/down"
21-
ln -s "$SCRIPT_DIR/service" "/service/$SERVICE_NAME"
22-
echo "Created /service/$SERVICE_NAME (in 'down' state - not running yet)"
23-
FIRST_INSTALL=1
26+
if [ -f "$INSTALL_MARKER" ]; then
27+
rm -f "$SCRIPT_DIR/service/down"
28+
ln -s "$SCRIPT_DIR/service" "/service/$SERVICE_NAME"
29+
echo "Re-created /service/$SERVICE_NAME after reboot (service will start)"
30+
FIRST_INSTALL=0
31+
else
32+
touch "$SCRIPT_DIR/service/down"
33+
ln -s "$SCRIPT_DIR/service" "/service/$SERVICE_NAME"
34+
echo "Created /service/$SERVICE_NAME (in 'down' state - not running yet)"
35+
FIRST_INSTALL=1
36+
fi
2437
else
2538
echo "Service symlink already exists, skipping"
2639
FIRST_INSTALL=0
2740
fi
41+
touch "$INSTALL_MARKER"
2842

2943
# Persist across firmware updates via rc.local
3044
filename=/data/rc.local
3145
if [ ! -f "$filename" ]; then
3246
touch "$filename"
33-
chmod 755 "$filename"
3447
echo "#!/bin/bash" >> "$filename"
3548
echo >> "$filename"
3649
fi
50+
# Venus only runs /data/rc.local when it is executable
51+
# (/etc/init.d/custom-rc-late.sh: `if [ -x /data/rc.local ]`). An existing but
52+
# non-executable file is the silent way to lose the bridge after a reboot, so
53+
# fix the mode on every install, not just when we create the file.
54+
chmod 755 "$filename"
3755
grep -qxF "$SCRIPT_DIR/install.sh" "$filename" || echo "$SCRIPT_DIR/install.sh" >> "$filename"
3856

3957
# The legacy single-loadpoint bridges leave their own line in rc.local; their

‎uninstall.sh‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ fi
7171

7272
# Reset any leftover 'down' marker so a re-install starts cleanly
7373
rm -f "$SCRIPT_DIR/service/down"
74+
# Forget that we were ever installed, so a later install.sh starts from the
75+
# guarded first-install path again instead of coming straight up.
76+
rm -f "$SCRIPT_DIR/.installed"
7477

7578
echo
7679
if [ "$FAILED" = "0" ]; then

0 commit comments

Comments
 (0)