Skip to content
This repository has been archived by the owner on Aug 30, 2024. It is now read-only.

Commit

Permalink
Added new script to start/stop walrus and sc
Browse files Browse the repository at this point in the history
  • Loading branch information
graziano committed Aug 3, 2009
1 parent 2318518 commit 23d314c
Show file tree
Hide file tree
Showing 8 changed files with 2,944 additions and 6,134 deletions.
8,220 changes: 2,248 additions & 5,972 deletions configure

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,9 @@ AC_CONFIG_FILES([Makedefs
tools/eucalyptus-cc:tools/eucalyptus-cc.in
tools/eucalyptus-nc:tools/eucalyptus-nc.in
tools/euca_conf:tools/euca_conf.in
tools/eucalyptus-cloud:tools/eucalyptus-cloud.in])
tools/eucalyptus-cloud:tools/eucalyptus-cloud.in
tools/eucalyptus-walrus:tools/eucalyptus-walrus.in
tools/eucalyptus-sc:tools/eucalyptus-sc.in])

AC_DEFINE_UNQUOTED(VERSION, "$VERSION")

Expand Down
85 changes: 2 additions & 83 deletions tools/euca_conf.in
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ UPGRADE_CONF=""
SETUP=""
VERSION=""
CHECK=""
LIST_SERVICES=""
ENABLE_SERVICE=""
DISABLE_SERVICE=""
TO_BACKUP="Y"
SCP="`which scp 2> /dev/null`"
RSYNC="`which rsync 2> /dev/null`"
Expand All @@ -53,9 +50,6 @@ usage () {
echo " --deregister-sc <host> remove storage controller to EUCALYPTUS"
echo " --register-clc <host> point local walrus to CLC location"
echo " --sync used only with --register-* to sync keys"
echo " --list-services list installed eucalyptus services"
echo " --enable-service <service> enable eucalyptus service"
echo " --disable-service <service> disable eucalyptus service"
echo " --cc-port <port> set CC port"
echo " --nc-port <port> set NC port"
echo " --instances <path> set the INSTANCE path"
Expand All @@ -66,7 +60,7 @@ usage () {
echo " --dhcp_user <user> set the username to run dhcpd as"
echo " --name <var> returns the value or <name>"
echo " --setup perform initial setup"
echo " --check [nc|cc|cloud] pre-flight checks"
echo " --check [nc|cc|cloud|sc|walrus] pre-flight checks"
echo " --version eucalyptus version"
echo
}
Expand Down Expand Up @@ -196,11 +190,6 @@ while [ $# -gt 0 ]; do
shift
continue
fi
if [ "$1" = "--list-services" ]; then
LIST_SERVICES="Y"
shift
continue
fi
if [ "$1" = "-version" -o "$1" = "--version" ]; then
VERSION="Y"
shift
Expand Down Expand Up @@ -255,16 +244,6 @@ while [ $# -gt 0 ]; do
shift; shift
continue
fi
if [ "$1" = "--disable-service" ]; then
DISABLE_SERVICE="$2"
shift; shift
continue
fi
if [ "$1" = "--enable-service" ]; then
ENABLE_SERVICE="$2"
shift; shift
continue
fi
if [ "$1" = "-upgrade-conf" -o "$1" = "--upgrade-conf" ]; then
# hidden options to upgrade from an older version
UPGRADE_CONF="$2"
Expand Down Expand Up @@ -531,66 +510,6 @@ fi
# we need defaults in eucalyptus.conf
. $FILE

# list available services
if [ -n "$LIST_SERVICES" -o -n "$ENABLE_SERVICE" -o -n "$DISABLE_SERVICE" ]; then
if [ -e $EUCALYPTUS/etc/init.d/eucalyptus-cc ]; then
CONFIG_OPTS="`$EUCALYPTUS/etc/init.d/eucalyptus-cc config 2> /dev/null`"
elif [ -e $EUCALYPTUS/etc/init.d/eucalyptus-nc ]; then
CONFIG_OPTS="`$EUCALYPTUS/etc/init.d/eucalyptus-nc config 2> /dev/null`"
fi
if [ -n "$CONFIG_OPTS" ]; then
eval $CONFIG_OPTS
fi

if [ -n "$LIST_SERVICES" ]; then
for x in ` ls $AXIS2C_HOME/services 2> /dev/null` ; do
if [ -d $AXIS2C_HOME/services/${x} ]; then
echo "${x} *"
fi
done
for x in `ls $AXIS2C_HOME/disabled 2> /dev/null` ; do
if [ -d $AXIS2C_HOME/disabled/${x} ]; then
echo "${x}"
fi
done
elif [ -n "$ENABLE_SERVICE" ]; then
DONE="N"
for x in `ls $AXIS2C_HOME/disabled 2> /dev/null` ; do
if [ "${x}" = "$ENABLE_SERVICE" ]; then
mv $AXIS2C_HOME/disabled/$x $AXIS2C_HOME/services
DONE="Y"
fi
done
for x in `ls $AXIS2C_HOME/services 2> /dev/null` ; do
if [ "${x}" = "$ENABLE_SERVICE" ]; then
if [ "$DONE" = "N" ]; then
echo "$x already enabled"
break
fi
fi
done
elif [ -n "$DISABLE_SERVICE" ]; then
DONE="N"
for x in `ls $AXIS2C_HOME/services 2> /dev/null` ; do
if [ "${x}" = "$DISABLE_SERVICE" ]; then
if [ ! -d $AXIS2C_HOME/disabled ]; then
mkdir -p $AXIS2C_HOME/disabled
fi
mv $AXIS2C_HOME/services/$x $AXIS2C_HOME/disabled
DONE="Y"
fi
done
for x in `ls $AXIS2C_HOME/disabled 2> /dev/null` ; do
if [ "${x}" = "$DISABLE_SERVICE" ]; then
if [ "$DONE" = "N" ]; then
echo "$x already disabled"
break
fi
fi
done
fi
fi

# first time setup
if [ -n "$SETUP" ]; then
ROOTWRAP="$EUCALYPTUS/usr/lib/eucalyptus/euca_rootwrap"
Expand Down Expand Up @@ -652,7 +571,7 @@ if [ -n "$CHECK" ]; then

# vblade and aoe may be needed
if [ "$DISABLE_EBS" != "Y" -a "$DISABLE_EBS" != "y" ]; then
if [ "$CHECK" = "cloud" ]; then
if [ "$CHECK" = "sc" ]; then
VBLADE="`which vblade 2> /dev/null`"
if [ -z "$VBLADE" ]; then
echo
Expand Down
20 changes: 2 additions & 18 deletions tools/eucalyptus-cc.in
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@

# Do NOT "set -e"

# if we are on rocks we need the rocks binaries
[ -e /etc/profile.d/rocks-binaries.sh ] && . /etc/profile.d/rocks-binaries.sh

# if we have lsb functions let's source them
WE_HAVE_LSB="N"
if [ -e /lib/lsb/init-functions ]; then
Expand All @@ -32,7 +29,7 @@ if [ -e /lib/lsb/init-functions ]; then
fi

if [ "$EUID" != "0" ]; then
echo "Eucalyptus must be run as root."
echo "Eucalyptus init scripts must be run as root."
exit 1
fi

Expand Down Expand Up @@ -61,16 +58,7 @@ if [ ! -x $EUCALYPTUS/usr/sbin/euca_conf ]; then
fi

create_httpd_config() {
if [ -x "/opt/rocks/bin/rocks" ]; then
# we are in the frontend: let's get frontend IP
MYNAME=`hostname -s`
IPS="127.0.0.1"
for x in "`/opt/rocks/bin/rocks list host interface $MYNAME|sed '1d'|tr -s ' '|cut -f 4 -d ' '|tr -s '\n' ' '`"; do
IPS="$IPS $x"
done
else
IPS="all"
fi
IPS="all"

# let's configure the common parts for both CC and NC
cat $EUCALYPTUS/etc/eucalyptus/httpd.conf |sed "s|EUCALYPTUS|$EUCALYPTUS|"|sed "s|AXIS2C_HOME|$AXIS2C_HOME|"|sed "s|\(ServerRoot\).*|\1 "$HTTPD_HOME"|" |sed "s|EUCA_USER|$EUCA_USER|" > $EUCALYPTUS/etc/eucalyptus/httpd-tmp.conf
Expand Down Expand Up @@ -187,10 +175,6 @@ if [ "$EUCALYPTUS" = "not_configured" ]; then
echo "EUCALYPTUS not configured!"
exit 1
fi
if [ -n "$TEMPLATE_PATH" ]; then
echo "TEMPLATE_PATH is defined: do you have an old configuration?"
exit 1
fi

if [ -z "$EUCA_USER" ] ; then
EUCA_USER="root"
Expand Down
104 changes: 58 additions & 46 deletions tools/eucalyptus-cloud.in
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
# Required-Start: $remote_fs $syslog
# Should-Start: sendmail
# Required-Stop: $remote_fs $syslog
# Should-Stop: sendmail
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start Eucalyptus cloud controller
Expand All @@ -21,11 +20,19 @@

# Do NOT "set -e"

# if we are on rocks we need the rocks binaries
[ -e /etc/profile.d/rocks-binaries.sh ] && . /etc/profile.d/rocks-binaries.sh
# we need to source the current path in case of manual intallation
export PATH=/sbin:/usr/sbin:/bin:/usr/bin:$PATH
DESC="Eucalyptus cloud controller"
NAME=eucalyptus-cloud
JAR_NAME="/usr/share/eucalyptus/eucalyptus-interface.jar"
JAR_ALL_NAMES="/usr/share/eucalyptus/eucalyptus-interface.jar /usr/share/eucalyptus/eucalyptus-storagecontroller.jar /usr/share/eucalyptus/eucalyptus-storagemgr.jar"
ANT="`which ant 2> /dev/null`"
JAVA="`which java 2> /dev/null`"
EUCA_USER="eucalyptus"


if [ "$EUID" != "0" ]; then
echo "Eucalyptus must be run as root."
echo "Eucalyptus init scripts must be run as root."
exit 1
fi

Expand All @@ -39,16 +46,6 @@ if [ -e /lib/lsb/init-functions ]; then
fi
fi

# I just wanted to set PATH to be the system PATH, but if a user install
# eucalyptus manually, it may have binaries in a non-standard position:
# hence we need to keep the PATH we receive.
export PATH=/sbin:/usr/sbin:/bin:/usr/bin:$PATH
DESC="Eucalyptus cloud controller"
NAME=eucalyptus-cloud
ANT="`which ant 2> /dev/null`"
JAVA="`which java 2> /dev/null`"
EUCA_USER="eucalyptus"

# honor the ENV variable if found otherwise look in root
if [ -z "$EUCALYPTUS" ] ; then
EUCALYPTUS="@prefix@"
Expand Down Expand Up @@ -102,17 +99,6 @@ check_java() {
do_start() {
local ret

# need to cehck if we have another cloud running
pidfile=$EUCALYPTUS/var/run/eucalyptus/eucalyptus-cloud.pid
if [ -s $pidfile ]; then
if ps `cat $pidfile` > /dev/null 2> /dev/null ; then
# there is another process with the same pid
echo
echo "Is the cloud already running?"
exit 1
fi
fi

# basic checks
check_java
if ! $EUCALYPTUS/usr/sbin/euca_conf -check cloud ; then
Expand All @@ -127,26 +113,25 @@ do_start() {
}

do_status() {
pidfile=$EUCALYPTUS/var/run/eucalyptus/eucalyptus-cc.pid
if [ ! -e ${EUCALYPTUS}${JAR_NAME} ]; then
# service is not running
return 1
fi

pidfile=$EUCALYPTUS/var/run/eucalyptus/eucalyptus-cloud.pid
if [ -s $pidfile ]; then
pid=`cat $pidfile 2> /dev/null`
if ps ax|grep $pid|grep cloud.xml> /dev/null ; then
# we are good
return 0
fi
fi
return 0
return 1
}

do_stop() {
pidfile=$EUCALYPTUS/var/run/eucalyptus/eucalyptus-cloud.pid

# let's be sure we are killing the right process
if ! do_status ; then
rm $pidfile
return
fi

# now kill the service
if [ -s "$pidfile" ]; then
pid=`cat $pidfile 2> /dev/null`
Expand Down Expand Up @@ -182,24 +167,12 @@ if [ "$EUCALYPTUS" = "not_configured" ]; then
echo "EUCALYPTUS not configured!"
exit 1
fi
if [ -n "$TEMPLATE_PATH" ]; then
echo "TEMPLATE_PATH is defined: do you have an old configuration?"
exit 1
fi

# let's get the user to use
if [ -z "$EUCA_USER" ] ; then
EUCA_USER="root"
fi

# let's see how many loop devices we have available
LOOP_AVL="`/bin/ls /dev/loop* 2> /dev/null|wc -l`"
if [ -z "$LOOP_AVL" -o "$LOOP_AVL" = "0" ]; then
echo "Couldn't find loop devices (/dev/loop*): expect problems"
elif [ $LOOP_AVL -lt 32 ]; then
echo "You should have at least 32 loop devices"
fi

# set the library path correctly
export LD_LIBRARY_PATH="$EUCALYPTUS/usr/lib/eucalyptus:$LD_LIBRARY_PATH"

Expand All @@ -212,7 +185,7 @@ case "$1" in
echo -n "Starting $DESC: "
fi
fi

# let's check there is no previous cloud running
if do_status ; then
echo
Expand All @@ -225,6 +198,18 @@ case "$1" in
exit 1
fi

# move the jar in the right place
if [ -e ${EUCALYPTUS}${JAR_NAME}.disabled ]; then
if ! cp ${EUCALYPTUS}${JAR_NAME}.disabled ${EUCALYPTUS}${JAR_NAME} ; then
echo "Failed to copy jar file into place!"
exit 1
fi
rm -f ${EUCALYPTUS}${JAR_NAME}.disabled
fi

# since other services could be running, we stop the container
# before starting
do_stop
do_start
case "$?" in
0|1)
Expand Down Expand Up @@ -255,7 +240,34 @@ case "$1" in
echo -n "Stopping $DESC: "
fi
fi

# if we don't have the JAR file we are not running
if [ ! -e ${EUCALYPTUS}${JAR_NAME} ]; then
# service is not running
exit 0
fi

# move the jar in the right place
if ! cp ${EUCALYPTUS}${JAR_NAME} ${EUCALYPTUS}${JAR_NAME}.disabled ; then
echo "Failed to copy jar file into place!"
exit 1
fi
rm -f ${EUCALYPTUS}${JAR_NAME}

# now let's stop the service
do_stop

# if we have more services running, we'll need to restart
__restart="N"
for x in $JAR_ALL_NAMES ; do
if [ -e ${EUCALYPTUS}/${x} ]; then
__restart="Y"
break
fi
done
if [ ${__restart} = "Y" ]; then
do_start
fi
if [ "$VERBOSE" != no ]; then
if [ "$WE_HAVE_LSB" = "Y" ]; then
log_end_msg 0
Expand Down
Loading

0 comments on commit 23d314c

Please sign in to comment.