Files
forgefirm/meta-forgefirm/recipes-forgefirm/gfcloud/files/gfcloud.init
T
ScottW514 abf85fccfe Add the gfcloud full-cloud controller daemon
gfcloud runs the machine under the Glowforge web service (the factory
cloud experience: the app drives homing, framing, printing). Its init
service starts it only when controller_mode = cloud - mutually exclusive
with grblHAL, which already stands down for that mode - so it owns
/dev/glowforge exclusively. Persistent GFUIService loop with a clean
SIGTERM shutdown that safes the hardware; the init script mirrors
grblhal.init. The image installs gfcloud and python3-ffmachine.
2026-08-08 19:08:13 -04:00

50 lines
1.2 KiB
Bash

#!/bin/sh
### BEGIN INIT INFO
# Provides: gfcloud
# Required-Start: $local_fs $network
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Glowforge web-service controller (full cloud mode)
### END INIT INFO
DAEMON=/usr/sbin/gfcloud.py
PIDFILE=/var/run/gfcloud.pid
CONF=/data/forgefirm.conf
# Boot-time controller-mode dispatch, mirror of grblhal.init: this daemon
# runs the machine under the Glowforge web service. It starts only when
# controller_mode = cloud (which keeps grblHAL down); anything else - grbl,
# unset, or no config file - leaves it stopped.
controller_mode() {
[ -r $CONF ] || { echo grbl; return; }
m=$(sed -n 's/^[ \t]*controller_mode[ \t]*=[ \t]*\([a-z]*\).*/\1/p' $CONF | tail -n 1)
echo "${m:-grbl}"
}
case "$1" in
start)
if [ "$(controller_mode)" != "cloud" ]; then
echo "gfcloud not started (controller_mode != cloud)"
exit 0
fi
echo "Starting gfcloud"
start-stop-daemon -S -q -p $PIDFILE -m -b -x $DAEMON
;;
stop)
echo "Stopping gfcloud"
start-stop-daemon -K -q -p $PIDFILE
rm -f $PIDFILE
;;
restart)
$0 stop
sleep 2
$0 start
;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 1
;;
esac
exit 0