mirror of https://github.com/apache/cloudstack.git
add wait for network before starting agent
This commit is contained in:
parent
57fe38efcd
commit
358fb9aba6
|
|
@ -1,7 +1,14 @@
|
|||
#!/bin/bash
|
||||
### BEGIN INIT INFO
|
||||
# Provides: cloud agent
|
||||
# Required-Start: $network
|
||||
# Required-Stop: $network
|
||||
# Default-Start: 3 4 5
|
||||
# Default-Stop: 0 1 2 6
|
||||
# X-Interactive: true
|
||||
# Short-Description: Start/stop apache2 web server
|
||||
### END INIT INFO
|
||||
|
||||
# chkconfig: 35 99 10
|
||||
# description: Cloud Agent
|
||||
|
||||
# WARNING: if this script is changed, then all other initscripts MUST BE changed to match it as well
|
||||
|
||||
|
|
@ -23,6 +30,20 @@ unset OPTIONS
|
|||
DAEMONIZE=@BINDIR@/@PACKAGE@-daemonize
|
||||
PROG=@LIBEXECDIR@/agent-runner
|
||||
|
||||
wait_for_network() {
|
||||
i=1
|
||||
while [ $i -lt 10 ]
|
||||
do
|
||||
if ip addr show cloudbr0 |grep -w inet > /dev/null 2>&1; then
|
||||
break
|
||||
else
|
||||
continue
|
||||
fi
|
||||
sleep 1
|
||||
let i=$i+1
|
||||
done
|
||||
}
|
||||
|
||||
start() {
|
||||
log_daemon_msg $"Starting $PROGNAME" "$SHORTNAME"
|
||||
if [ -s "$PIDFILE" ] && kill -0 $(cat "$PIDFILE") >/dev/null 2>&1; then
|
||||
|
|
@ -38,6 +59,9 @@ start() {
|
|||
exit 1
|
||||
fi
|
||||
|
||||
#FIXME: wait for network
|
||||
wait_for_network
|
||||
|
||||
if start-stop-daemon --start --quiet \
|
||||
--pidfile "$PIDFILE" \
|
||||
--exec "$DAEMONIZE" -- -n "$SHORTNAME" -p "$PIDFILE" -l "$LOGFILE" "$PROG" $OPTIONS
|
||||
|
|
|
|||
Loading…
Reference in New Issue