自动化安装和启动DS脚本

本文介绍了一个用于安装和配置Fabric Broker及Engine的Shell脚本。该脚本还支持部署各种容器和分布式的操作,如Tomcat、JBoss等,并提供了一些实用的功能,例如重启服务器、列出Gridlib文件等。
摘要由CSDN通过智能技术生成
#!/bin/sh

#fabric broker path
FABRIC_HOME=/opt/qa/fabric/4.0
INSTALL_DIR=$FABRIC_HOME/datasynapse
GRIDLIB_DIR=$INSTALL_DIR/webapps/livecluster/deploy/resources/gridlib/

#fabric engine path
Engine_HOME=/opt/qa/engine
ENGINE_DIR=$Engine_HOME/stress0

TASK=$1

#fabric build info
BUILD_VERSION=4.1
SUB_VERSION=$2
FULL_VERSION=$BUILD_VERSION.$SUB_VERSION
BUILD_DIR=/u2/Releases/internal/Fabric_Builds/
TARGET_DIR=$BUILD_DIR$BUILD_VERSION/$FULL_VERSION
DISTRI_DIR=/u2/testing/currentversion/fabric/trunk/distributions/

#fabric WS env
FABRIC_TRUNK=/u2/testing/currentversion/fabric/trunk
FABRICSDK_HOME=$FABRIC_TRUNK/FabricServerSDK
TESTHARNESS2_DIR=$FABRIC_TRUNK/compiled_code/testharness-2

installBroker(){

if [ -d $INSTALL_DIR ];then
echo "... $INSTALL_DIR is existing!"
cd $INSTALL_DIR
echo "... server is stopping ..."
./server.sh stop > ../installBroker.log
echo "... server stopped!"
cd ..
rm -rf datasynapse/
echo "... $INSTALL_DIR removed!"
fi

if [ ! -d $FABRIC_HOME ];then
echo "... $FABRIC_HOME is not existing!"
mkdir $FABRIC_HOME
echo "... $FABRIC_HOME created!"
cd $FABRIC_HOME
fi

gunzip -c $TARGET_DIR/TIB_Silver_Fabric.$BUILD_VERSION.0.tar.gz > $FABRIC_HOME/TIB_Silver_Fabric.$BUILD_VERSION.0.tar
tar -xvf $FABRIC_HOME/TIB_Silver_Fabric.$BUILD_VERSION.0.tar >> installBroker.log
echo "... TIB_Silver_Fabric.$BUILD_VERSION.0.tar.gz unzipped!"
rm -rf $FABRIC_HOME/TIB_Silver_Fabric.$BUILD_VERSION.0.tar
unzip -o $TARGET_DIR/TIB_Silver_Fabric.$BUILD_VERSION.0_3rd-Party-Libs.zip -d $INSTALL_DIR >> ../installBroker.log
echo "... TIB_Silver_Fabric.$BUILD_VERSION.0_3rd-Party-Libs.zip unzipped!"
cd $INSTALL_DIR
echo "... server is starting ..."
./server.sh start
}

installEngine(){

if [ -z $BROKER_HOST ]
then
echo "engine host not set yet"
exit 1
fi

if [ -z $ENGINE_TYPE ]
then
echo "engine type not set yet"
echo "(SolarisX86|Linux64|Linux|Solaris|Aix)"
exit 1
fi

ENGINE_URL=http://$BROKER_HOST:8080/livecluster/public_html/register/install/unixengine/DSEngine$ENGINE_TYPE.tar.gz

if [ -d $ENGINE_DIR/DSEngine ];then
echo "... $ENGINE_DIR/DSEngine is existing!"
cd $ENGINE_DIR/DSEngine
./engine.sh stop > ../installEngine.log
cd ..
rm -rf DSEng*
echo "$ENGINE_DIR/DSEngine removed!"
else
mkdir $ENGINE_DIR
echo "$ENGINE_DIR created!"
cd $ENGINE_DIR
fi

wget $ENGINE_URL -o installEngine.log
echo "... DSEngine$ENGINE_TYPE.tar.gz downloaded!"
gzip -d DSEngine$ENGINE_TYPE.tar.gz
tar -xvf DSEngine$ENGINE_TYPE.tar >> installEngine.log
echo "... DSEngine$ENGINE_TYPE.tar.gz unzipped!"

cd DSEngine

./configure.sh -s $BROKER_HOST:8000 >> ../installEngine.log
echo "... new engine configured!"
echo "... new engine starting!"
./engine.sh start

}

