tomcat应用自动部署脚本

脚本 Story 144浏览 0评论

从远程服务器拷贝项目war包,替换web内容及properties文件

运行命令:

xx.sh xxx(项目名称)

#!/bin/bash

RETVAL=0
workpath=/cache1
projects=($*)
cd $workpath/web
for project in ${projects[@]}
do
# \scp -P 端口 root@IP:/opt/xxx/xxx/xxx.war ./
/bin/bash tomcat-xxx-$project stop
rm -rf $workpath/tomcat-xxx-$project/webapps/$project/*
sleep 1
unzip $workpath/web/"$project".war -d $workpath/tomcat-xxx-$project/webapps/$project/ >/dev/null 2>&1
RETVAL=$?
chown tomcat.tomcat $workpath/tomcat-xxx-$project/webapps/$project -R
if [ $RETVAL -eq 0 ];then
   echo "$project is ok!"
else
   echo "$project isn't ok!"
   exit 1
fi
done
\cp -a /cache1/web/$project.properties /cache1/tomcat-xxx-$project/webapps/$project/WEB-INF/classes/
/bin/bash tomcat-xxx-$project start
if [ $? -eq 0 ];then
   exit 0
else
   echo "Something is wrong"
exit 0
fi

转载请注明:成长的对话 » tomcat应用自动部署脚本