From 1011652959394cca69e3a2d3a2627423fcd564f8 Mon Sep 17 00:00:00 2001 From: Adam Outler Date: Thu, 29 Jan 2026 16:18:41 +0000 Subject: [PATCH] Fix fresh install script --- .../entrypoint.d/20-first-run-config.sh | 42 +++++++++++++++---- 1 file changed, 35 insertions(+), 7 deletions(-) diff --git a/install/production-filesystem/entrypoint.d/20-first-run-config.sh b/install/production-filesystem/entrypoint.d/20-first-run-config.sh index 8e37f2d6..b57a657f 100755 --- a/install/production-filesystem/entrypoint.d/20-first-run-config.sh +++ b/install/production-filesystem/entrypoint.d/20-first-run-config.sh @@ -6,17 +6,46 @@ if [ -d "${NETALERTX_CONFIG}" ]; then chmod u+rwX "${NETALERTX_CONFIG}" 2>/dev/null || true fi chmod u+rw "${NETALERTX_CONFIG}/app.conf" 2>/dev/null || true + +set -eu + +CYAN=$(printf '\033[1;36m') +RED=$(printf '\033[1;31m') +RESET=$(printf '\033[0m') + +# Ensure config folder exists +if [ ! -d "${NETALERTX_CONFIG}" ]; then + if ! mkdir -p "${NETALERTX_CONFIG}"; then + >&2 printf "%s" "${RED}" + >&2 cat <&2 printf "%s" "${RESET}" + exit 1 + fi + chmod 700 "${NETALERTX_CONFIG}" 2>/dev/null || true +fi + +# Fresh rebuild requested +if [ "${ALWAYS_FRESH_INSTALL:-false}" = "true" ] && [ -e "${NETALERTX_CONFIG}/app.conf" ]; then + >&2 echo "INFO: ALWAYS_FRESH_INSTALL enabled — removing existing config." + rm -rf "${NETALERTX_CONFIG}"/* +fi + # Check for app.conf and deploy if required if [ ! -f "${NETALERTX_CONFIG}/app.conf" ]; then - mkdir -p "${NETALERTX_CONFIG}" || { - >&2 echo "ERROR: Failed to create config directory ${NETALERTX_CONFIG}" - exit 1 - } install -m 600 /app/back/app.conf "${NETALERTX_CONFIG}/app.conf" || { >&2 echo "ERROR: Failed to deploy default config to ${NETALERTX_CONFIG}/app.conf" exit 2 } - RESET=$(printf '\033[0m') + >&2 printf "%s" "${CYAN}" >&2 cat <&2 printf "%s" "${RESET}" + >&2 printf "%s" "${RESET}" fi