-
Notifications
You must be signed in to change notification settings - Fork 54
Expand file tree
/
Copy pathmqtt-status
More file actions
42 lines (37 loc) · 764 Bytes
/
Copy pathmqtt-status
File metadata and controls
42 lines (37 loc) · 764 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/bin/sh
PIDFILE="/run/mqtt-status.pid"
if [ ! -f /opt/config/mqtt.conf ]; then
echo "You have to configure mqtt first. Please see /opt/config/mqtt.conf.dist for further instructions"
fi
status()
{
pid="$(cat "$PIDFILE" 2>/dev/null)"
if [ "$pid" ]; then
kill -0 "$pid" >/dev/null && echo "PID: $pid" || return 1
fi
}
start()
{
if [ -f $PIDFILE ]; then
echo "MQTT-Status already running";
else
echo "Starting MQTT-Status"
/opt/bin/busybox nohup /opt/scripts/mqtt-status-interval.sh &>/dev/null &
echo "$!" > "$PIDFILE"
fi
}
stop()
{
pid="$(cat "$PIDFILE" 2>/dev/null)"
if [ "$pid" ]; then
kill "$pid" && rm "$PIDFILE"
fi
}
if [ $# -eq 0 ]; then
start
else
case $1 in start|stop|status)
$1
;;
esac
fi