refactor: no interactive prompts — config.json.sample has defaults, update preserves config
This commit is contained in:
parent
30547fc354
commit
86ce14bc5b
1 changed files with 6 additions and 19 deletions
|
|
@ -142,26 +142,13 @@ fi
|
|||
# ── 8. Configuration (greenfield only) ──
|
||||
CONFIG_FILE="${DEPLOY_DIR}/config.json"
|
||||
if $GREENFIELD; then
|
||||
echo ""
|
||||
info "Where should recordings be stored?"
|
||||
info " Examples: /mnt/recordings, /home/user/nvr_data, /media/usb"
|
||||
if [ -e /dev/tty ]; then
|
||||
read -p " Storage path [${HOME}/nvr_data]: " STORAGE_PATH </dev/tty
|
||||
fi
|
||||
STORAGE_PATH="${STORAGE_PATH:-${HOME}/nvr_data}"
|
||||
STORAGE_PATH="${STORAGE_PATH%/}"
|
||||
echo ""
|
||||
|
||||
# Build config.json from sample.
|
||||
jq --arg path "${STORAGE_PATH}" \
|
||||
--arg go2rtc "${GO2RTC_BIN}" \
|
||||
'.storage.recordings_path = $path | .go2rtc.binary = $go2rtc' \
|
||||
config.json.sample > "${CONFIG_FILE}"
|
||||
|
||||
sudo mkdir -p "${STORAGE_PATH}"
|
||||
sudo chown "$(whoami):$(id -gn)" "${STORAGE_PATH}"
|
||||
# Build config.json from sample with sensible defaults.
|
||||
cp config.json.sample "${CONFIG_FILE}"
|
||||
STORAGE_PATH=$(jq -r .storage.recordings_path "${CONFIG_FILE}")
|
||||
sudo mkdir -p "${STORAGE_PATH}" 2>/dev/null || true
|
||||
sudo chown "$(whoami):$(id -gn)" "${STORAGE_PATH}" 2>/dev/null || true
|
||||
log "Config created: ${CONFIG_FILE}"
|
||||
log "Storage path: ${STORAGE_PATH}"
|
||||
log "Storage: ${STORAGE_PATH} (change via web UI Settings)"
|
||||
else
|
||||
log "Config preserved: ${CONFIG_FILE}"
|
||||
fi
|
||||
|
|
|
|||
Loading…
Reference in a new issue