In a Thingino-powered network setup, every camera can be configured to automatically register via MQTT and record video directly to an NFS share using a small script added to /etc/rc.local on each device. This approach centralizes control and customization, allowing you to modify behavior for all cameras from a single server.
This file can be included in each firmware build by including the modified rc.local file in thingino-firmware/overlay/upper/etc/rc.local
-
On Each Camera:
- A simple script is added to
/etc/rc.localto execute custom behavior at boot by fetching a script from the central server.
- A simple script is added to
-
On the Central Server:
- A customizable script,
rc-local-camera.sh, handles mounting NFS shares and starting camera-specific processes.
- A customizable script,
The /etc/rc.local file ensures the camera fetches and executes the server-provided script at boot:
#!/bin/sh
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
curl -sSL http://router.lan/rc-local-camera.sh | sh
exit 0curlCommand: Downloads and executes therc-local-camera.shscript from the central server.- Dynamic Behavior: Cameras automatically adopt updated scripts without requiring individual configuration changes.
This script defines camera behavior and is served from the central server:
#!/bin/sh
# Mount shared NFS directories
mkdir -p /mnt/nfs_root
mount -t nfs -o rw,async,noatime,nolock,rsize=1048576,wsize=1048576 \
router.lan:/mnt/backup/nfs_root /mnt/nfs_root
mkdir -p /mnt/nfs
mount -t nfs -o rw,async,noatime,nolock,rsize=1048576,wsize=1048576 \
router.lan:/mnt/HomeAssistant/media/record/$(hostname)/ /mnt/nfs
# Start recording and MQTT registration
/mnt/nfs_root/sbin/ffmpeg-record.sh &
/mnt/nfs_root/sbin/mqtt-full.sh $(hostname)-
NFS Mounts:
- Mounts a shared root NFS directory (
/mnt/nfs_root). - Mounts a camera-specific NFS directory (
/mnt/nfs), dynamically named based on the camera’s hostname.
- Mounts a shared root NFS directory (
-
Recording and MQTT Registration:
ffmpeg-record.sh: Starts video recording directly to the mounted NFS directory.mqtt-full.sh: Registers the camera with the MQTT broker using the camera’s hostname.
-
Custom Behavior via
hostname:- Allows per-camera customization based on hostname, configured dynamically by the server script.
-
Centralized Management:
- Update camera behavior by modifying the server script without physically accessing each device.
- Push custom configurations or updates instantly to all cameras.
-
Dynamic Per-Camera Behavior:
- Use the hostname to customize NFS paths, recording settings, or MQTT topics for individual cameras.
-
Scalability:
- Add new cameras by simply pointing their
/etc/rc.localto the server’s script. No manual configuration required.
- Add new cameras by simply pointing their
-
Ease of Maintenance:
- No need to log into each camera to make changes.
- A single script update propagates to all devices.
- Home Automation Integration:
- Cameras record to an NFS share accessed by Home Assistant for media storage.
- MQTT messages from cameras trigger automations, such as motion alerts or snapshot processing.