📦 增加判断是包含必须配置默认任务,如果没有就加上

This commit is contained in:
iouAkira
2020-12-11 14:31:04 +08:00
parent 37a554ae61
commit 018b6cc38a
2 changed files with 13 additions and 3 deletions

View File

@ -19,7 +19,7 @@ echo "##########################################################################
######################################获取docker构建文件里面的自定义信息方法-start#####################################################
function getDockerImageLabel() {
repo=akyakya/jd_scripts
imageTag=test
imageTag=dev
token=$(curl -s "https://auth.docker.io/token?service=registry.docker.io&scope=repository:${repo}:pull" | jq -r '.token')
digest=$(curl -s -H "Accept: application/vnd.docker.distribution.manifest.v2+json" -H "Authorization: Bearer $token" "https://registry-1.docker.io/v2/${repo}/manifests/${imageTag}" | jq .config.digest -r)
labels=$(curl -s -L -H "Accept: application/vnd.docker.distribution.manifest.v2+json" -H "Authorization: Bearer $token" "https://registry-1.docker.io/v2/${repo}/blobs/$digest" | jq .config.Labels)
@ -104,6 +104,12 @@ else
cat $defaultListFile >$mergedListFile
fi
# 判断最后要加载的定时任务是否包含默认定时任务,不包含的话就加进去
if [ $(grep -c "default_task.sh" $mergedListFile) -eq '0' ]; then
echo -e >>$mergedListFile
echo "52 */1 * * * sh /scripts/docker/default_task.sh |ts >> /scripts/logs/default_task.log 2>&1" >>$mergedListFile
fi
echo "Load the latest crontab task file..."
echo "加载最新的定时任务文件..."
crontab $mergedListFile