deployContainers(){

for i in tomcat jboss weblogic websphere iis
do
if [ $CONTAINER = all ]; then
source=$TARGET_DIR/$i*.zip
source=$source" "
cp $source $GRIDLIB_DIR
elif [ $CONTAINER = $i ]; then
cp $TARGET_DIR/$i*.zip $GRIDLIB_DIR
else
continue
fi
done

}

deployDistributions(){

for i in tomcat jboss weblogic websphere iis
do
if [ $CONTAINER = all ]; then
source=$DISTRI_DIR/$i*.zip
source=$source" "
cp $source $GRIDLIB_DIR
elif [ $CONTAINER = $i ]; then
cp $DISTRI_DIR/$i*.zip $GRIDLIB_DIR
else
continue
fi
done
}

deployContainerDistribution(){

if [ -z $CONTAINER_VERSION ]; then
echo -e "container version not set yet\nSample: deployCD 0.5 jboss -eap4_3_0,4_2_1"
exit 1
fi

for v in `echo $CONTAINER_VERSION| sed 's/,/ /g'`
do
if [ $CONTAINER = websphere ]; then
PLATFORM=`echo ${v##*-}`
VERSION=`echo ${v%%-*}`
cp $DISTRI_DIR/ibm-j2sdk-$PLATFORM-*.zip $GRIDLIB_DIR
cp $TARGET_DIR/$CONTAINER$VERSION-container-gridlib.zip $GRIDLIB_DIR
cp $DISTRI_DIR/$CONTAINER$v-distribution-gridlib.zip $GRIDLIB_DIR
elif [ $CONTAINER = webspheredm ]; then
PLATFORM=`echo ${v##*-}`
VERSION=`echo ${v%%-*}`
cp $DISTRI_DIR/ibm-j2sdk-$PLATFORM-*.zip $GRIDLIB_DIR
cp $TARGET_DIR/$CONTAINER$VERSION-container-gridlib.zip $GRIDLIB_DIR
_CONTAINER=`echo ${CONTAINER%%dm*}`
cp $DISTRI_DIR/$_CONTAINER$v-distribution-gridlib.zip $GRIDLIB_DIR
else
cp $TARGET_DIR/$CONTAINER$v-container-gridlib.zip $GRIDLIB_DIR
cp $DISTRI_DIR$CONTAINER$v-distribution-gridlib.zip $GRIDLIB_DIR
fi
done
}

setupWsEnv(){
export CLASSPATH=$TESTHARNESS2_DIR/fabric/classes/fabrictestharness_client.jar:$TESTHARNESS2_DIR/fabric/classes/fabrictestharness_server.jar:$TESTHARNESS2_DIR/util/lib/httpunit.jar:$TESTHARNESS2_DIR/fabric/util/parameters:$TESTHARNESS2_DIR/util/lib/jaxrpc.jar:$TESTHARNESS2_DIR/util/lib/axis.jar:$TESTHARNESS2_DIR/util/lib/commons-logging-1.0.4.jar:$TESTHARNESS2_DIR/util/lib/commons-discovery-0.2.jar:$TESTHARNESS2_DIR/util/lib/wsdl4j-1.5.1.jar:$TESTHARNESS2_DIR/util/lib/commons-httpclient-3.0.jar:$TESTHARNESS2_DIR/util/lib/commons-codec-1.3.jar
echo $CLASSPATH

}

