diff --git a/setup.sh b/setup.sh index f462b15..826ec5a 100755 --- a/setup.sh +++ b/setup.sh @@ -148,9 +148,20 @@ echo "" log "Step 1c/7: Where should recordings be stored?" info " This is where video clips and snapshots will be saved." info " Examples: /mnt/recordings, /home/user/nvr, /media/usb-drive" +info " Or set STORAGE_PATH environment variable to skip the prompt." echo "" -read -p " Storage path [${HOME}/nvr_data]: " STORAGE_PATH -STORAGE_PATH="${STORAGE_PATH:-${HOME}/nvr_data}" +if [ -n "${STORAGE_PATH}" ]; then + log "Using STORAGE_PATH from environment: ${STORAGE_PATH}" +elif [ -t 0 ]; then + # Interactive terminal — ask the user. + read -p " Storage path [${HOME}/nvr_data]: " STORAGE_PATH + STORAGE_PATH="${STORAGE_PATH:-${HOME}/nvr_data}" +else + # Non-interactive (piped install) — use default. + STORAGE_PATH="${HOME}/nvr_data" + warn "Non-interactive install — using default storage: ${STORAGE_PATH}" + info " To change: export STORAGE_PATH=/your/path before running this script." +fi # Strip trailing slash. STORAGE_PATH="${STORAGE_PATH%/}"