mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-19 19:16:17 +00:00
fix: prevent duplicate data volumes in entrypoint.sh (#681)
This commit is contained in:
+25
-4
@@ -2,14 +2,19 @@
|
|||||||
set -e
|
set -e
|
||||||
|
|
||||||
# 1) Normalize command:
|
# 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 starts with '-': treat as rustfs arguments, auto-prefix rustfs
|
||||||
# - First argument is 'rustfs': replace with absolute path to avoid PATH interference
|
# - 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 "$@"
|
set -- /usr/bin/rustfs "$@"
|
||||||
elif [ "$1" = "rustfs" ]; then
|
elif [ "$1" = "rustfs" ]; then
|
||||||
shift
|
shift
|
||||||
set -- /usr/bin/rustfs "$@"
|
set -- /usr/bin/rustfs "$@"
|
||||||
|
else
|
||||||
|
set -- /usr/bin/rustfs "$@"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# 2) Process data volumes (separate from log directory)
|
# 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!"
|
echo "!!!WARNING: Using default RUSTFS_ACCESS_KEY or RUSTFS_SECRET_KEY. Override them in production!"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Starting: $*"
|
# 5) Append DATA_VOLUMES only if no data paths in arguments
|
||||||
set -- "$@" $DATA_VOLUMES
|
# 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 "$@"
|
exec "$@"
|
||||||
|
|||||||
Reference in New Issue
Block a user