-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathLirLogger.sh
executable file
·114 lines (102 loc) · 2.3 KB
/
LirLogger.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
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#!/bin/sh
#
# LirLogger Startup script for LirLogger
#
# chkconfig: - 85 15
# processname: LirLogger
# pidfile: /var/run/LirLogger.pid
# description: LirLogger is a remotely configurable service that controls 1 camera and multiple serial sensors
#
### BEGIN INIT INFO
# Provides: LirLogger
# Required-Start: $local_fs $remote_fs $network
# Required-Stop: $local_fs $remote_fs $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: start and stop LirLogger
### END INIT INFO
# Source function library.
. /etc/rc.d/init.d/functions
if [ -f /etc/sysconfig/LirLogger ]; then
. /etc/sysconfig/LirLogger
fi
prog=LirLogger
lirlogger=${LIRLOGGER-/usr/local/bin/LirLogger}
pidfile=${PIDFILE-/var/run/LirLogger.pid}
pleora_env="/opt/pleora/ebus_sdk/bin/set_puregev_env"
SLEEPMSEC=100000
RETVAL=0
start() {
echo -n $"Starting $prog: "
source ${pleora_env}
daemon --pidfile=${pidfile} ${lirlogger}
return 1
}
stop() {
echo -n $"Stopping $prog: "
killproc ${prog}
RETVAL=$?
echo
[ $RETVAL = 0 ] && rm -f ${pidfile}
}
reload() {
echo -n $"Reloading $prog: "
killproc -p ${pidfile} ${prog} -HUP
RETVAL=$?
echo
}
upgrade() {
oldbinpidfile=${pidfile}.oldbin
configtest -q || return 6
echo -n $"Staring new master $prog: "
killproc -p ${pidfile} ${prog} -USR2
RETVAL=$?
echo
/bin/usleep $SLEEPMSEC
if [ -f ${oldbinpidfile} -a -f ${pidfile} ]; then
echo -n $"Graceful shutdown of old $prog: "
killproc -p ${oldbinpidfile} ${prog} -QUIT
RETVAL=$?
echo
else
echo $"Upgrade failed!"
return 1
fi
}
rh_status() {
status -p ${pidfile} ${lirlogger}
}
# See how we were called.
case "$1" in
start)
rh_status >/dev/null 2>&1 && exit 0
start
;;
stop)
stop
;;
status)
rh_status
RETVAL=$?
;;
restart)
stop
start
;;
upgrade)
upgrade
;;
condrestart|try-restart)
if rh_status >/dev/null 2>&1; then
stop
start
fi
;;
force-reload|reload)
reload
;;
*)
echo $"Usage: $prog {start|stop|restart|condrestart|try-restart|force-reload|upgrade|reload|status|help}"
RETVAL=2
esac
exit $RETVAL