From ae35f3f7b81df2c4a5a4c15436901395910e7066 Mon Sep 17 00:00:00 2001 From: Cobra Date: Tue, 7 Apr 2026 14:12:07 -0400 Subject: [PATCH] =?UTF-8?q?Fix=20HOME=20path=20when=20run=20via=20sudo=20?= =?UTF-8?q?=E2=80=94=20use=20SUDO=5FUSER's=20home=20not=20/root?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- operator_setup.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/operator_setup.sh b/operator_setup.sh index 5a9fb1d..a02a747 100755 --- a/operator_setup.sh +++ b/operator_setup.sh @@ -57,8 +57,10 @@ banner() { [[ $EUID -eq 0 ]] || error "Must run as root (use: sudo bash operator_setup.sh)" SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" -CACHE_DIR="${HOME}/.bigbrother/images" -CREDS="${HOME}/.local/bin/creds" +# When run via sudo, use the invoking user's home — not /root +REAL_HOME=$(getent passwd "${SUDO_USER:-$(whoami)}" | cut -d: -f6) +CACHE_DIR="${REAL_HOME}/.bigbrother/images" +CREDS="${REAL_HOME}/.local/bin/creds" MOUNT_POINT="/mnt/opi" mkdir -p "$CACHE_DIR"