You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
67 lines
1.7 KiB
67 lines
1.7 KiB
#!/bin/bash
|
|
#更新容器的服务
|
|
|
|
|
|
CONTAINER_CODE=$1 #容器编号
|
|
BRANCH_NAME=$2 #构建分支
|
|
RESET_DATA=$3 #是否需要清理数据
|
|
|
|
IMPORT_DATA=$4 #是否导入数据
|
|
|
|
PACKAGE_PATH=/data/wwwroot/release_package/${BRANCH_NAME}_anhei/Linux/
|
|
|
|
cd ${PACKAGE_PATH}
|
|
FILE_NAME=$(ls -t | head -n 1)
|
|
FILE_PATH=${PACKAGE_PATH}${FILE_NAME} #执行文件位置
|
|
##挂载路径
|
|
MOUNT_PATH=/data/mmogrun/
|
|
#映射端口
|
|
|
|
OUT_MOUNT_PATH=${MOUNT_PATH}${CONTAINER_CODE} ##外部挂载目录
|
|
cp -rf "${FILE_PATH}" "${OUT_MOUNT_PATH}"
|
|
# shellcheck disable=SC2164
|
|
cd "${OUT_MOUNT_PATH}"
|
|
PID=$(cat maintainer.pid)
|
|
## 先停服通知
|
|
PUSHER=/data/anhei/docker/3rd/feishu/pusher.sh
|
|
sh ${PUSHER} "${CONTAINER_CODE}" "开始重启服务器"
|
|
docker exec "${PID}" sh -c "cd ${MOUNT_PATH}publish/ctrl_sh/ && ./stop_all.sh"
|
|
|
|
#再解压
|
|
tar -zxvf "${FILE_PATH}"
|
|
docker exec "${PID}" sh -c "sh /3rd/replace.sh ${CONTAINER_CODE}"
|
|
|
|
#导入数据
|
|
# shellcheck disable=SC2170
|
|
|
|
NONE="none"
|
|
if [ "${IMPORT_DATA}" = "${NONE}" ]; then ####shell 字符串比较是一个等号,TMD
|
|
echo "不需要导入db数据"
|
|
else
|
|
echo "需要导入线上数据:"${IMPORT_DATA}
|
|
docker exec "${PID}" sh -c "sh /3rd/import_db.sh ${IMPORT_DATA}"
|
|
RESET_DATA=1 #导入数据强制重新清理库
|
|
fi
|
|
|
|
if [ "${RESET_DATA}" -eq 1 ]; then
|
|
docker exec "${PID}" sh -c "sh /3rd/clear_db.sh ${CONTAINER_CODE}"
|
|
else
|
|
echo "不清理数据"
|
|
fi
|
|
|
|
|
|
|
|
|
|
docker exec "${PID}" sh -c "cd ${MOUNT_PATH}publish/ctrl_sh/ && ./start_all.sh"
|
|
sh ${PUSHER} "${CONTAINER_CODE}" "重启服务器完成"
|
|
##重启成功通知
|
|
|
|
echo "Update DOcker ${CONTAINER_CODE} successfully"
|
|
#清理文件
|
|
rm -rf /data/mmogrun/${CONTAINER_CODE}/mgame_server_release*.tgz
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|