#!/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