mirror of
				https://github.com/mail-in-a-box/mailinabox.git
				synced 2025-11-03 19:30:54 +00:00 
			
		
		
		
	Add some test scripts
This commit is contained in:
		
							parent
							
								
									2b3c2fcc02
								
							
						
					
					
						commit
						ac811bcbd1
					
				
							
								
								
									
										1
									
								
								management/reporting/capture/.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								management/reporting/capture/.gitignore
									
									
									
									
										vendored
									
									
								
							@ -1 +0,0 @@
 | 
			
		||||
tests/
 | 
			
		||||
							
								
								
									
										3
									
								
								management/reporting/capture/tests/.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								management/reporting/capture/tests/.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@ -0,0 +1,3 @@
 | 
			
		||||
*.log
 | 
			
		||||
pos.json
 | 
			
		||||
*.sqlite
 | 
			
		||||
							
								
								
									
										12
									
								
								management/reporting/capture/tests/config.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								management/reporting/capture/tests/config.json
									
									
									
									
									
										Normal file
									
								
							@ -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
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										35
									
								
								management/reporting/capture/tests/load.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										35
									
								
								management/reporting/capture/tests/load.sh
									
									
									
									
									
										Executable file
									
								
							@ -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
 | 
			
		||||
							
								
								
									
										34
									
								
								management/reporting/capture/tests/run.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										34
									
								
								management/reporting/capture/tests/run.sh
									
									
									
									
									
										Executable file
									
								
							@ -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"
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user