File tree Expand file tree Collapse file tree
patches/debian/config/etc/init.d Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -81,17 +81,15 @@ _failure() {
8181}
8282RETVAL=$?
8383CLOUDSTACK_HOME=" /usr/local/cloud"
84+ if [ -f $CLOUDSTACK_HOME /systemvm/utils.sh ];
85+ then
86+ . $CLOUDSTACK_HOME /systemvm/utils.sh
87+ else
88+ _failure
89+ fi
8490
8591# mkdir -p /var/log/vmops
8692
87- get_pids () {
88- local i
89- for i in $( ps -ef| grep java | grep -v grep | awk ' {print $2}' ) ;
90- do
91- echo $( pwdx $i ) | grep " $CLOUDSTACK_HOME " | awk -F: ' {print $1}' ;
92- done
93- }
94-
9593start () {
9694 local pid=$( get_pids)
9795 if [ " $pid " != " " ]; then
Original file line number Diff line number Diff line change 2323# _run.sh runs the agent client.
2424
2525# set -x
26-
26+ readonly PROGNAME=$( basename " $0 " )
27+ readonly LOCKDIR=/tmp
28+ readonly LOCKFD=500
29+
30+ CLOUDSTACK_HOME=" /usr/local/cloud"
31+ . $CLOUDSTACK_HOME /systemvm/utils.sh
32+
33+ LOCKFILE=$LOCKDIR /$PROGNAME .xlock
34+ lock $LOCKFILE $LOCKFD
35+ if [ $? -eq 1 ]; then
36+ exit 1
37+ fi
38+
2739while true
2840do
29- ./_run.sh " $@ " &
30- wait
31- ex=$?
32- if [ $ex -eq 0 ] || [ $ex -eq 1 ] || [ $ex -eq 66 ] || [ $ex -gt 128 ]; then
33- # permanent errors
34- sleep 5
41+ pid=$( get_pids)
42+ action=` cat /usr/local/cloud/systemvm/user_request`
43+ if [ " $pid " == " " ] && [ " $action " == " start" ] ; then
44+ ./_run.sh " $@ " &
45+ wait
46+ ex=$?
47+ if [ $ex -eq 0 ] || [ $ex -eq 1 ] || [ $ex -eq 66 ] || [ $ex -gt 128 ]; then
48+ # permanent errors
49+ sleep 5
50+ fi
3551 fi
3652
3753 # user stop agent by service cloud stop
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ CLOUDSTACK_HOME=" /usr/local/cloud"
4+
5+ get_pids () {
6+ local i
7+ for i in $( ps -ef| grep java | grep -v grep | awk ' {print $2}' ) ;
8+ do
9+ echo $( pwdx $i ) | grep " $CLOUDSTACK_HOME " | awk -F: ' {print $1}' ;
10+ done
11+ }
12+
13+ lock ()
14+ {
15+ lockfile=$1
16+ lockfd=$2
17+ eval " exec $lockfd >$lockfile "
18+ flock -n $lockfd \
19+ && return 0 \
20+ || return 1
21+ }
You can’t perform that action at this time.
0 commit comments