forked from AndyTaylorTweet/Pi-Star_Binaries_sbin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpistar-remote.service
executable file
·80 lines (72 loc) · 2.51 KB
/
pistar-remote.service
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/bin/bash
#########################################################
# #
# pistar-remote Service Handler #
# #
# Written for Pi-Star (http://www.mw0mwz.co.uk/pi-star) #
# By Andy Taylor (MW0MWZ) #
# #
# Version 1.2 #
# #
#########################################################
# Service Config
DAEMON=python
DAEMON_PATH=/usr/bin/
DAEMON_OPTS=/usr/local/sbin/pistar-remote
PGREP=/usr/bin/pgrep
KILL=/bin/kill
SLEEP=/bin/sleep
# Pre-flight checks...
test -x ${DAEMON_PATH}${DAEMON} || exit 0
test -x ${DAEMON_OPTS} || exit 0
# Check the remote app is enabled.
if grep "enabled" /etc/pistar-remote | grep -q "false" ; then
exit 0;
fi
case "$1" in
start)
if [ `${PGREP} -f "${DAEMON_PATH}${DAEMON} ${DAEMON_OPTS}"` ]; then
echo -e "pistar-remote is already running as PID "`${PGREP} -f "${DAEMON_PATH}${DAEMON} ${DAEMON_OPTS}"`
exit 0;
else
${DAEMON_PATH}${DAEMON} ${DAEMON_OPTS} &
echo -e "pistar-remote started as PID "`${PGREP} -f "${DAEMON_PATH}${DAEMON} ${DAEMON_OPTS}"`
exit 0;
fi
;;
stop)
if [ `${PGREP} -f "${DAEMON_PATH}${DAEMON} ${DAEMON_OPTS}"` ]; then
echo -e "Killing pistar-remote PID "`${PGREP} -f "${DAEMON_PATH}${DAEMON} ${DAEMON_OPTS}"`
$KILL `${PGREP} -f "${DAEMON_PATH}${DAEMON} ${DAEMON_OPTS}"`
exit 0;
else
echo -e "pistar-remote is not running"
exit 0;
fi
;;
restart)
if [ `${PGREP} -f "${DAEMON_PATH}${DAEMON} ${DAEMON_OPTS}"` ]; then
echo -e "Killing pistar-remote PID "`${PGREP} -f "${DAEMON_PATH}${DAEMON} ${DAEMON_OPTS}"`
$KILL `${PGREP} -f "${DAEMON_PATH}${DAEMON} ${DAEMON_OPTS}"`
$SLEEP 3
${DAEMON_PATH}${DAEMON} ${DAEMON_OPTS} &
echo -e "pistar-remote re-started as PID "`${PGREP} -f "${DAEMON_PATH}${DAEMON} ${DAEMON_OPTS}"`
exit 0;
else
echo -e "pistar-remote is not running"
${DAEMON_PATH}${DAEMON} ${DAEMON_OPTS} &
echo -e "pistar-remote is started as PID "`${PGREP} -f "${DAEMON_PATH}${DAEMON} ${DAEMON_OPTS}"`
exit 0;
fi
;;
status)
if [ `${PGREP} -f "${DAEMON_PATH}${DAEMON} ${DAEMON_OPTS}"` ]; then
echo -e "pistar-remote is running as PID "`${PGREP} -f "${DAEMON_PATH}${DAEMON} ${DAEMON_OPTS}"`
else
echo -e "pistar-remote is not running"
fi
;;
*)
echo $"Usage: $0 {start|stop|restart|status}"
exit 0
esac