checkSubVersion(){
if [ -z $SUB_VERSION ]
then
echo "sub version number not set yet"
exit
fi
}

checkContainerName(){
if [ -z $CONTAINER ]
then
echo -e "container not set yet\ncontainer list:\ntomcat jboss weblogic websphere"
exit 1
fi
}

restartServer(){
cd "$INSTALL_DIR"
./server.sh stop >> ../installBroker.log
echo "... server stopped!"
./server.sh start >> ../installBroker.log
echo "... server started!"
cd "$FABRIC_HOME"
}

listGlidlib(){
echo -e "$TESTHARNESS2_DIR/fabric/server/glz/$FOLDER"
ls -C "$TESTHARNESS2_DIR/fabric/server/glz/$FOLDER"
}

listDistribution(){
echo -e "$DISTRI_DIR"
ls -C "$DISTRI_DIR"
}

listFSGridLibDir(){
echo -e "$GRIDLIB_DIR"
ls -C "$GRIDLIB_DIR"
}

copyGridlib(){
cp -f "$TESTHARNESS2_DIR/fabric/server/glz/$FOLDER/$GRIDLIB" "$GRIDLIB_DIR"
echo -e "copied \n$TESTHARNESS2_DIR/fabric/server/glz/$FOLDER/$GRIDLIB\n to"
find "$GRIDLIB_DIR" -name "$GRIDLIB"
}

usage(){
echo -e "usage:\n"
echo "setupBroker|setupB"
echo -e "Sample: setupB 0.6\n"
echo "setupEngine|setupE"
echo -e "Sample: setupE qalx03 SolarisX86\n"
echo "deployContainer|deployC"
echo -e "Sample: deployC tomcat\n"
echo "deployDistribution|deployD"
echo -e "Sample: deployD websphere\n"
echo "deployContainerDistribution|deployCD"
echo "Sample: deployCD 0.6 jboss 4_2_1,-eap4_3_0,-eap5_0_0"
echo " deployCD 0.6 websphere 7_0-linux,7_0-linux64"
echo -e " deployCD 0.6 weblogic 10_0,8_1_sp4\n"
echo "setupWS"
echo -e "Sample: . ./installFS.sh setupWS\n"
echo -e "restartBroker|restartB\n"
echo "listGridlibs|lsglz"
echo -e "Sample: lsglz no-deploy\n"
echo "copyGridlibs|cpgl"
echo -e "Sample: cpgl deploy jbosswebappgenericservicedomain-gridlib.zip\n"
echo -e "listDistribution|lsD\n"
echo -e "listFSGridlib|lsfsglz\n"
}

if [ -z $TASK ]
then
echo "Task not set yet"
exit
fi

case "$TASK" in
setupBroker | setupB)
SUB_VERSION=$2
checkSubVersion
installBroker $SUB_VERSION;;
setupEngine | setupE)
BROKER_HOST=$2
ENGINE_TYPE=$3
echo "host $BROKER_HOST enginetype $ENGINE_TYPE"
installEngine $BROKER_HOST $ENGINE_TYPE;;
deployContainer | deployC)
checkSubVersion
CONTAINER=$3
checkContainerName
deployContainers $CONTAINER;;
deployDistribution | deployD)
checkSubVersion
CONTAINER=$3
checkContainerName
deployDistributions $CONTAINER;;
deployContainerDistribution | deployCD)
checkSubVersion
CONTAINER=$3
checkContainerName
CONTAINER_VERSION=$4
deployContainerDistribution $CONTAINER $CONTAINER_VERSION;;
setupWS)
setupWsEnv;;
restartBroker | restartB)
restartServer;;
listGridlibs | lsglz)
FOLDER=$2
listGlidlib $FOLDER;;
copyGridlibs | cpgl)
FOLDER=$2
GRIDLIB=$3
copyGridlib $FOLDER $GRIDLIB;;
listDistribution | lsD)
listDistribution;;
listFSGridlib | lsfsglz)
listFSGridLibDir;;
*)
usage;;

esac
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值