-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathalarmctl
executable file
·58 lines (53 loc) · 1.06 KB
/
alarmctl
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/bin/bash
########################################
# Init and control script for Alarmify #
# by Eric Thompson (October 2017) #
########################################
FIND_PID="pgrep -u root -fo alarmify"
START_ALARM="/usr/bin/python /root/alarmify/alarmify.py > /dev/null 2>&1 & disown"
do_start () {
pid=$($FIND_PID)
if [[ $pid ]]; then
echo "Alarmify is already running with PID: $pid"
else
echo "Starting Alarmify..."
$($START_ALARM)
fi
}
do_status () {
pid=$($FIND_PID)
if [[ $pid ]]; then
echo "Alarmify is running with PID: $pid"
else
echo "Alarmify is not currently running"
fi
}
do_stop () {
pid=$($FIND_PID)
if [[ $pid ]]; then
echo "Stopping Alarmify..."
$(kill $pid)
else
echo "Alarmify is not currently running"
fi
}
case "$1" in
start|"")
do_start
;;
restart|reload|force-reload)
do_stop
do_start
;;
stop)
do_stop
;;
status)
do_status
exit $?
;;
*)
echo "Usage: alarmctl [start|stop|restart|status]" >&2
exit 3
;;
esac