From c9b20d98269ee6332064906df67dcde88a611e9e Mon Sep 17 00:00:00 2001 From: Yasen Pramatarov Date: Mon, 27 May 2024 15:49:06 +0300 Subject: [PATCH] Adds database file and database schema checks. --- jvb/jitsi-stats | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/jvb/jitsi-stats b/jvb/jitsi-stats index 25ce83d..39ebc98 100755 --- a/jvb/jitsi-stats +++ b/jvb/jitsi-stats @@ -200,6 +200,18 @@ case "$cmd" in --check) + # First check if database exists + if [[ ! -f $"DB" ]]; then + echo "Database not found. If it's a fresh install, please install the database first." + exit 1 + fi + + # Check the state table + if ! sqlite3 "$DB" ".schema state" &>/dev/null; then + echo "The database doesn't contain the required table \"state\". Please check it, and if needed, reinstall it." + exit 1 + fi + # Retrieve last log file and position inside it IFS='|' read -r last_file last_filetime last_size last_pos last_inode <<< $(get_state)