tools/rc.thermferm

Sun, 05 May 2024 17:24:54 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Sun, 05 May 2024 17:24:54 +0200
changeset 730
6eba006ed8f5
parent 675
825210ba2707
permissions
-rw-r--r--

Much faster shutdown of the websocket service.

612
452f79a5ad71 Make sure the hostname doesn't contain the domain name. Added Slackare init and setup scripts.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1 #!/bin/bash
452f79a5ad71 Make sure the hostname doesn't contain the domain name. Added Slackare init and setup scripts.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2 #
452f79a5ad71 Make sure the hostname doesn't contain the domain name. Added Slackare init and setup scripts.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3 # thermferm init script for Slackware.
452f79a5ad71 Make sure the hostname doesn't contain the domain name. Added Slackare init and setup scripts.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4 #
633
8b84e73af50e Add DESTDIR installation target. Some kicad update again. Moved init script to /etc/rc.d
Michiel Broek <mbroek@mbse.eu>
parents: 614
diff changeset
5 # Copyright 2022-2024 Michiel Broek, the Netherlands.
612
452f79a5ad71 Make sure the hostname doesn't contain the domain name. Added Slackare init and setup scripts.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6
639
276ee5b61348 Init system for Slackware only
Michiel Broek <mbroek@mbse.eu>
parents: 633
diff changeset
7 # Source default settings:
276ee5b61348 Init system for Slackware only
Michiel Broek <mbroek@mbse.eu>
parents: 633
diff changeset
8 if [ -r /etc/default/thermferm ]; then
276ee5b61348 Init system for Slackware only
Michiel Broek <mbroek@mbse.eu>
parents: 633
diff changeset
9 . /etc/default/thermferm
276ee5b61348 Init system for Slackware only
Michiel Broek <mbroek@mbse.eu>
parents: 633
diff changeset
10 fi
276ee5b61348 Init system for Slackware only
Michiel Broek <mbroek@mbse.eu>
parents: 633
diff changeset
11
633
8b84e73af50e Add DESTDIR installation target. Some kicad update again. Moved init script to /etc/rc.d
Michiel Broek <mbroek@mbse.eu>
parents: 614
diff changeset
12 PIDFILE=/run/thermferm.pid
675
825210ba2707 Added websockets to thermferm. Started new www directory for websocket enabled web. The init script now waits until thermferm is completely stopped.
Michiel Broek <mbroek@mbse.eu>
parents: 640
diff changeset
13 STOPTIME=45
612
452f79a5ad71 Make sure the hostname doesn't contain the domain name. Added Slackare init and setup scripts.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14
452f79a5ad71 Make sure the hostname doesn't contain the domain name. Added Slackare init and setup scripts.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
15 case "$1" in
452f79a5ad71 Make sure the hostname doesn't contain the domain name. Added Slackare init and setup scripts.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
16 start)
452f79a5ad71 Make sure the hostname doesn't contain the domain name. Added Slackare init and setup scripts.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
17 echo -n "Starting Fermentation Controller: "
452f79a5ad71 Make sure the hostname doesn't contain the domain name. Added Slackare init and setup scripts.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
18 if [ -f ${PIDFILE} ]; then
452f79a5ad71 Make sure the hostname doesn't contain the domain name. Added Slackare init and setup scripts.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
19 echo "already running."
452f79a5ad71 Make sure the hostname doesn't contain the domain name. Added Slackare init and setup scripts.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
20 else
639
276ee5b61348 Init system for Slackware only
Michiel Broek <mbroek@mbse.eu>
parents: 633
diff changeset
21 ${THERMFERM_BIN}
612
452f79a5ad71 Make sure the hostname doesn't contain the domain name. Added Slackare init and setup scripts.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
22 echo "done."
452f79a5ad71 Make sure the hostname doesn't contain the domain name. Added Slackare init and setup scripts.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
23 fi
452f79a5ad71 Make sure the hostname doesn't contain the domain name. Added Slackare init and setup scripts.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
24 ;;
452f79a5ad71 Make sure the hostname doesn't contain the domain name. Added Slackare init and setup scripts.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
25
452f79a5ad71 Make sure the hostname doesn't contain the domain name. Added Slackare init and setup scripts.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
26 stop)
452f79a5ad71 Make sure the hostname doesn't contain the domain name. Added Slackare init and setup scripts.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
27 echo -n "Stopping Fermentation Controller: "
452f79a5ad71 Make sure the hostname doesn't contain the domain name. Added Slackare init and setup scripts.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
28 if [ -f ${PIDFILE} ]; then
452f79a5ad71 Make sure the hostname doesn't contain the domain name. Added Slackare init and setup scripts.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
29 kill $(cat ${PIDFILE})
675
825210ba2707 Added websockets to thermferm. Started new www directory for websocket enabled web. The init script now waits until thermferm is completely stopped.
Michiel Broek <mbroek@mbse.eu>
parents: 640
diff changeset
30 tim=0
825210ba2707 Added websockets to thermferm. Started new www directory for websocket enabled web. The init script now waits until thermferm is completely stopped.
Michiel Broek <mbroek@mbse.eu>
parents: 640
diff changeset
31 while [ true ]; do
825210ba2707 Added websockets to thermferm. Started new www directory for websocket enabled web. The init script now waits until thermferm is completely stopped.
Michiel Broek <mbroek@mbse.eu>
parents: 640
diff changeset
32 [ ! -f "${PIDFILE}" ] && break;
825210ba2707 Added websockets to thermferm. Started new www directory for websocket enabled web. The init script now waits until thermferm is completely stopped.
Michiel Broek <mbroek@mbse.eu>
parents: 640
diff changeset
33 [ $tim -gt $STOPTIME ] && break;
825210ba2707 Added websockets to thermferm. Started new www directory for websocket enabled web. The init script now waits until thermferm is completely stopped.
Michiel Broek <mbroek@mbse.eu>
parents: 640
diff changeset
34 echo -n "."
825210ba2707 Added websockets to thermferm. Started new www directory for websocket enabled web. The init script now waits until thermferm is completely stopped.
Michiel Broek <mbroek@mbse.eu>
parents: 640
diff changeset
35 sleep 1
825210ba2707 Added websockets to thermferm. Started new www directory for websocket enabled web. The init script now waits until thermferm is completely stopped.
Michiel Broek <mbroek@mbse.eu>
parents: 640
diff changeset
36 tim=$(($tim+1))
825210ba2707 Added websockets to thermferm. Started new www directory for websocket enabled web. The init script now waits until thermferm is completely stopped.
Michiel Broek <mbroek@mbse.eu>
parents: 640
diff changeset
37 done
612
452f79a5ad71 Make sure the hostname doesn't contain the domain name. Added Slackare init and setup scripts.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
38 echo "done."
452f79a5ad71 Make sure the hostname doesn't contain the domain name. Added Slackare init and setup scripts.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
39 else
452f79a5ad71 Make sure the hostname doesn't contain the domain name. Added Slackare init and setup scripts.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
40 echo "wasn't running."
452f79a5ad71 Make sure the hostname doesn't contain the domain name. Added Slackare init and setup scripts.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
41 fi
452f79a5ad71 Make sure the hostname doesn't contain the domain name. Added Slackare init and setup scripts.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
42 ;;
452f79a5ad71 Make sure the hostname doesn't contain the domain name. Added Slackare init and setup scripts.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
43
452f79a5ad71 Make sure the hostname doesn't contain the domain name. Added Slackare init and setup scripts.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
44 restart)
452f79a5ad71 Make sure the hostname doesn't contain the domain name. Added Slackare init and setup scripts.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
45 $0 stop
614
389097dc665d Version 0.9.11. Removed lcd debug message after 7 years. Added setup for alternative beer sensor. If the main sensor is gone, the alternative will be used.
Michiel Broek <mbroek@mbse.eu>
parents: 612
diff changeset
46 sleep 2
612
452f79a5ad71 Make sure the hostname doesn't contain the domain name. Added Slackare init and setup scripts.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
47 $0 start
452f79a5ad71 Make sure the hostname doesn't contain the domain name. Added Slackare init and setup scripts.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
48 ;;
452f79a5ad71 Make sure the hostname doesn't contain the domain name. Added Slackare init and setup scripts.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
49
452f79a5ad71 Make sure the hostname doesn't contain the domain name. Added Slackare init and setup scripts.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
50 *)
452f79a5ad71 Make sure the hostname doesn't contain the domain name. Added Slackare init and setup scripts.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
51 echo "usage: $0 {start|stop|restart}"
452f79a5ad71 Make sure the hostname doesn't contain the domain name. Added Slackare init and setup scripts.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
52 esac
452f79a5ad71 Make sure the hostname doesn't contain the domain name. Added Slackare init and setup scripts.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
53

mercurial