From 4da39f6131bd4b38b002bb1b9c96cdf7ccbbdd87 Mon Sep 17 00:00:00 2001 From: ScottW514 Date: Fri, 7 Aug 2026 20:59:43 -0400 Subject: [PATCH] grblhal init: boot-time controller-mode dispatch The init script consults controller_mode in /data/forgefirm.conf: 'cloud' (once that mode exists, with its own service reading the same key) keeps grblHAL down; grbl, unset, or a missing config starts it. Board-verified both ways: cloud in the conf leaves the controller stopped with a clear message, grbl starts and serves normally. --- .../grblhal-glowforge/grblhal.init | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/meta-forgefirm/recipes-forgefirm/grblhal-glowforge/grblhal-glowforge/grblhal.init b/meta-forgefirm/recipes-forgefirm/grblhal-glowforge/grblhal-glowforge/grblhal.init index bdc7d3e..e478a29 100644 --- a/meta-forgefirm/recipes-forgefirm/grblhal-glowforge/grblhal-glowforge/grblhal.init +++ b/meta-forgefirm/recipes-forgefirm/grblhal-glowforge/grblhal-glowforge/grblhal.init @@ -11,9 +11,24 @@ DAEMON=/usr/bin/grblHAL_glowforge PIDFILE=/var/run/grblhal.pid LOG=/data/glowforge.log +CONF=/data/forgefirm.conf + +# Boot-time controller-mode dispatch: this service runs the machine in +# GRBL mode. controller_mode = cloud (once that mode exists, with its +# own service consulting the same key) keeps grblHAL down; anything +# else - grbl, unset, or no config file - starts it. +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 "grblHAL not started (controller_mode = cloud)" + exit 0 + fi echo "Starting grblHAL" start-stop-daemon -S -q -p $PIDFILE -m -b -x /bin/sh -- \ -c "cd /data && GFSINK=/dev/glowforge exec $DAEMON -p 23 -e /data/EEPROM-glowforge.DAT >> $LOG 2>&1"