tools/rc.thermferm

Mon, 15 Apr 2024 17:04:57 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Mon, 15 Apr 2024 17:04:57 +0200
changeset 678
cc49115e769e
parent 675
825210ba2707
permissions
-rw-r--r--

Better websocket broadcast messages. Added GLOBAL JSON command to the server. Better logic to trigger websocket and mqtt data updates for the fermenter units. Websocket receive added fermenter mode, stage, setpoints, switches. Added more css styles for the fermenter screen. Added the fermenter screen php and javascript.

#!/bin/bash
#
# thermferm init script for Slackware.
#
# Copyright 2022-2024 Michiel Broek, the Netherlands.

# Source default settings:
if [ -r /etc/default/thermferm ]; then
  . /etc/default/thermferm
fi

PIDFILE=/run/thermferm.pid
STOPTIME=45

case "$1" in
  start)
    echo -n "Starting Fermentation Controller: "
    if [ -f ${PIDFILE} ]; then
  	echo "already running."
    else
	${THERMFERM_BIN}
        echo "done."
    fi
    ;;

  stop)
    echo -n "Stopping Fermentation Controller: "
    if [ -f ${PIDFILE} ]; then
      kill $(cat ${PIDFILE})
      tim=0
      while [ true ]; do
	[ ! -f "${PIDFILE}" ] && break;
	[ $tim -gt $STOPTIME ] && break;
	echo -n "."
	sleep 1
	tim=$(($tim+1))
      done
      echo "done."
    else
      echo "wasn't running."
    fi
    ;;

  restart)
    $0 stop
    sleep 2
    $0 start
    ;;

  *)
    echo "usage: $0 {start|stop|restart}"
esac

mercurial