forked from switchgears/extremefeedbacklamp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
initd_switchgearsXFD_discovery
executable file
·70 lines (64 loc) · 1.53 KB
/
initd_switchgearsXFD_discovery
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
#!/bin/bash
# /etc/init.d/switchgearsXFD
# Debian on Raspberry Pi compatible XFD startup script, Device Discovery Server.
#
### BEGIN INIT INFO
# Provides: XFD_discover
# Required-Start: $remote_fs $syslog $network
# Required-Stop: $remote_fs $syslog $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start XFD at boot time
# Description: Jumpstarts the server that the jenkins plugin can use to find the lamp
### END INIT INFO
DESC="Switch-Gears.dk eXtreme Feedback Device Discovery Server"
NAME=switchgearsXFDDiscoveryServer
SCRIPTNAME=/etc/init.d/$NAME
PIDFILE=/tmp/xfd/discover-xfd.pid
if [ `id -u` -ne 0 ]; then
echo "The $NAME init script can only be run as root"
exit 1
fi
do_start()
{
mkdir -p $(dirname $PIDFILE)
rm -f $PIDFILE
sudo /home/pi/extremefeedbacklamp/xfd_discovery_server.py &
echo -n $! > $PIDFILE
}
do_stop()
{
if [ -f $PIDFILE ]; then
kill `cat $PIDFILE`
fi
}
case "$1" in
start)
echo "Starting $NAME"
do_start
;;
stop)
echo "Stopping $NAME"
do_stop
;;
restart)
echo "Stopping $NAME"
do_stop
do_start
;;
status)
if [ -f $PIDFILE ]; then
echo "XFD Discovery Server (should be) running with PID:"
cat $PIDFILE
echo ""
else
echo "XFD Discovery Server not running (or not started through init.d)"
fi
;;
*)
echo "Usage: /etc/init.d/switchgearsXFDDiscoveryServer {start|stop|status|restart}"
exit 1
;;
esac
exit 0