From 3441f77a789f71ffc82ae37e0f0d7b075d3c8cb5 Mon Sep 17 00:00:00 2001 From: Adam Outler Date: Tue, 21 Oct 2025 19:10:48 +0000 Subject: [PATCH] Fix always fresh install env --- .../services/scripts/check-first-run-db.sh | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/install/production-filesystem/services/scripts/check-first-run-db.sh b/install/production-filesystem/services/scripts/check-first-run-db.sh index 8aa6d0bc..b183b588 100644 --- a/install/production-filesystem/services/scripts/check-first-run-db.sh +++ b/install/production-filesystem/services/scripts/check-first-run-db.sh @@ -2,8 +2,17 @@ # This script checks if the database file exists, and if not, creates it with the initial schema. # It is intended to be run at the first start of the application. -# if the db exists, exit -test -f "${NETALERTX_DB_FILE}" && exit 0 +# If ALWAYS_FRESH_INSTALL is true, remove the database to force a rebuild. +if [ "${ALWAYS_FRESH_INSTALL}" = "true" ]; then + if [ -f "${NETALERTX_DB_FILE}" ]; then + # Provide feedback to the user. + >&2 echo "INFO: ALWAYS_FRESH_INSTALL is true. Removing existing database to force a fresh installation." + rm -f "${NETALERTX_DB_FILE}" "${NETALERTX_DB_FILE}-shm" "${NETALERTX_DB_FILE}-wal" + fi +# Otherwise, if the db exists, exit. +elif [ -f "${NETALERTX_DB_FILE}" ]; then + exit 0 +fi CYAN='\033[1;36m' RESET='\033[0m'