tomcat自动解压,部署war包脚本
deploy.sh
用法 deploy.sh 放到tomacat 目录下
./deploy.sh war路径
#!/bin/sh
war=$1
bin=$(cd `dirname $0`; pwd)
if [ ! -n "${war}" ]; then
echo "***Usage: $0 [project.war]"
exit 0
fi
if [ ! -f "${war}" ]; then
echo "***Error: ${war} does not exist."
exit 0
fi
if [ ! "${war##*.}" = "war" ]; then
echo "***Error: ${war} is not a war file."
exit 0
fi
echo "Deploy ${war##*/}..."
rm -rf ${bin}/../webapps/ROOT/ && unzip -qo ${war} -d ${bin}/../webapps/ROOT/
rm -rf ${bin}/../work/Catalina/localhost/
echo "Restart tomcat..."
exec ${bin}/restart.sh
restart.sh 重启tomcat脚本
#!/bin/sh
bin=$(cd `dirname $0`; pwd)
pid=$(ps aux | grep tomcat | grep -v grep | grep -v restart | grep ${bin} | awk '{print $2}')
if [ -n "${pid}" ]; then
echo "Shutdown..."
sh ${bin}/shutdown.sh
sleep 3
pid=$(ps aux | grep tomcat | grep -v grep | grep -v restart | grep ${bin} | awk '{print $2}')
if [ -n "${pid}" ]; then
kill -9 ${pid}
sleep 1
fi
fi
echo "Startup..."
sh ${bin}/startup.sh
if [ "$1" = "-v" ]; then
tail -f ${bin}/../logs/catalina.out
fi