-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit
executable file
·84 lines (73 loc) · 2.01 KB
/
init
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
#!/bin/sh
### BEGIN INIT INFO
# Provides: ts-M1M3thermal
# Required-Start: $network $remote_fs
# Required-Stop: $network $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 6
# Short-Description: Start TS VMS (Vibration Monitor System) daemon
### END INIT INFO
PATH=/sbin:/bin:/usr/bin:/usr/sbin
DAEMON=/usr/sbin/ts-M1M3thermald
PIDFILE=/var/run/ts-M1M3thermald.pid
# rcS contains TICKADJ
test -r /etc/default/rcS && . /etc/default/rcS
# Source function library.
. /etc/init.d/functions
# Source devices, export all variables
set -a
. /etc/default/ts-M1M3thermal
set +a
startdaemon(){
# CSC runs with shmem config, requires ospl daemon
sudo -E -u m1m3 -g m1m3 LD_LIBRARY_PATH=$OSPL_HOME/lib PATH=$PATH:$OSPL_HOME/bin $OSPL_HOME/bin/ospl start
# make sure network is up and running
attemps=0
export LSST_DDS_IP=`ip route get 1 | awk '{print $7;exit}'`
while [ -z $LSST_DDS_IP ]; do
sleep 1
export LSST_DDS_IP=`ip route get 1 | awk '{print $7;exit}'`
let attemps+=1
if [ $attemps -gt 60 ]; then
logger -t M1M3thermal_start -p user.error "Timeouted waiting for interface"
exit 1
fi
done
logger -t M1M3thermal_start -p user.info "Starting with IP $LSST_DDS_IP"
echo -n "Starting TS M1M3 thermal:"
start-stop-daemon --start --oknodo --pidfile ${PIDFILE} --startas $DAEMON -- -p ${PIDFILE} -u m1m3:m1m3
echo "done"
}
stopdaemon(){
echo -n "Stopping TS M1M3 thermal:"
start-stop-daemon --stop --remove-pidfile --retry 5 -p ${PIDFILE}
sudo -E -u m1m3 -g m1m3 LD_LIBRARY_PATH=$OSPL_HOME/lib PATH=$PATH:$OSPL_HOME/bin $OSPL_HOME/bin/ospl stop
if [ $? == 0 ]; then
echo "done"
else
echo "failed"
exit $?
fi
}
case "$1" in
start)
startdaemon
;;
stop)
stopdaemon
;;
restart)
stopdaemon
startdaemon
;;
status)
sudo -E -u m1m3 -g m1m3 LD_LIBRARY_PATH=$OSPL_HOME/lib PATH=$PATH:$OSPL_HOME/bin $OSPL_HOME/bin/ospl status
status $DAEMON
exit $?
;;
*)
echo "Usage: ts-M1M3thermal { start | stop | status | restart }" >&2
exit 1
;;
esac
exit 0