incubator-cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wid...@apache.org
Subject [34/50] git commit: Modify the other Agent init scripts so they use JSVC as well
Date Thu, 26 Jul 2012 21:05:07 GMT
Modify the other Agent init scripts so they use JSVC as well


Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/5c5a4e3a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/5c5a4e3a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/5c5a4e3a

Branch: refs/heads/rbd
Commit: 5c5a4e3a10b9ab2c54ce507962cdf73fa62957d1
Parents: 8dfaa76
Author: Wido den Hollander <wido@widodh.nl>
Authored: Tue Jul 24 23:59:37 2012 +0200
Committer: Wido den Hollander <wido@widodh.nl>
Committed: Tue Jul 24 23:59:37 2012 +0200

----------------------------------------------------------------------
 .../centos/SYSCONFDIR/rc.d/init.d/cloud-agent.in   |   27 ++++++--
 .../fedora/SYSCONFDIR/rc.d/init.d/cloud-agent.in   |   27 ++++++--
 .../opensuse/sles/SYSCONFDIR/init.d/cloud-agent.in |   51 ++++++++++-----
 .../rhel/SYSCONFDIR/rc.d/init.d/cloud-agent.in     |   27 ++++++--
 agent/distro/sles/SYSCONFDIR/init.d/cloud-agent.in |   51 ++++++++++-----
 5 files changed, 134 insertions(+), 49 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/5c5a4e3a/agent/distro/centos/SYSCONFDIR/rc.d/init.d/cloud-agent.in
----------------------------------------------------------------------
diff --git a/agent/distro/centos/SYSCONFDIR/rc.d/init.d/cloud-agent.in b/agent/distro/centos/SYSCONFDIR/rc.d/init.d/cloud-agent.in
index d98d6e2..488ced2 100755
--- a/agent/distro/centos/SYSCONFDIR/rc.d/init.d/cloud-agent.in
+++ b/agent/distro/centos/SYSCONFDIR/rc.d/init.d/cloud-agent.in
@@ -33,17 +33,34 @@ PIDFILE=@PIDDIR@/"$whatami".pid
 LOCKFILE=@LOCKDIR@/"$SHORTNAME"
 LOGFILE=@AGENTLOG@
 PROGNAME="Cloud Agent"
+CLASS="com.cloud.agent.AgentShell"
 
 unset OPTIONS
 [ -r @SYSCONFDIR@/sysconfig/"$SHORTNAME" ] && source @SYSCONFDIR@/sysconfig/"$SHORTNAME"
