#!/bin/bash
# jar包地址
JAR_DIR=/opt/zhgdpt/prod/
# supervisord启动配置文件iniwen文件位置
SUPERVISOR_DIR=/etc/supervisord.d/
# 备份java路径
JAR_DIR_COPY=/opt/zhgdpt/$(date +%Y%m%d%H)/
# html 路径
NGINX_DIR=/data/nginx/html/
# html备份路径
NGINX_DIR_COPY=/data/nginx/html/$(date +%Y%m%d%H)/
# 通过页面上传的压缩包路径(包含 html文件、jar文件、nginx配置文件、supervisord的ini配置文件、需要执行的sql)
UPGRADE_DIR=/opt/zhgdpt/upgrade/init/
echo '升级前端包'
cd ${NGINX_DIR}
if [ -d ${UPGRADE_DIR}html/ ]; then
if [ -e ${UPGRADE_DIR}/html/zhgdpt.zip ];then
echo "前端zhgdpt部署"
if [ ! -d ${NGINX_DIR_COPY} ];then
mkdir $(date +%Y%m%d%H)
fi
mv ${NGINX_DIR}zhgdpt.zip ${NGINX_DIR_COPY}
cp ${UPGRADE_DIR}/html/zhgdpt.zip ${NGINX_DIR}
rm -rf zhgdpt
unzip zhgdpt.zip
else
echo "${UPGRADE_DIR}html/zhgdpt.zip 不存在"
fi
if [ -e ${UPGRADE_DIR}/html/zhgdptDp.zip ];then
echo "前端zhgdptDp部署"
if [ ! -d ${NGINX_DIR_COPY} ];then
mkdir $(date +%Y%m%d%H)
fi
mv ${NGINX_DIR}zhgdptDp.zip ${NGINX_DIR_COPY}
cp ${UPGRADE_DIR}/html/zhgdptDp.zip ${NGINX_DIR}
rm -rf zhgdptDp
unzip zhgdptDp.zip
else
echo "${UPGRADE_DIR}html/zhgdptDp.zip 不存在"
fi
else
echo "${UPGRADE_DIR}html目录 不存在"
fi
echo '升级jar包'
if [ -d ${UPGRADE_DIR}jar/ ];then
if [ ! -d ${JAR_DIR_COPY} ];then
cd /opt/zhgdpt
mkdir $(date +%Y%m%d%H)
else
echo "${JAR_DIR_COPY}目录存在"
fi
cd ${UPGRADE_DIR}jar
for filename in *; do
if [ -e ${UPGRADE_DIR}jar/${filename} ];then
mv ${JAR_DIR}${filename} ${JAR_DIR_COPY}
cp ${UPGRADE_DIR}jar/${filename} ${JAR_DIR}
if [ ${filename} == gateway.jar ]; then
echo "gateway服务重启"
nohup supervisorctl restart zhgdptProd-gateway-10000 >/tmp/upgrade.log 2>&1 & # nohup:不中断执行 &:后台执行 >/tmp/upgrade.log:输出执行日志
echo "gateway-执行完成---"
fi
if [ ${filename} == authentication.jar ]; then
echo "authentication服务重启"
nohup supervisorctl restart zhgdptProd-authentication-9001 >/tmp/upgrade.log 2>&1 &
echo "authentication-执行完成---"
fi
if [ ${filename} == sys-rbac.jar ]; then
echo "sys-rbac服务重启"
nohup supervisorctl restart zhgdptProd-sys-rbac-9999 >/tmp/upgrade.log 2>&1 &
echo "rbac-执行完成---"
fi
if [ ${filename} == adminserver.jar ]; then
echo "adminserver服务重启"
nohup supervisorctl restart zhgdptProd-adminserver-8769 >/tmp/upgrade.log 2>&1 &
echo "adminserver-执行完成---"
fi
if [ ${filename} == xxl-job-admin.jar ]; then
echo "xxl-job-admin服务重启"
nohup supervisorctl restart zhgdptProd-xxl-job-admin-8087 >/tmp/upgrade.log 2>&1 &
echo "admin-执行完成---"
fi
if [ ${filename} == library-factory.jar ]; then
echo "library-factory服务重启"
nohup supervisorctl restart zhgdptProd-library-factory-9911 >/tmp/upgrade.log 2>&1 &
echo "factory-执行完成---"
fi
if [ ${filename} == ejjzhgd-daping.jar ]; then
echo "ejjzhgd-daping服务重启"
nohup supervisorctl restart zhgdptProd-daping-9031 >/tmp/upgrade.log 2>&1 &
echo "daping-执行完成---"
fi
if [ ${filename} == ejjzhgd-gps-device.jar ]; then
echo "server-gps-device服务重启"
nohup supervisorctl restart zhgdptProd-gps-device-9080 >/tmp/upgrade.log 2>&1 &
echo "device-执行完成---"
fi
if [ ${filename} == ejjzhgd-daping-new.jar ]; then
echo "ejjzhgd-daping-new服务重启"
nohup supervisorctl restart zhgdptProd-daping-new-9050 >/tmp/upgrade.log 2>&1 &
echo "daping-new-执行完成---"
fi
if [ ${filename} == ejjzhgd-open.jar ]; then
echo "ejjzhgd-open服务重启"
nohup supervisorctl restart zhgdptProd-open-9036 >/tmp/upgrade.log 2>&1 &
echo "open-执行完成---"
fi
if [ ${filename} == ejjzhgd-platform-box.jar ]; then
echo "ejjzhgd-platform-box服务重启"
nohup supervisorctl restart zhgdptProd-platform-box-9041 >/tmp/upgrade.log 2>&1 &
echo "box-执行完成---"
fi
if [ ${filename} == ejjzhgd-platform-transfer.jar ]; then
echo "ejjzhgd-platform-transfer服务重启"
nohup supervisorctl restart zhgdptProd-platform-transfer-9040 >/tmp/upgrade.log 2>&1 &
echo "transfer-执行完成---"
fi
if [ ${filename} == ejjzhgd-platform-convert-base64.jar ]; then
echo "ejjzhgd-platform-convert-base64服务重启"
nohup supervisorctl restart zhgdptProd-platform-convert-base64-9042 >/tmp/upgrade.log 2>&1 &
echo "base64-执行完成---"
fi
if [ ${filename} == ejjzhgd-platform-upgrade.jar ]; then
echo "ejjzhgd-platform-upgrade---服务重启"
nohup supervisorctl restart zhgdptProd-platform-upgrade-9039 >/tmp/upgrade.log 2>&1 &
echo "upgrade-执行完成---"
fi
if [ ${filename} == ejjzhgd-sjsb.jar ]; then
echo "ejjzhgd-sjsb服务重启"
nohup supervisorctl restart zhgdptProd-sjsb-9060 >/tmp/upgrade.log 2>&1 &
echo "sjsb-执行完成---"
fi
if [ ${filename} == ejjzhgd-sys-ext.jar ]; then
echo "ejjzhgd-sys-ext服务重启"
nohup supervisorctl restart zhgdptProd-sys-ext-9033 >/tmp/upgrade.log 2>&1 &
echo "ext-执行完成---"
fi
if [ ${filename} == ejjzhgd-video.jar ]; then
echo "ejjzhgd-platform-video服务重启"
nohup supervisorctl restart zhgdptProd-video-9032 >/tmp/upgrade.log 2>&1 &
echo "video-执行完成---"
fi
if [ ${filename} == ejjzhgd-video-uvp.jar ]; then
echo "ejjzhgd-video-uvp服务重启"
nohup supervisorctl restart zhgdptProd-video-uvp-9038 >/tmp/upgrade.log 2>&1 &
echo "uvp-执行完成---"
fi
if [ ${filename} == ejjzhgd-web.jar ]; then
echo "ejjzhgd-web服务重启"
nohup supervisorctl restart zhgdptProd-web-9030 >/tmp/upgrade.log 2>&1 &
echo "web-执行完成---"
fi
if [ ${filename} == ejjzhgd-ws.jar ]; then
echo "ejjzhgd-ws服务重启"
nohup supervisorctl restart zhgdptProd-ws-9037 >/tmp/upgrade.log 2>&1 &
echo "ws-执行完成---"
fi
else
echo "${UPGRADE_DIR}jar/${filename} 不存在"
fi
done
else
echo "${UPGRADE_DIR}jar目录 不存在"
fi
echo '升级supervisor'
if [ -d ${UPGRADE_DIR}supervisor/ ];then
cd ${SUPERVISOR_DIR}
cp ${UPGRADE_DIR}supervisor/* ${SUPERVISOR_DIR}
supervisorctl reload
else
echo "${UPGRADE_DIR}supervisor 目录不存在"
fi
echo '升级nginx'
if [ -d ${UPGRADE_DIR}nginx/ ];then
cp ${UPGRADE_DIR}nginx/* /data/nginx/conf/
cd /data/nginx/
./sbin/nginx -s reload
else
echo "${UPGRADE_DIR}nginx 目录不存在"
fi
# 最后删除通过页面上传的压缩包
rm -rf /opt/zhgdpt/upgrade/
系统自动升级部署shell脚本
最新推荐文章于 2024-03-20 10:07:55 发布