Create putty status display (service control)
sudo chmod +x /usr/local/bin/camera-status
#!/bin/bash
show_service()
{
local label="$1"
local unit="$2"
local active
local enabled
local state
active="$(systemctl is-active "$unit" 2>/dev/null || true)"
enabled="$(systemctl is-enabled "$unit" 2>/dev/null || true)"
if [ "$active" = "active" ]; then
state="ACTIVATED"
else
state="DEACTIVATED"
fi
printf "%-20s %-12s boot: %s\n" "$label:" "$state" "$enabled"
}
echo
echo "================ CAMERA STATUS ================"
show_service "Motion detection" "motion-camera.service"
show_service "Aim stream" "aim-camera.service"
show_service "Timelapse" "timelapse-camera.service"
echo
echo "Commands:"
echo " motion-on motion-off"
echo " aim-on aim-off"
echo " timelapse-on timelapse-off"
echo " camera-status"
echo "================================================"
echo
sudo chmod +x /usr/local/bin/camera-status
create the commands
nano ~/.bashrc
Append at the bottom
# Camera service commands
alias motion-on='sudo systemctl start motion-camera.service'
alias motion-off='sudo systemctl stop motion-camera.service'
alias aim-on='sudo systemctl start aim-camera.service'
alias aim-off='sudo systemctl stop aim-camera.service'
alias timelapse-on='sudo systemctl start timelapse-camera.service'
alias timelapse-off='sudo systemctl stop timelapse-camera.service'
alias camera-status='/usr/local/bin/camera-status'
# Show camera status when opening PuTTY/SSH.
if [[ $- == *i* ]]; then
/usr/local/bin/camera-status
fi
Now apply:
source ~/.bashrc