mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2025-12-07 09:36:05 -08:00
Fix errors for tests
This commit is contained in:
@@ -70,7 +70,9 @@ if [ "${NETALERTX_DEBUG:-0}" != "1" ]; then
|
||||
if [ ${NETALERTX_DOCKER_ERROR_CHECK} -ne 0 ]; then
|
||||
|
||||
echo exit code ${NETALERTX_DOCKER_ERROR_CHECK} from ${script}
|
||||
exit ${NETALERTX_DOCKER_ERROR_CHECK}
|
||||
if [ ${NETALERTX_DOCKER_ERROR_CHECK} -ne 0 ]; then
|
||||
NETALERTX_CHECK_ONLY=${NETALERTX_DOCKER_ERROR_CHECK}
|
||||
fi
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
@@ -1,14 +1,48 @@
|
||||
#!/bin/sh
|
||||
# check-storage.sh - Verify critical paths are persistent mounts.
|
||||
|
||||
warn_if_not_persistent_mount() {
|
||||
path="$1"
|
||||
# Check if the path is a mount point by looking for it in /proc/self/mountinfo
|
||||
# We are looking for an exact match in the mount point column (field 5)
|
||||
if awk -v target="${path}" '$5 == target {found=1} END {exit found ? 0 : 1}' /proc/self/mountinfo; then
|
||||
# Get the Device ID of the root filesystem (overlayfs/tmpfs)
|
||||
# The default, non-persistent container root will have a unique Device ID.
|
||||
# Persistent mounts will have a different Device ID (unless it's a bind mount
|
||||
# from the host's root, which is a rare and unusual setup for a single volume check).
|
||||
ROOT_DEV_ID=$(stat -c '%d' /)
|
||||
|
||||
is_persistent_mount() {
|
||||
target_path="$1"
|
||||
|
||||
# Stat the path and get its Device ID
|
||||
current_dev_id=$(stat -c '%d' "${target_path}")
|
||||
|
||||
# If the Device ID of the target is *different* from the root's Device ID,
|
||||
# it means it resides on a separate filesystem, implying a mount.
|
||||
if [ "${current_dev_id}" != "${ROOT_DEV_ID}" ]; then
|
||||
return 0 # Persistent (different filesystem/device ID)
|
||||
fi
|
||||
|
||||
# Fallback to check if it's the root directory itself (which is always mounted)
|
||||
if [ "${target_path}" = "/" ]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
# Check parent directory recursively
|
||||
parent_dir=$(dirname "${target_path}")
|
||||
if [ "${parent_dir}" != "${target_path}" ]; then
|
||||
is_persistent_mount "${parent_dir}"
|
||||
return $?
|
||||
fi
|
||||
|
||||
return 1 # Not persistent
|
||||
}
|
||||
|
||||
warn_if_not_persistent_mount() {
|
||||
path="$1"
|
||||
|
||||
if is_persistent_mount "${path}"; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
# ... (Your existing warning message block remains unchanged) ...
|
||||
|
||||
failures=1
|
||||
YELLOW=$(printf '\033[1;33m')
|
||||
RESET=$(printf '\033[0m')
|
||||
@@ -36,7 +70,7 @@ EOF
|
||||
|
||||
# If NETALERTX_DEBUG=1 then we will exit
|
||||
if [ "${NETALERTX_DEBUG}" = "1" ]; then
|
||||
exit 0
|
||||
exit 0
|
||||
fi
|
||||
|
||||
failures=0
|
||||
@@ -49,4 +83,4 @@ if [ "${failures}" -ne 0 ]; then
|
||||
# We only warn, not exit, as this is not a critical failure
|
||||
# but the user should be aware of the potential data loss.
|
||||
sleep 5 # Give user time to read the message
|
||||
fi
|
||||
fi
|
||||
Reference in New Issue
Block a user