-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit
executable file
·93 lines (82 loc) · 2.08 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
#!/bin/sh
### BEGIN INIT INFO
# Provides: ts-VMS
# 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-VMSd
PIDFILE=/var/run/ts-VMSd
# 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-VMS
set +a
if [ -z "$VMS" ]; then
echo "Please edit /etc/default/ts-VMS and specify at least one VMS device to start"
exit 1
fi
startdaemon(){
# CSC runs with shmem config, requires ospl daemon
sudo -E -u vms -g vms 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 VMS_start -p user.error "Timeouted waiting for interface"
exit 1
fi
done
logger -t VMS_start -p user.info "Starting with IP $LSST_DDS_IP"
echo -n "Starting TS VMS $1:"
start-stop-daemon --start --oknodo --pidfile ${PIDFILE}_$1.pid --exec $DAEMON -- -p ${PIDFILE}_$1.pid -u vms:vms $1
echo "done"
}
stopdaemon(){
echo -n "Stopping TS VMS $1:"
start-stop-daemon --stop --oknodo --remove-pidfile --user vms --retry 5 -p ${PIDFILE}_$1.pid
sudo -E -u vms -g vms LD_LIBRARY_PATH=$OSPL_HOME/lib PATH=$PATH:$OSPL_HOME/bin $OSPL_HOME/bin/ospl stop
echo "done"
}
startall(){
for v in $VMS; do
startdaemon $v
done
}
stopall(){
for v in $VMS; do
stopdaemon $v
done
}
case "$1" in
start)
startall
;;
stop)
stopall
;;
restart)
stopall
startall
;;
status)
sudo -E -u vms -g vms LD_LIBRARY_PATH=$OSPL_HOME/lib PATH=$PATH:$OSPL_HOME/bin $OSPL_HOME/bin/ospl status
status $DAEMON
exit $?
;;
*)
echo "Usage: ts-VMS { start | stop | status | restart }" >&2
exit 1
;;
esac
exit 0