From 774fac9edd5da0cd6395ffab62eaedc64509ea84 Mon Sep 17 00:00:00 2001 From: rcourtman Date: Wed, 3 Dec 2025 18:04:10 +0000 Subject: [PATCH] fix: Improve TrueNAS detection for immutable filesystem installs Added fallback detection for TrueNAS systems that may not have /etc/truenas-version or other standard markers: 1. Check if hostname contains "truenas" (common default hostname) 2. Test if /usr/local/bin is actually writable - if not and /data exists, use TrueNAS installation paths This fixes installations on TrueNAS systems where the standard detection files are missing but the filesystem is still immutable. Related to #801 --- scripts/install.sh | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/scripts/install.sh b/scripts/install.sh index 0c88849f0..27ece786e 100644 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -236,6 +236,20 @@ is_truenas_scale() { if [[ -d /data/ix-applications ]] || [[ -d /etc/ix-apps.d ]]; then return 0 fi + # Fallback: check if hostname contains "truenas" (common default hostname) + if hostname 2>/dev/null | grep -qi "truenas"; then + return 0 + fi + return 1 +} + +# Check if we can write to /usr/local/bin (catches immutable filesystems like TrueNAS) +is_install_dir_writable() { + local test_file="${INSTALL_DIR}/.pulse-write-test-$$" + if touch "$test_file" 2>/dev/null; then + rm -f "$test_file" 2>/dev/null + return 0 + fi return 1 } @@ -244,6 +258,12 @@ if [[ "$(uname -s)" == "Linux" ]] && is_truenas_scale; then INSTALL_DIR="$TRUENAS_STATE_DIR" LOG_FILE="$TRUENAS_LOG_DIR/${AGENT_NAME}.log" log_info "TrueNAS SCALE detected (immutable root). Using $TRUENAS_STATE_DIR for installation." +elif [[ "$(uname -s)" == "Linux" ]] && [[ -d /data ]] && ! is_install_dir_writable; then + # /usr/local/bin is read-only but /data exists - likely TrueNAS or similar immutable system + TRUENAS=true + INSTALL_DIR="$TRUENAS_STATE_DIR" + LOG_FILE="$TRUENAS_LOG_DIR/${AGENT_NAME}.log" + log_info "Immutable filesystem detected (read-only /usr/local/bin). Using $TRUENAS_STATE_DIR for installation." fi # --- Download ---