# 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 `--init --start`: the firmware keeps no position across a # power cycle, so without --init the gimbal sits un-homed and captures nothing. # --init also means the gimbal 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 TimeoutStopSec=60 [Install] WantedBy=multi-user.target