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) ──
|
# ── 8. Configuration (greenfield only) ──
|
||||||
CONFIG_FILE="${DEPLOY_DIR}/config.json"
|
CONFIG_FILE="${DEPLOY_DIR}/config.json"
|
||||||
if $GREENFIELD; then
|
if $GREENFIELD; then
|
||||||
echo ""
|
# Build config.json from sample with sensible defaults.
|
||||||
info "Where should recordings be stored?"
|
cp config.json.sample "${CONFIG_FILE}"
|
||||||
info " Examples: /mnt/recordings, /home/user/nvr_data, /media/usb"
|
STORAGE_PATH=$(jq -r .storage.recordings_path "${CONFIG_FILE}")
|
||||||
if [ -e /dev/tty ]; then
|
sudo mkdir -p "${STORAGE_PATH}" 2>/dev/null || true
|
||||||
read -p " Storage path [${HOME}/nvr_data]: " STORAGE_PATH </dev/tty
|
sudo chown "$(whoami):$(id -gn)" "${STORAGE_PATH}" 2>/dev/null || true
|
||||||
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}"
|
|
||||||
log "Config created: ${CONFIG_FILE}"
|
log "Config created: ${CONFIG_FILE}"
|
||||||
log "Storage path: ${STORAGE_PATH}"
|
log "Storage: ${STORAGE_PATH} (change via web UI Settings)"
|
||||||
else
|
else
|
||||||
log "Config preserved: ${CONFIG_FILE}"
|
log "Config preserved: ${CONFIG_FILE}"
|
||||||
fi
|
fi
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue