-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathraspC.sh
executable file
·54 lines (45 loc) · 1.23 KB
/
raspC.sh
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
#!/bin/sh
### BEGIN INIT INFO
# Provides: raspC
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Monitoring tool
# Description: Monitoring tool for Raspberry Pi based on websockets written in C
### END INIT INFO
# Author: Karim Echchennouf <[email protected]>
set -e
NAME=raspC
PIDFILE=/var/run/$NAME.pid
DAEMON=/usr/sbin/raspC
export PATH="${PATH}:/usr/sbin:/sbin"
. /lib/lsb/init-functions
case "$1" in
start)
log_daemon_msg "$NAME started"
start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON
echo "."
;;
stop)
log_daemon_msg "$NAME stoped"
start-stop-daemon --stop --quiet --oknodo --pidfile $PIDFILE
;;
restart)
log_daemon_msg "$NAME restarting"
start-stop-daemon --stop --quiet --oknodo --retry 30 --pidfile $PIDFILE
start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- $DAEMON_OPTS
;;
force-reload)
pid=$(pgrep $NAME)
kill -HUP $pid
;;
status)
status_of_proc -p $PIDFILE $DAEMON $NAME && exit 0 || exit $?
exit $?
;;
*)
log_failure_msg "Usage: "$1" {start|stop|restart|force-reload|status}"
exit 1
esac
exit 0