From a90d646673d5adeca31b2481fbdb94dfcc41a4eb Mon Sep 17 00:00:00 2001 From: downtownallday Date: Sat, 22 Mar 2025 09:44:11 -0400 Subject: [PATCH 1/2] during setup, vacuum the reporting/capture database --- setup/management-capture.sh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/setup/management-capture.sh b/setup/management-capture.sh index 35b3fc2e..8eafaf92 100755 --- a/setup/management-capture.sh +++ b/setup/management-capture.sh @@ -15,6 +15,9 @@ source /etc/mailinabox.conf # load global vars echo "Installing miabldap-capture daemon..." conf="$STORAGE_ROOT/reporting/config.json" +db="$STORAGE_ROOT/reporting/capture.sqlite" + +apt_install sqlite3 if [ ! -e "$conf" ]; then mkdir -p $(dirname "$conf") @@ -37,5 +40,11 @@ fi sed "s|%BIN%|$(pwd)|g" conf/miabldap-capture.service > /etc/systemd/system/miabldap-capture.service hide_output systemctl daemon-reload + +if [ -e "$db" ]; then + echo "Vacuum capture database" + hide_output systemctl stop miabldap-capture + hide_output /usr/bin/sqlite3 "$db" "VACUUM;" +fi hide_output systemctl enable miabldap-capture restart_service miabldap-capture From 3f385e6835d5f10e386116f69b58a9a3dedf3f90 Mon Sep 17 00:00:00 2001 From: downtownallday Date: Sat, 22 Mar 2025 18:37:46 -0400 Subject: [PATCH 2/2] vacuum only if non-empty the file may have already been created by the management daemon --- setup/management-capture.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/setup/management-capture.sh b/setup/management-capture.sh index 8eafaf92..9a4beb31 100755 --- a/setup/management-capture.sh +++ b/setup/management-capture.sh @@ -41,7 +41,8 @@ sed "s|%BIN%|$(pwd)|g" conf/miabldap-capture.service > /etc/systemd/system/miabl hide_output systemctl daemon-reload -if [ -e "$db" ]; then +# vacuum database if it exists and is non-empty +if [ -s "$db" ]; then echo "Vacuum capture database" hide_output systemctl stop miabldap-capture hide_output /usr/bin/sqlite3 "$db" "VACUUM;"