From 76534fac307cdd77ab1b900544718a9e3e7a173d Mon Sep 17 00:00:00 2001 From: qiaofeng1227 <76487013@qq.com> Date: Thu, 14 Mar 2024 14:14:10 +0800 Subject: [PATCH] 2.0.4 --- systemd/script/crontab.sh | 24 ++++++++++++++++++++---- version.json | 2 +- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/systemd/script/crontab.sh b/systemd/script/crontab.sh index 7eb1d75f..3c765632 100644 --- a/systemd/script/crontab.sh +++ b/systemd/script/crontab.sh @@ -21,10 +21,26 @@ check_ports() { # get volume from container function get_volume_path() { - local container_name="$1" - local volume_name="$2" - local mounts=$(docker inspect -f '{{ json .Mounts }}' "$container_name" | jq -r '.[] | select(.Name == "'$volume_name'") | .Source') - echo "$mounts" + local container_name="\$1" + local volume_name="\$2" + local retries=0 + local max_retries=5 + local mounts + + while [ $retries -lt $max_retries ]; do + mounts=$(docker inspect -f '{{ json .Mounts }}' "$container_name" | jq -r ".[] | select(.Name == \"$volume_name\") | .Source") + + if [[ "$mounts" == *"/"* ]]; then + echo "$mounts" + return 0 + fi + + ((retries++)) + sleep 5 + done + + echo "Cannot get volume path" + exit 1 } volume_path=$(get_volume_path "$container_name" "$volume_name") diff --git a/version.json b/version.json index 0127abd8..7cfce350 100644 --- a/version.json +++ b/version.json @@ -1,5 +1,5 @@ { - "version": "2.0.3", + "version": "2.0.4", "plugins": { "portainer": "0.0.9", "nginx": "0.0.7",