Skip to content

Universal station tooling: multi-camera conversion in FirstRun, unified StartCapture - #948

Open
Cybis320 wants to merge 17 commits into
prereleasefrom
multicam-station-tooling
Open

Universal station tooling: multi-camera conversion in FirstRun, unified StartCapture#948
Cybis320 wants to merge 17 commits into
prereleasefrom
multicam-station-tooling

Conversation

@Cybis320

Copy link
Copy Markdown
Contributor

This PR packages the multi-camera data structure work proposed by Peter E. on the forum, submitted on his behalf. It is the "proper pull request" promised in the June revert (c91ba9e), updated with the improvements from Pete's revised proposal (his Upgrade.zip).

What this does

RMS_FirstRun.sh

  • Automatically checks whether the root file system fills the storage device. If not, one keypress runs raspi-config --expand-rootfs and reboots — no more navigating raspi-config menus. Warns if the device itself is below the 64 GB minimum.
  • Prompts for station ID, latitude, longitude and elevation directly at the terminal, with validation, instead of opening the whole config file in an editor.
  • At the end of setup, offers conversion to the multi-camera data structure (with a confirmation on decline), then chains to add_Station.sh.
  • Assorted cleanups: never overwrites an existing SSH key (GMN has the public half on file), internet check falls back to HTTPS when ping is blocked, file-system expansion step is skipped on non-Pi systems.

Scripts/add_Station.sh (new, universal — replaces the Pi/Linux split)

  • Creates stations under ~/source/Stations/<ID>, interactively or in bulk from a CSV (stations_template.csv sample included).
  • Converts a legacy single-camera install: .config, mask.bmp and platepar_cmn2010.cal are copied to the station directory and existing data is moved under ~/RMS_data/<ID>. Nothing in ~/source/RMS is modified — the conversion never deletes, rewrites or re-downloads files in the RMS root.
  • The Pi camera-count limits (1, or 4 on a Pi5) are advisory with an override rather than hard exits.
  • add_Pi_Station.sh and add_GStation.sh remain as thin compatibility wrappers, answering the naming concern Pete raised: the tool now lives at Scripts/add_Station.sh. Renaming the MultiCamLinux/ directory itself is left for later so deployed entry points keep working.

Scripts/RMS_StartCapture.sh

  • Now works on both data structures, as Pete's revised RMS_StartCapture2.sh proposed: if station directories exist under ~/source/Stations it starts each one in its own terminal (staggered 70 s on multi-camera systems so concurrent first-start updates cannot collide, 2 s when there is only one station); otherwise it starts the legacy single camera as before.
  • RMS_StartCapture_MCP.sh becomes a compatibility wrapper, and add_Station.sh no longer needs to retarget the Desktop shortcut after a conversion.

Testing

  • Pete tested his revised scripts end-to-end on a freshly flashed Bullseye image on a Pi4 (terminal transcripts posted on the forum).
  • The reworked universal scripts were exercised in a sandboxed environment (isolated $HOME with shims) covering the legacy-to-multicam conversion, interactive station creation and the CSV bulk flow.
  • A full interactive run of this exact branch on a freshly flashed Pi image is still outstanding — testers with a spare SD card are very welcome.

Credits

  • Peter E. — original conversion proposal, the revised scripts this PR incorporates, and Pi testing.
  • Ed Harman — the original MultiCamLinux tooling this builds on.

Cybis320 added 17 commits July 28, 2026 10:59
RMS_FirstRun now offers a double-confirmed step 5 that converts new
installs to the Stations data structure by chaining to add_Pi_Station.sh.

add_Pi_Station.sh changes:
- Support single-camera platforms (RPi4 and older) with MaxStation=1
  instead of refusing to run; skip multi-camera-only tweaks (wayfire
  cascade, reboot disable, extra_space scaling) on those systems
- Migrate camera_settings.json to the station folder and point
  camera_settings_path at it
- Move all existing captured data (including hidden files) with find
  instead of a hardcoded list, avoiding the mv-into-itself error
