1
0
mirror of https://github.com/mail-in-a-box/mailinabox.git synced 2025-07-07 23:50:55 +00:00

Merge pull request #44 from downtownallday/cleanup-reporting-db

Cleanup reporting db
This commit is contained in:
Downtown Allday 2025-03-23 07:42:26 -04:00 committed by GitHub
commit 5254bfa6a6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -15,6 +15,9 @@ source /etc/mailinabox.conf # load global vars
echo "Installing miabldap-capture daemon..." echo "Installing miabldap-capture daemon..."
conf="$STORAGE_ROOT/reporting/config.json" conf="$STORAGE_ROOT/reporting/config.json"
db="$STORAGE_ROOT/reporting/capture.sqlite"
apt_install sqlite3
if [ ! -e "$conf" ]; then if [ ! -e "$conf" ]; then
mkdir -p $(dirname "$conf") mkdir -p $(dirname "$conf")
@ -37,5 +40,12 @@ fi
sed "s|%BIN%|$(pwd)|g" conf/miabldap-capture.service > /etc/systemd/system/miabldap-capture.service sed "s|%BIN%|$(pwd)|g" conf/miabldap-capture.service > /etc/systemd/system/miabldap-capture.service
hide_output systemctl daemon-reload hide_output systemctl daemon-reload
# 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;"
fi
hide_output systemctl enable miabldap-capture hide_output systemctl enable miabldap-capture
restart_service miabldap-capture restart_service miabldap-capture