# systemd unit for Fire Gimbal Control - a TEMPLATE. scripts/install-tower fills # in the @...@ fields and installs it; to do it by hand, replace them and copy it # to /etc/systemd/system/, then: # sudo loginctl enable-linger # see below - not optional # sudo systemctl daemon-reload && sudo systemctl enable fire-gimbal-control # # The unit runs the program through scripts/fgc, inside tmux, so a tower started # at boot still has the dashboard: `scripts/fgc attach` from any ssh session. # fgc returns once the program is up, hence oneshot + RemainAfterExit; stopping # the unit runs `fgc stop`, which shuts the camera and motors down cleanly. # # Lingering: without it /run/user/ does not exist until someone logs in, so # a program started at boot takes its single-instance lock in /tmp, and a later # ssh session looks in /run/user, finds nothing, and `fgc status` says it is not # running - while a second copy could start beside it. # # @ARGS@ is normally empty. Whether the program homes and the mode it starts in # are config.ini [Startup] home / mode, not arguments (the program refuses the # old --init / --start). The firmware keeps no position across a power cycle, so # a tower in service has home = true - and HOMES UNATTENDED at every boot. # # MQTT credentials: /etc/fire_gimbal_control/credentials.env (FGC_MQTT_USER, # FGC_MQTT_PW), read by fgc inside the tmux pane rather than passed through this # unit - a tmux server that already exists would not hand a new session the # unit's environment. [Unit] Description=Fire Gimbal Control After=network-online.target Wants=network-online.target [Service] Type=oneshot RemainAfterExit=yes User=@USER@ WorkingDirectory=@REPO@ ExecStart=@REPO@/scripts/fgc start @ARGS@ ExecStop=@REPO@/scripts/fgc stop TimeoutStartSec=120 # Longer than `fgc stop` itself waits (120 s) for the program's clean shutdown: # past this systemd kills it outright, which wedges the camera for the next run. TimeoutStopSec=150 [Install] WantedBy=multi-user.target