tomcat应用自动部署脚本

从远程服务器拷贝项目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

weinxin
聂扬帆博客
一个分享IT运维相关工作经验和实战技巧的个人博客

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: