From dd117d181ede48e155cbc9de86d70e0baecd08f5 Mon Sep 17 00:00:00 2001 From: lxk0301 <778732665@qq.com> Date: Tue, 23 Feb 2021 11:25:00 +0800 Subject: [PATCH] update docker --- docker/default_task.sh | 5 +++++ docker/notify_docker_user.js | 26 ++++++++++++++++++++------ 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/docker/default_task.sh b/docker/default_task.sh index 4c22a5a9..65703ca3 100644 --- a/docker/default_task.sh +++ b/docker/default_task.sh @@ -121,3 +121,8 @@ crontab $mergedListFile echo "第10步将仓库的docker_entrypoint.sh脚本更新至系统/usr/local/bin/docker_entrypoint.sh内..." cat /scripts/docker/docker_entrypoint.sh >/usr/local/bin/docker_entrypoint.sh + +echo "发送通知" +export NOTIFY_CONTENT="2021-02-21更新 https://gitee.com/lxk0301/jd_scripts仓库被迫私有,需重新更新一下镜像:https://hub.docker.com/r/lxk0301/jd_scripts,(注:国内第三方镜像目前可能不是最新请使用hub.docker.com镜像,docker-compose.yml的REPO_URL记得修改)后续可同步更新jd_script仓库最新脚本" +cd /scripts/docker +node notify_docker_user.js \ No newline at end of file diff --git a/docker/notify_docker_user.js b/docker/notify_docker_user.js index 55916d06..4249d533 100644 --- a/docker/notify_docker_user.js +++ b/docker/notify_docker_user.js @@ -1,9 +1,23 @@ const notify = require('../sendNotify'); - -function image_update_notify() { - if (process.env.NOTIFY_CONTENT) { - notify.sendNotify("⚠️Docker镜像版本更新通知⚠️", process.env.NOTIFY_CONTENT) +const fs = require('fs'); +const notifyPath = '/scripts/logs/notify.txt'; +async function image_update_notify() { + if (fs.existsSync(notifyPath)) { + //notify.txt文件存在 + const content = await fs.readFileSync(`${notifyPath}`, 'utf8');//读取notify.txt内容 + if (!content.match(process.env.NOTIFY_CONTENT) && process.env.NOTIFY_CONTENT) { + await notify.sendNotify("⚠️Docker镜像版本更新通知⚠️", process.env.NOTIFY_CONTENT); + //把通知内容写入notify.txt文件 + await fs.writeFileSync(`${notifyPath}`, JSON.stringify(process.env.NOTIFY_CONTENT)); } + } else { + if (process.env.NOTIFY_CONTENT) { + notify.sendNotify("⚠️Docker镜像版本更新通知⚠️", process.env.NOTIFY_CONTENT) + //把通知内容写入notify.txt文件 + await fs.writeFileSync(`${notifyPath}`, JSON.stringify(process.env.NOTIFY_CONTENT)); + } + } } - -image_update_notify(); \ No newline at end of file +!(async() => { + await image_update_notify(); +})().catch((e) => console.log(e)) \ No newline at end of file