tomcat微服务迁移
shell脚本 -- 拉取代码包
背景:上线项目,更新项目包
#!/bin/bash
#====================================================
# Description: Update the package for PE.
#====================================================
PKG_NAME="ROOT"
TOMCAT_PORT="8080"
FTP="ftp://x.x.x.x:21/"
WAR_NAME="${PKG_NAME}.war"
TOMCAT_PATH="/data/tomcat-${TOMCAT_PORT}/webapps/"
BAK_PATH="/data/backup/${PKG_NAME}"
# Create dir.
if [ ! -d "$BAK_PATH" ];then
mkdir -p "${BAK_PATH}"
fi
# Update package and restart tomcat.
/etc/init.d/tomcat-${TOMCAT_PORT} stop
cd ${TOMCAT_PATH}
cp ${WAR_NAME} ${BAK_PATH}/${WAR_NAME}.$(date +%Y-%m-%d-%H%M.bak)
rm -rf ${TOMCAT_PATH}${PKG_NAME}
rm -rf ${TOMCAT_PATH}${WAR_NAME}
>${TOMCAT_PATH}../catalina.out
#wget ${FTP}/${WAR_NAME}
wget -nH -m --ftp-user=xxx --ftp-password=xxx ${FTP}/${WAR_NAME}
/etc/init.d/tomcat-${TOMCAT_PORT} start
sleep 5
# Check.
echo ""
echo -e "\033[32m=======================Checkout=========================\033[0m"
echo ""
curl -I 127.0.0.1:${TOMCAT_PORT}/${PKG_NAME}
~