-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathinit
executable file
·103 lines (92 loc) · 2.55 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#!/bin/sh
### BEGIN INIT INFO
# Provides: ts-M1M3support
# 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-M1M3supportd
PIDFILE=/var/run/ts-M1M3supportd.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/M1M3support
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 M1M3support_start -p user.error "Timeouted waiting for interface"
exit 1
fi
done
logger -t M1M3support_start -p user.info "Starting with IP $LSST_DDS_IP"
OPTS="-u m1m3:m1m3 "
if [ $M1M3_SUPPORT_CONFIG ]; then
OPTS+="-c $M1M3_SUPPORT_CONFIG "
fi
echo -n "Starting TS M1M3 support: (config"
start-stop-daemon --start --oknodo --pidfile ${PIDFILE} --startas $DAEMON -- -p ${PIDFILE} ${OPTS}
echo "done"
}
stopdaemon(){
echo -n "Stopping TS M1M3 support:"
start-stop-daemon --stop --oknodo --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
echo "done"
}
case "$1" in
start)
startdaemon
;;
stop)
stopdaemon
;;
restart)
stopdaemon
startdaemon
;;
reload)
pid=$(cat $PIDFILE)
if [ -z $pid ]; then
echo "M1M3 Support System CSC isn't running."
else
echo -n "Triggering M1M3 Support System configuration reload - pid ${pid}"
/bin/kill -SIGUSR1 ${pid}
echo "..$? done. Check M1M3 log for confirmation!"
fi
;;
rawdc)
pid=$(cat $PIDFILE)
if [ -z $pid ]; then
echo "M1M3 Support System CSC isn't running."
else
echo -n "Flipping M1M3 Support System Raw DC Accelerometers recording - pid ${pid}"
/bin/kill -SIGUSR2 ${pid}
echo "..$? done. Check M1M3 log for confirmation!"
fi
;;
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-M1M3support { start | stop | status | restart }" >&2
exit 1
;;
esac
exit 0