From 84d6f9724c7fd8741eb25f9997704dce5d6bec32 Mon Sep 17 00:00:00 2001 From: iwanhae Date: Mon, 31 Aug 2026 16:48:06 +0900 Subject: [PATCH] status: fix false DRIFT for non-root invocations - runner: export sbin-inclusive PATH (util-linux tools live in /usr/sbin) - 001: read /proc/swaps instead of swapon(8) - 005: resolve /dev/disk/by-uuid symlink instead of findfs(8); report ? (exit 2) when the UUID cannot be resolved --- migrations/001-create-swap.sh | 3 +-- migrations/005-mount-pgdata.sh | 3 ++- sysmig | 2 ++ 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/migrations/001-create-swap.sh b/migrations/001-create-swap.sh index a11a095..17c58f1 100644 --- a/migrations/001-create-swap.sh +++ b/migrations/001-create-swap.sh @@ -26,8 +26,7 @@ case "${1:-}" in echo " swap 2GB enabled + fstab entry + vm.swappiness=10" ;; status) - swapon --show --noheadings 2>/dev/null | grep -q '^/swapfile ' \ - || { echo "DRIFT /swapfile not active"; exit 1; } + grep -q '^/swapfile ' /proc/swaps || { echo "DRIFT /swapfile not active"; exit 1; } grep -q '^/swapfile ' /etc/fstab || { echo "DRIFT fstab entry missing"; exit 1; } swp=$(cat /proc/sys/vm/swappiness 2>/dev/null || echo '?') [[ $swp == 10 ]] || { echo "DRIFT vm.swappiness=$swp (want 10)"; exit 1; } diff --git a/migrations/005-mount-pgdata.sh b/migrations/005-mount-pgdata.sh index 0ceb68b..6be22c7 100644 --- a/migrations/005-mount-pgdata.sh +++ b/migrations/005-mount-pgdata.sh @@ -32,7 +32,8 @@ case "${1:-}" in ;; status) src=$(findmnt -rn -o SOURCE "$MOUNTPOINT" 2>/dev/null || true) - want=$(findfs UUID="$DISK_UUID" 2>/dev/null || true) + want=$(readlink -f "/dev/disk/by-uuid/$DISK_UUID" 2>/dev/null || true) + [[ -n $want ]] || { echo "? cannot resolve UUID=$DISK_UUID"; exit 2; } [[ -n $src ]] || { echo "DRIFT $MOUNTPOINT not mounted"; exit 1; } [[ $src == "$want" ]] || { echo "DRIFT $MOUNTPOINT mounted from $src (want $want)"; exit 1; } grep -q "^UUID=$DISK_UUID $MOUNTPOINT " /etc/fstab \ diff --git a/sysmig b/sysmig index 0af7796..a169d37 100755 --- a/sysmig +++ b/sysmig @@ -15,6 +15,8 @@ # ============================================================================ set -euo pipefail +export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin + MIG_DIR="$(cd "$(dirname "$0")/migrations" && pwd)" STATE_DIR=/var/lib/sysmig STATE_FILE=$STATE_DIR/applied