- Restore pristine defaults via git checkout with a wget fallback so an
  offline run cannot delete .config without a replacement
- Add an Edit_configs desktop helper for editing station configs

RMS_StartCapture_MCP.sh starts a single-camera system with a 2 s delay
instead of 70 s; the long delay is only needed to serialize first-start
updates across multiple stations.

Autorun is now enabled only after the optional conversion finishes so an
interrupted conversion is not skipped over by the autorun path on the
next boot.
Stations can now be created in bulk from a stations.csv file. The header
row names the columns: station_id (required), camera_ip (spliced into
the rtsp device URL), and any other .config key, which is applied
verbatim to the station config. Usage:

  add_GStation.sh [RMS_data_path] [stations.csv]

With no arguments the script uses ~/source/RMS/stations.csv if present
(the file is gitignored), otherwise it falls back to the previous
interactive prompts, so the GRMSL_Install.sh flow keeps working.
Desktop and autostart entries now use gnome-terminal (an optional
StartCapture profile customises the windows) instead of installing and
configuring lxterminal.

Robustness fixes over the old version: config seds are anchored at line
start so commented examples are not rewritten, CSV fields are trimmed
without xargs (handles CRLF endings and quotes in values), a final CSV
row without a trailing newline is not dropped, and the CMNbinViewer
icon points at the RMS copy instead of a cmn_binviewer path that only
exists via an install-time symlink.

The script is also slimmed down to station creation: the GNOME
sleep/screen-lock prevention moved to RMS_Installer.sh as one-time
machine setup (guarded for headless installs), the duplicated UTC
timezone setting is dropped (RMS_Installer.sh already does it), and the
interactive optional installs (pcmanfm, mousepad, AnyDesk), cron-based
update scheduling, and AnyDesk Wayland workaround are removed.
add_Pi_Station.sh and add_GStation.sh duplicated the same station
creation logic with platform assumptions baked in, and the copies had
drifted (different extra_space factors, entry names, and bug fixes
applied to one but not the other). Both are now thin compatibility
wrappers around a single universal Scripts/MultiCamLinux/add_Station.sh
that works on any Linux platform, Raspberry Pi included:

- Platform detection reads /sys/firmware/devicetree/base/model instead
  of uname/lscpu, so 32-bit Pi installs are detected and can migrate too
- The Pi camera limit (1, or 4 on a Pi5 or later) is now advisory: the
  script warns that it is the tested ceiling and lets the operator
  override it, instead of hard-stopping. Future more capable Pis and
  experiments are not blocked. Generic Linux has no limit, as before
- The legacy single-camera relocation is universal, so a PC that was set
  up as a single camera can convert just like a Pi. Pi image cosmetics
  (conky, wayfire, image desktop shortcuts) only run when the files
  exist
- Launch entries use whichever of lxterminal/gnome-terminal fits the
  desktop. On FirstRun-managed systems (the Pi images) captures are
  started by RMS_StartCapture_MCP.sh as before; elsewhere per-station
  XDG autostart entries start captures at login
- CSV-driven bulk creation and the interactive prompts are available on
  every platform

RMS_FirstRun.sh now offers the conversion on any platform that has not
converted yet (the raspi-config step is skipped where raspi-config does
not exist, and the config editor falls back to gedit/gnome-text-editor
on GNOME), and chains to add_Station.sh, which shows the relocation
details and asks the final confirmation. RMS_StartCapture_MCP.sh picks
the terminal emulator the same way.
Instead of opening the whole .config in a GUI editor (leafpad, mousepad,
or whatever the desktop provides) and grep-checking afterwards that the
station ID was changed, FirstRun now asks for the four values it needs -
station ID, latitude, longitude, elevation - right at the terminal,
validates them (GMN code format with an override, numeric ranges for the
coordinates), shows a summary to confirm or re-enter, and writes them
into .config with anchored seds. EOF on any prompt aborts the script
instead of looping. The RMS_config desktop shortcut remains the way to
edit any other setting.
- RMS_FirstRun no longer overwrites an existing SSH key: the public half
  is already on file with GMN, so regenerating it on a re-run would
  silently break the data uploads. The Desktop link uses ln -sf so a
  re-run does not error either
