mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2026-02-24 11:16:01 -05:00
21 lines
722 B
Bash
Executable File
21 lines
722 B
Bash
Executable File
#!/bin/sh
|
|
# This script recreates the database from schema code.
|
|
# Database location
|
|
NETALERTX_DB_FILE=${NETALERTX_DB:-/data/db}/app.db
|
|
|
|
#remove the old database
|
|
rm -f "${NETALERTX_DB_FILE}" "${NETALERTX_DB_FILE}-shm" "${NETALERTX_DB_FILE}-wal"
|
|
|
|
# Calculate script directory and schema path
|
|
SCRIPT_DIR="$(dirname "$(readlink -f "$0")")"
|
|
# Path to the schema file (relative to script location: scripts/db_cleanup/ -> ../../server/db/schema/app.sql)
|
|
SCHEMA_FILE="${SCRIPT_DIR}/../../server/db/schema/app.sql"
|
|
|
|
if [ ! -f "${SCHEMA_FILE}" ]; then
|
|
echo "Error: Schema file not found at ${SCHEMA_FILE}"
|
|
exit 1
|
|
fi
|
|
|
|
# Import the database schema into the new database file
|
|
sqlite3 "${NETALERTX_DB_FILE}" < "${SCHEMA_FILE}"
|