mirror of
https://github.com/mail-in-a-box/mailinabox.git
synced 2026-10-26 06:09:53 +01:00
Add some test scripts
This commit is contained in:
@@ -1 +0,0 @@
|
|||||||
tests/
|
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
*.log
|
||||||
|
pos.json
|
||||||
|
*.sqlite
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"capture": true,
|
||||||
|
"prune_policy": {
|
||||||
|
"frequency_min": 2400,
|
||||||
|
"older_than_days": 30
|
||||||
|
},
|
||||||
|
"drop_disposition": {
|
||||||
|
"failed_login_attempt": false,
|
||||||
|
"suspected_scanner": false,
|
||||||
|
"reject": false
|
||||||
|
}
|
||||||
|
}
|
||||||
Executable
+35
@@ -0,0 +1,35 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# load a mail.log file into the current test vm's capture.sqlite
|
||||||
|
#
|
||||||
|
if [ -z "$1" ]; then
|
||||||
|
echo "usage: $0 /path/to/mail.log"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
log="$1"
|
||||||
|
if [ ! -e "$log" ]; then
|
||||||
|
echo "Does not exist: $log"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
. /etc/mailinabox.conf
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "Could not load /etc/mailinabox.conf !!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
echo "Stopping maibldap-capture daemon"
|
||||||
|
systemctl stop miabldap-capture || exit 1
|
||||||
|
|
||||||
|
echo "Ensuring access to capture.sqlite"
|
||||||
|
capture_db=$STORAGE_ROOT/reporting/capture.sqlite
|
||||||
|
sqlite3 "$capture_db" "select value from db_info where key='schema_version'" >/dev/null
|
||||||
|
[ $? -ne 0 ] && exit 1
|
||||||
|
|
||||||
|
echo "Loading $log"
|
||||||
|
python3 ../capture.py -d -loglevel info -logfile "$log" -stopateof
|
||||||
|
|
||||||
|
echo "Starting miabldap-capture daemon"
|
||||||
|
systemctl start miabldap-capture
|
||||||
Executable
+34
@@ -0,0 +1,34 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
#
|
||||||
|
# interactively load a mail.log file and create a capture.sqlite
|
||||||
|
# database in the current directory
|
||||||
|
|
||||||
|
log="./mail.log"
|
||||||
|
pos="./pos.json"
|
||||||
|
sqlite="./capture.sqlite"
|
||||||
|
config="./config.json"
|
||||||
|
|
||||||
|
if [ -e "./debug.log" ]; then
|
||||||
|
log="./debug.log"
|
||||||
|
fi
|
||||||
|
|
||||||
|
case "$1" in
|
||||||
|
*.log )
|
||||||
|
log="$1"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
if [ "$1" != "-c" ]; then
|
||||||
|
# Start over. Don't continue where we left off
|
||||||
|
echo "STARTING OVER"
|
||||||
|
rm -f "$pos"
|
||||||
|
rm -f "$sqlite"
|
||||||
|
else
|
||||||
|
shift
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "USING LOG: $log"
|
||||||
|
echo "DB: $sqlite"
|
||||||
|
python3 ../capture.py -d -loglevel info $@ -logfile "$log" -posfile "$pos" -sqlitefile "$sqlite" -config "$config"
|
||||||
Reference in New Issue
Block a user