From 684e83253023754da045a9e3353a3ff2df2d9a72 Mon Sep 17 00:00:00 2001 From: livelycode36 Date: Wed, 22 Oct 2025 09:04:04 +0800 Subject: [PATCH] fix: prevent duplicate data volumes in entrypoint.sh (#681) --- entrypoint.sh | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 8e97badd..585278b3 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -2,14 +2,19 @@ set -e # 1) Normalize command: -# - No arguments: default to execute rustfs +# - No arguments: default to execute rustfs with DATA_VOLUMES # - First argument starts with '-': treat as rustfs arguments, auto-prefix rustfs # - First argument is 'rustfs': replace with absolute path to avoid PATH interference -if [ $# -eq 0 ] || [ "${1#-}" != "$1" ]; then +# - Otherwise: treat as full rustfs arguments (e.g., /data paths) +if [ $# -eq 0 ]; then + set -- /usr/bin/rustfs +elif [ "${1#-}" != "$1" ]; then set -- /usr/bin/rustfs "$@" elif [ "$1" = "rustfs" ]; then shift set -- /usr/bin/rustfs "$@" +else + set -- /usr/bin/rustfs "$@" fi # 2) Process data volumes (separate from log directory) @@ -74,6 +79,22 @@ if [ "${RUSTFS_ACCESS_KEY}" = "rustfsadmin" ] || [ "${RUSTFS_SECRET_KEY}" = "rus echo "!!!WARNING: Using default RUSTFS_ACCESS_KEY or RUSTFS_SECRET_KEY. Override them in production!" fi -echo "Starting: $*" -set -- "$@" $DATA_VOLUMES +# 5) Append DATA_VOLUMES only if no data paths in arguments +# Check if any argument looks like a data path (starts with / and not an option) +HAS_DATA_PATH=false +for arg in "$@"; do + case "$arg" in + /usr/bin/rustfs) continue ;; + -*) continue ;; + /*) HAS_DATA_PATH=true; break ;; + esac +done + +if [ "$HAS_DATA_PATH" = "false" ] && [ -n "$DATA_VOLUMES" ]; then + echo "Starting: $* $DATA_VOLUMES" + set -- "$@" $DATA_VOLUMES +else + echo "Starting: $*" +fi + exec "$@"