-DAEMONIZE=@BINDIR@/@PACKAGE@-daemonize
-PROG=@LIBEXECDIR@/agent-runner
+
+# The first existing directory is used for JAVA_HOME (if JAVA_HOME is not defined in $DEFAULT)
+JDK_DIRS="/usr/lib/jvm/java-6-openjdk /usr/lib/jvm/java-6-openjdk-i386 /usr/lib/jvm/java-6-openjdk-amd64
/usr/lib/jvm/java-6-sun /usr/lib/jvm/java-1.5.0-sun /usr/lib/j2sdk1.5-sun /usr/lib/j2sdk1.5-ibm"
+
+for jdir in $JDK_DIRS; do
+    if [ -r "$jdir/bin/java" -a -z "${JAVA_HOME}" ]; then
+        JAVA_HOME="$jdir"
+    fi
+done
+export JAVA_HOME
+
+SCP="@SYSTEMCLASSPATH@"
+DCP="@DEPSCLASSPATH@"
+ACP="@AGENTCLASSPATH@"
+JCP="/usr/share/java/commons-daemon.jar"
+
+# We need to append the JSVC daemon JAR to the classpath
+# AgentShell implements the JSVC daemon methods
+export CLASSPATH="$SCP:$DCP:$ACP:$JCP:@AGENTSYSCONFDIR@"
 
 start() {
         echo -n $"Starting $PROGNAME: "
 	if hostname --fqdn >/dev/null 2>&1 ; then
-		daemon --check=$SHORTNAME --pidfile=${PIDFILE} "$DAEMONIZE" \
-			-n "$SHORTNAME" -p "$PIDFILE" -l "$LOGFILE" "$PROG" $OPTIONS
+		jsvc -cp "$CLASSPATH" -pidfile "$PIDFILE" $CLASS
 		RETVAL=$?
 		echo
 	else
@@ -58,7 +75,7 @@ start() {
 
 stop() {
 	echo -n $"Stopping $PROGNAME: "
-	killproc -p ${PIDFILE} $SHORTNAME # -d 10 $SHORTNAME
+	jsvc -pidfile "$PIDFILE" -stop $CLASS
 	RETVAL=$?
 	echo
 	[ $RETVAL = 0 ] && rm -f ${LOCKFILE} ${PIDFILE}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/5c5a4e3a/agent/distro/fedora/SYSCONFDIR/rc.d/init.d/cloud-agent.in
----------------------------------------------------------------------
diff --git a/agent/distro/fedora/SYSCONFDIR/rc.d/init.d/cloud-agent.in b/agent/distro/fedora/SYSCONFDIR/rc.d/init.d/cloud-agent.in
index d98d6e2..488ced2 100755
--- a/agent/distro/fedora/SYSCONFDIR/rc.d/init.d/cloud-agent.in
+++ b/agent/distro/fedora/SYSCONFDIR/rc.d/init.d/cloud-agent.in
@@ -33,17 +33,34 @@ PIDFILE=@PIDDIR@/"$whatami".pid
 LOCKFILE=@LOCKDIR@/"$SHORTNAME"
 LOGFILE=@AGENTLOG@
 PROGNAME="Cloud Agent"
+CLASS="com.cloud.agent.AgentShell"
 
 unset OPTIONS
 [ -r @SYSCONFDIR@/sysconfig/"$SHORTNAME" ] && source @SYSCONFDIR@/sysconfig/"$SHORTNAME"
-DAEMONIZE=@BINDIR@/@PACKAGE@-daemonize
-PROG=@LIBEXECDIR@/agent-runner
+
+# The first existing directory is used for JAVA_HOME (if JAVA_HOME is not defined in $DEFAULT)
+JDK_DIRS="/usr/lib/jvm/java-6-openjdk /usr/lib/jvm/java-6-openjdk-i386 /usr/lib/jvm/java-6-openjdk-amd64
/usr/lib/jvm/java-6-sun /usr/lib/jvm/java-1.5.0-sun /usr/lib/j2sdk1.5-sun /usr/lib/j2sdk1.5-ibm"
+
+for jdir in $JDK_DIRS; do
+    if [ -r "$jdir/bin/java" -a -z "${JAVA_HOME}" ]; then
+        JAVA_HOME="$jdir"
+    fi
+done
+export JAVA_HOME
+
+SCP="@SYSTEMCLASSPATH@"
+DCP="@DEPSCLASSPATH@"
+ACP="@AGENTCLASSPATH@"
+JCP="/usr/share/java/commons-daemon.jar"
+
+# We need to append the JSVC daemon JAR to the classpath
+# AgentShell implements the JSVC daemon methods
+export CLASSPATH="$SCP:$DCP:$ACP:$JCP:@AGENTSYSCONFDIR@"
 
 start() {
         echo -n $"Starting $PROGNAME: "
 	if hostname --fqdn >/dev/null 2>&1 ; then
-		daemon --check=$SHORTNAME --pidfile=${PIDFILE} "$DAEMONIZE" \
-			-n "$SHORTNAME" -p "$PIDFILE" -l "$LOGFILE" "$PROG" $OPTIONS
+		jsvc -cp "$CLASSPATH" -pidfile "$PIDFILE" $CLASS
 		RETVAL=$?
 		echo
 	else
@@ -58,7 +75,7 @@ start() {
 
 stop() {
 	echo -n $"Stopping $PROGNAME: "
-	killproc -p ${PIDFILE} $SHORTNAME # -d 10 $SHORTNAME
+	jsvc -pidfile "$PIDFILE" -stop $CLASS
 	RETVAL=$?
 	echo
 	[ $RETVAL = 0 ] && rm -f ${LOCKFILE} ${PIDFILE}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/5c5a4e3a/agent/distro/opensuse/sles/SYSCONFDIR/init.d/cloud-agent.in
----------------------------------------------------------------------
diff --git a/agent/distro/opensuse/sles/SYSCONFDIR/init.d/cloud-agent.in b/agent/distro/opensuse/sles/SYSCONFDIR/init.d/cloud-agent.in
index 4046d22..4f6f04d 100644
--- a/agent/distro/opensuse/sles/SYSCONFDIR/init.d/cloud-agent.in
+++ b/agent/distro/opensuse/sles/SYSCONFDIR/init.d/cloud-agent.in
@@ -1,8 +1,8 @@
 #!/bin/bash
 ### BEGIN INIT INFO
 # Provides:          cloud agent
-# Required-Start:    $network
-# Required-Stop:     $network
+# Required-Start:    $network 
+# Required-Stop:     $network 
 # Default-Start:     3 4 5
 # Default-Stop:      0 1 2 6
 # X-Interactive:     true
@@ -29,7 +29,7 @@
 # WARNING: if this script is changed, then all other initscripts MUST BE changed to match
it as well
 
 . /lib/lsb/init-functions
-. /etc/rc.status
+. /etc/default/rcS
 
 whatami=cloud-agent
 
@@ -40,17 +40,37 @@ PIDFILE=@PIDDIR@/"$whatami".pid
 LOCKFILE=@LOCKDIR@/"$SHORTNAME"
 LOGFILE=@AGENTLOG@
 PROGNAME="Cloud Agent"
+CLASS="com.cloud.agent.AgentShell"
 
 unset OPTIONS
 [ -r @SYSCONFDIR@/default/"$SHORTNAME" ] && source @SYSCONFDIR@/default/"$SHORTNAME"
-DAEMONIZE=@BINDIR@/@PACKAGE@-daemonize
-PROG=@LIBEXECDIR@/agent-runner
+
+# The first existing directory is used for JAVA_HOME (if JAVA_HOME is not defined in $DEFAULT)
+JDK_DIRS="/usr/lib/jvm/java-6-openjdk /usr/lib/jvm/java-6-openjdk-i386 /usr/lib/jvm/java-6-openjdk-amd64
/usr/lib/jvm/java-6-sun /usr/lib/jvm/java-1.5.0-sun /usr/lib/j2sdk1.5-sun /usr/lib/j2sdk1.5-ibm"
+
+for jdir in $JDK_DIRS; do
+    if [ -r "$jdir/bin/java" -a -z "${JAVA_HOME}" ]; then
+        JAVA_HOME="$jdir"
+    fi
+done
+export JAVA_HOME
+
+SCP="@SYSTEMCLASSPATH@"
+DCP="@DEPSCLASSPATH@"
+ACP="@AGENTCLASSPATH@"
+JCP="/usr/share/java/commons-daemon.jar"
+
+# We need to append the JSVC daemon JAR to the classpath
+# AgentShell implements the JSVC daemon methods
+export CLASSPATH="$SCP:$DCP:$ACP:$JCP:@AGENTSYSCONFDIR@"
 
 wait_for_network() {
     i=1
     while [ $i -lt 10 ]
     do
-        if ip addr show cloudbr0 |grep -w inet > /dev/null 2>&1; then
+        # Under Ubuntu and Debian libvirt by default creates a bridge called virbr0.
+        # That's why we want more then 3 lines back from brctl, so that there is a manually
created bridge
+        if [ "$(brctl show|wc -l)" -gt 2 ]; then
             break
         else
             sleep 1
@@ -75,12 +95,9 @@ start() {
 		exit 1
 	fi
 
-    #FIXME: wait for network
-    wait_for_network
+        wait_for_network
 
-	if start-stop-daemon --start --quiet \
-		--pidfile "$PIDFILE" \
-		--exec "$DAEMONIZE" -- -n "$SHORTNAME" -p "$PIDFILE" -l "$LOGFILE" "$PROG" $OPTIONS
+	if jsvc -cp "$CLASSPATH" -pidfile "$PIDFILE" $CLASS
 		RETVAL=$?
 	    then
 		rc=0
@@ -106,11 +123,11 @@ stop() {
     count="0"
 
     echo -n $"Stopping $PROGNAME" "$SHORTNAME"
-    start-stop-daemon --stop --quiet --oknodo --pidfile "$PIDFILE"
+    jsvc -pidfile "$PIDFILE" -stop $CLASS
 
     until [ "$count" -gt "$SHUTDOWN_WAIT" ]
     do
-        agentPid=`ps aux|grep [j]ava|grep cloud-agent`
+        agentPid=`ps aux|grep [j]svc|grep cloud-agent`
         if [ "$?" -gt "0" ];then
             break
         fi
@@ -118,16 +135,16 @@ stop() {
         let count="${count}+1"
     done
 
-    agentPid=`ps aux|grep [j]ava|grep cloud-agent`
+    agentPid=`ps aux|grep [j]svc|grep cloud-agent`
     if [ "$?" -eq "0" ]; then
-         agentPid=`ps aux|grep [j]ava|awk '{print $2}'`
+         agentPid=`ps aux|grep [j]svc|awk '{print $2}'`
          if [ "$agentPid" != "" ]; then
               kill -9 $agentPid
          fi
     fi
 
-	log_end_msg $?
-	rm -f "$PIDFILE"
+    log_end_msg $?
+    rm -f "$PIDFILE"
 }
 
 

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/5c5a4e3a/agent/distro/rhel/SYSCONFDIR/rc.d/init.d/cloud-agent.in
----------------------------------------------------------------------
diff --git a/agent/distro/rhel/SYSCONFDIR/rc.d/init.d/cloud-agent.in b/agent/distro/rhel/SYSCONFDIR/rc.d/init.d/cloud-agent.in
index d98d6e2..488ced2 100644
--- a/agent/distro/rhel/SYSCONFDIR/rc.d/init.d/cloud-agent.in
+++ b/agent/distro/rhel/SYSCONFDIR/rc.d/init.d/cloud-agent.in
@@ -33,17 +33,34 @@ PIDFILE=@PIDDIR@/"$whatami".pid
 LOCKFILE=@LOCKDIR@/"$SHORTNAME"
 LOGFILE=@AGENTLOG@
 PROGNAME="Cloud Agent"
+CLASS="com.cloud.agent.AgentShell"
 
 unset OPTIONS
 [ -r @SYSCONFDIR@/sysconfig/"$SHORTNAME" ] && source @SYSCONFDIR@/sysconfig/"$SHORTNAME"
-DAEMONIZE=@BINDIR@/@PACKAGE@-daemonize
-PROG=@LIBEXECDIR@/agent-runner
+
+# The first existing directory is used for JAVA_HOME (if JAVA_HOME is not defined in $DEFAULT)
+JDK_DIRS="/usr/lib/jvm/java-6-openjdk /usr/lib/jvm/java-6-openjdk-i386 /usr/lib/jvm/java-6-openjdk-amd64
/usr/lib/jvm/java-6-sun /usr/lib/jvm/java-1.5.0-sun /usr/lib/j2sdk1.5-sun /usr/lib/j2sdk1.5-ibm"
+
+for jdir in $JDK_DIRS; do
+    if [ -r "$jdir/bin/java" -a -z "${JAVA_HOME}" ]; then
+        JAVA_HOME="$jdir"
+    fi
+done
+export JAVA_HOME
+
+SCP="@SYSTEMCLASSPATH@"
+DCP="@DEPSCLASSPATH@"
+ACP="@AGENTCLASSPATH@"
+JCP="/usr/share/java/commons-daemon.jar"
+
+# We need to append the JSVC daemon JAR to the classpath
+# AgentShell implements the JSVC daemon methods
+export CLASSPATH="$SCP:$DCP:$ACP:$JCP:@AGENTSYSCONFDIR@"
 
 start() {
         echo -n $"Starting $PROGNAME: "
 	if hostname --fqdn >/dev/null 2>&1 ; then
-		daemon --check=$SHORTNAME --pidfile=${PIDFILE} "$DAEMONIZE" \
-			-n "$SHORTNAME" -p "$PIDFILE" -l "$LOGFILE" "$PROG" $OPTIONS
+		jsvc -cp "$CLASSPATH" -pidfile "$PIDFILE" $CLASS
 		RETVAL=$?
 		echo
 	else
@@ -58,7 +75,7 @@ start() {
 
 stop() {
 	echo -n $"Stopping $PROGNAME: "
-	killproc -p ${PIDFILE} $SHORTNAME # -d 10 $SHORTNAME
+	jsvc -pidfile "$PIDFILE" -stop $CLASS
 	RETVAL=$?
 	echo
 	[ $RETVAL = 0 ] && rm -f ${LOCKFILE} ${PIDFILE}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/5c5a4e3a/agent/distro/sles/SYSCONFDIR/init.d/cloud-agent.in
----------------------------------------------------------------------
diff --git a/agent/distro/sles/SYSCONFDIR/init.d/cloud-agent.in b/agent/distro/sles/SYSCONFDIR/init.d/cloud-agent.in
index 4046d22..4f6f04d 100644
--- a/agent/distro/sles/SYSCONFDIR/init.d/cloud-agent.in
+++ b/agent/distro/sles/SYSCONFDIR/init.d/cloud-agent.in
@@ -1,8 +1,8 @@
 #!/bin/bash
 ### BEGIN INIT INFO
 # Provides:          cloud agent
-# Required-Start:    $network
-# Required-Stop:     $network
+# Required-Start:    $network 
+# Required-Stop:     $network 
 # Default-Start:     3 4 5
 # Default-Stop:      0 1 2 6
 # X-Interactive:     true
@@ -29,7 +29,7 @@
 # WARNING: if this script is changed, then all other initscripts MUST BE changed to match
it as well
 
 . /lib/lsb/init-functions
-. /etc/rc.status
+. /etc/default/rcS
 
 whatami=cloud-agent
 
@@ -40,17 +40,37 @@ PIDFILE=@PIDDIR@/"$whatami".pid
 LOCKFILE=@LOCKDIR@/"$SHORTNAME"
 LOGFILE=@AGENTLOG@
 PROGNAME="Cloud Agent"
+CLASS="com.cloud.agent.AgentShell"
 
 unset OPTIONS
 [ -r @SYSCONFDIR@/default/"$SHORTNAME" ] && source @SYSCONFDIR@/default/"$SHORTNAME"
-DAEMONIZE=@BINDIR@/@PACKAGE@-daemonize
-PROG=@LIBEXECDIR@/agent-runner
+
+# The first existing directory is used for JAVA_HOME (if JAVA_HOME is not defined in $DEFAULT)
+JDK_DIRS="/usr/lib/jvm/java-6-openjdk /usr/lib/jvm/java-6-openjdk-i386 /usr/lib/jvm/java-6-openjdk-amd64
/usr/lib/jvm/java-6-sun /usr/lib/jvm/java-1.5.0-sun /usr/lib/j2sdk1.5-sun /usr/lib/j2sdk1.5-ibm"
+
+for jdir in $JDK_DIRS; do
+    if [ -r "$jdir/bin/java" -a -z "${JAVA_HOME}" ]; then
+        JAVA_HOME="$jdir"
+    fi
+done
+export JAVA_HOME
+
+SCP="@SYSTEMCLASSPATH@"
+DCP="@DEPSCLASSPATH@"
+ACP="@AGENTCLASSPATH@"
+JCP="/usr/share/java/commons-daemon.jar"
+
+# We need to append the JSVC daemon JAR to the classpath
+# AgentShell implements the JSVC daemon methods
+export CLASSPATH="$SCP:$DCP:$ACP:$JCP:@AGENTSYSCONFDIR@"
 
 wait_for_network() {
     i=1
     while [ $i -lt 10 ]
     do
-        if ip addr show cloudbr0 |grep -w inet > /dev/null 2>&1; then
+        # Under Ubuntu and Debian libvirt by default creates a bridge called virbr0.
+        # That's why we want more then 3 lines back from brctl, so that there is a manually
created bridge
+        if [ "$(brctl show|wc -l)" -gt 2 ]; then
             break
         else
             sleep 1
@@ -75,12 +95,9 @@ start() {
 		exit 1
 	fi
 
-    #FIXME: wait for network
-    wait_for_network
+        wait_for_network
 
-	if start-stop-daemon --start --quiet \
-		--pidfile "$PIDFILE" \
-		--exec "$DAEMONIZE" -- -n "$SHORTNAME" -p "$PIDFILE" -l "$LOGFILE" "$PROG" $OPTIONS
+	if jsvc -cp "$CLASSPATH" -pidfile "$PIDFILE" $CLASS
 		RETVAL=$?
 	    then
 		rc=0
@@ -106,11 +123,11 @@ stop() {
     count="0"
 
     echo -n $"Stopping $PROGNAME" "$SHORTNAME"
-    start-stop-daemon --stop --quiet --oknodo --pidfile "$PIDFILE"
+    jsvc -pidfile "$PIDFILE" -stop $CLASS
 
     until [ "$count" -gt "$SHUTDOWN_WAIT" ]
     do
-        agentPid=`ps aux|grep [j]ava|grep cloud-agent`
+        agentPid=`ps aux|grep [j]svc|grep cloud-agent`
         if [ "$?" -gt "0" ];then
             break
         fi
@@ -118,16 +135,16 @@ stop() {
         let count="${count}+1"
     done
 
-    agentPid=`ps aux|grep [j]ava|grep cloud-agent`
+    agentPid=`ps aux|grep [j]svc|grep cloud-agent`
     if [ "$?" -eq "0" ]; then
-         agentPid=`ps aux|grep [j]ava|awk '{print $2}'`
+         agentPid=`ps aux|grep [j]svc|awk '{print $2}'`
          if [ "$agentPid" != "" ]; then
               kill -9 $agentPid
          fi
     fi
 
-	log_end_msg $?
-	rm -f "$PIDFILE"
+    log_end_msg $?
+    rm -f "$PIDFILE"
 }
 
 


Mime
View raw message