- The successful autorun path exits 0 instead of 1
- The updater is invoked directly from Scripts/ instead of through the
  Desktop symlink (the StartCapture symlink stays, it is retargeted by
  add_Station.sh on purpose)
- The internet check falls back to an HTTP probe of github.com when
  ping is blocked, since GitHub is what the update needs to reach anyway
- The init message no longer promises 10 seconds while sleeping 12
- Prompts that accepted any key to skip no longer claim Q is special
- Removed the unused delay_by_station_sequence() from StartCapture.sh
The template shows the CSV format add_Station.sh reads: station_id,
camera_ip, and any .config key as further columns (capture_wait_seconds
here, which staggers the capture start across cameras). Copy it to
~/source/RMS/stations.csv (gitignored) and edit. The script's usage and
error messages point to it.
The XDG-autostart-vs-Desktop-entry choice keyed on the autorun flag
alone, but a PC that converts through RMS_FirstRun also carries that
flag - and nothing launches FirstRun at boot on a PC, so such systems
ended up with no automatic capture start at all. The Pi-image behavior
(Desktop entry only, MCP starts captures at boot) now additionally
requires Pi hardware; everything else gets autostart entries.

The Desktop RMS_StartCapture.sh symlink is retargeted to the
multi-camera launcher unconditionally - after any conversion the legacy
script it pointed at would read the reset template config.

Also create ~/.config/autostart and the Desktop dir inside
create_station: the migration path runs before the main-flow mkdirs, so
the autostart entry write could fail silently.
A universal tool does not belong in the MultiCamLinux subdirectory; it
now sits next to RMS_Installer.sh and RMS_FirstRun.sh. The runtime
launchers (StartCapture.sh, LiveStream.sh, RMS_StartCapture_MCP.sh)
stay in MultiCamLinux/ because desktop entries on deployed systems
reference those paths. Compatibility wrappers and FirstRun updated.
The legacy conversion used to mutate the repo working tree: it deleted
the root .config and re-downloaded it from GitHub (leaving no config at
all when offline), moved mask.bmp and platepar out, and the
camera_settings.json move had been proposed too. None of that is the
station tool's business - RMS_Update already owns the lifecycle of the
root .config/mask.bmp/camera_settings.json (backup, reset, restore),
and camera_settings.json is shared by all stations from the root by
default (every station's camera_settings_path points there).

The conversion now only COPIES .config, mask.bmp and platepar into
~/source/Stations/<ID> and moves the captured data under
~/RMS_data/<ID>. Nothing in ~/source/RMS is created, modified or
deleted - no git commands, no downloads. The root files keep the
operator's values and remain the templates for adding further
stations.
Instead of walking the user through the raspi-config menus, measure the
root file system against the device it lives on and offer a one-key
expansion (raspi-config --expand-rootfs) followed by an automatic
reboot. If the device is already fully used but below the 64 GB minimum,
warn about it instead of offering an expansion that would do nothing.

Based on Peter E.'s revised first-run proposal.
RMS_StartCapture.sh now detects the multi-camera structure (station
directories under ~/source/Stations) and starts every configured station
itself, staggered as before, falling back to the legacy single-camera
start otherwise. RMS_StartCapture_MCP.sh becomes a compatibility wrapper
for Desktop shortcuts created by older installs, and add_Station.sh no
longer needs to retarget the Desktop entry after a conversion.

Based on Peter E.'s revised proposal (RMS_StartCapture2.sh).
@dvida
dvida requested review from g7gpr and markmac99 August 4, 2026 17:31
@markmac99

Copy link
Copy Markdown
Contributor

I'll review this as soon as i can but not likely to be before 20th Aug as we're on holiday from 11th and i have a bunch of other GMN work to finish this week.
In principle as described all seems good stuff.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants