mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-27 15:37:02 +00:00
Fix entrypoint.sh incorrectly passing logs directory as data volume with improved separation (#561)
* Initial plan * Fix entrypoint.sh: separate log directory from data volumes Co-authored-by: overtrue <1472352+overtrue@users.noreply.github.com> * Improve separation: use functions and RUSTFS_OBS_LOG_DIRECTORY env var Co-authored-by: overtrue <1472352+overtrue@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: overtrue <1472352+overtrue@users.noreply.github.com>
This commit is contained in:
+52
-33
@@ -12,49 +12,68 @@ elif [ "$1" = "rustfs" ]; then
|
|||||||
set -- /usr/bin/rustfs "$@"
|
set -- /usr/bin/rustfs "$@"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# 2) Parse and create local mount directories (ignore http/https), ensure /logs is included
|
# 2) Process data volumes (separate from log directory)
|
||||||
VOLUME_RAW="${RUSTFS_VOLUMES:-/data}"
|
DATA_VOLUMES=""
|
||||||
# Convert comma/tab to space
|
process_data_volumes() {
|
||||||
VOLUME_LIST=$(echo "$VOLUME_RAW" | tr ',\t' ' ')
|
VOLUME_RAW="${RUSTFS_VOLUMES:-/data}"
|
||||||
LOCAL_VOLUMES=""
|
# Convert comma/tab to space
|
||||||
for vol in $VOLUME_LIST; do
|
VOLUME_LIST=$(echo "$VOLUME_RAW" | tr ',\t' ' ')
|
||||||
case "$vol" in
|
|
||||||
/*)
|
for vol in $VOLUME_LIST; do
|
||||||
case "$vol" in
|
case "$vol" in
|
||||||
http://*|https://*) : ;;
|
/*)
|
||||||
*) LOCAL_VOLUMES="$LOCAL_VOLUMES $vol" ;;
|
case "$vol" in
|
||||||
esac
|
http://*|https://*) : ;;
|
||||||
;;
|
*) DATA_VOLUMES="$DATA_VOLUMES $vol" ;;
|
||||||
*)
|
esac
|
||||||
: # skip non-local paths
|
;;
|
||||||
;;
|
*)
|
||||||
esac
|
: # skip non-local paths
|
||||||
done
|
;;
|
||||||
# Ensure /logs is included
|
esac
|
||||||
case " $LOCAL_VOLUMES " in
|
done
|
||||||
*" /logs "*) : ;;
|
|
||||||
*) LOCAL_VOLUMES="$LOCAL_VOLUMES /logs" ;;
|
echo "Initializing data directories:$DATA_VOLUMES"
|
||||||
esac
|
for vol in $DATA_VOLUMES; do
|
||||||
|
if [ ! -d "$vol" ]; then
|
||||||
|
echo " mkdir -p $vol"
|
||||||
|
mkdir -p "$vol"
|
||||||
|
# If target user is specified, try to set directory owner to that user (non-recursive to avoid large disk overhead)
|
||||||
|
if [ -n "$RUSTFS_UID" ] && [ -n "$RUSTFS_GID" ]; then
|
||||||
|
chown "$RUSTFS_UID:$RUSTFS_GID" "$vol" 2>/dev/null || true
|
||||||
|
elif [ -n "$RUSTFS_USERNAME" ] && [ -n "$RUSTFS_GROUPNAME" ]; then
|
||||||
|
chown "$RUSTFS_USERNAME:$RUSTFS_GROUPNAME" "$vol" 2>/dev/null || true
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
echo "Initializing mount directories:$LOCAL_VOLUMES"
|
# 3) Process log directory (separate from data volumes)
|
||||||
for vol in $LOCAL_VOLUMES; do
|
process_log_directory() {
|
||||||
if [ ! -d "$vol" ]; then
|
LOG_DIR="${RUSTFS_OBS_LOG_DIRECTORY:-/logs}"
|
||||||
echo " mkdir -p $vol"
|
|
||||||
mkdir -p "$vol"
|
echo "Initializing log directory: $LOG_DIR"
|
||||||
|
if [ ! -d "$LOG_DIR" ]; then
|
||||||
|
echo " mkdir -p $LOG_DIR"
|
||||||
|
mkdir -p "$LOG_DIR"
|
||||||
# If target user is specified, try to set directory owner to that user (non-recursive to avoid large disk overhead)
|
# If target user is specified, try to set directory owner to that user (non-recursive to avoid large disk overhead)
|
||||||
if [ -n "$RUSTFS_UID" ] && [ -n "$RUSTFS_GID" ]; then
|
if [ -n "$RUSTFS_UID" ] && [ -n "$RUSTFS_GID" ]; then
|
||||||
chown "$RUSTFS_UID:$RUSTFS_GID" "$vol" 2>/dev/null || true
|
chown "$RUSTFS_UID:$RUSTFS_GID" "$LOG_DIR" 2>/dev/null || true
|
||||||
elif [ -n "$RUSTFS_USERNAME" ] && [ -n "$RUSTFS_GROUPNAME" ]; then
|
elif [ -n "$RUSTFS_USERNAME" ] && [ -n "$RUSTFS_GROUPNAME" ]; then
|
||||||
chown "$RUSTFS_USERNAME:$RUSTFS_GROUPNAME" "$vol" 2>/dev/null || true
|
chown "$RUSTFS_USERNAME:$RUSTFS_GROUPNAME" "$LOG_DIR" 2>/dev/null || true
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
}
|
||||||
|
|
||||||
# 3) Default credentials warning
|
# Execute the separate processes
|
||||||
|
process_data_volumes
|
||||||
|
process_log_directory
|
||||||
|
|
||||||
|
# 4) Default credentials warning
|
||||||
if [ "${RUSTFS_ACCESS_KEY}" = "rustfsadmin" ] || [ "${RUSTFS_SECRET_KEY}" = "rustfsadmin" ]; then
|
if [ "${RUSTFS_ACCESS_KEY}" = "rustfsadmin" ] || [ "${RUSTFS_SECRET_KEY}" = "rustfsadmin" ]; then
|
||||||
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: $*"
|
echo "Starting: $*"
|
||||||
set -- "$@" $LOCAL_VOLUMES
|
set -- "$@" $DATA_VOLUMES
|
||||||
exec "$@"
|
exec "$@"
|
||||||
|
|||||||
Reference in New Issue
Block a user