aboutsummaryrefslogtreecommitdiffstats
path: root/script/load-mail-server-logs
blob: 234aecd3b910c6c7f5955fcba3a11325d8cb57e9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/bin/bash

LOC=`dirname "$0"`

cd "$LOC"/..
source commonlib/shlib/deployfns
read_conf config/general

# Specific file if specified
if [ x$1 != x ]
then
    case "$1" in
      /*) f=$1 ;;
       *) f=$(pwd)/$1 ;;
    esac
    cd "$LOC"
    bundle exec ./runner 'MailServerLog.load_file("'$f'")'
    exit
fi

# Load in last three days worth of logs (if they've been modified)
cd "$LOC"
LATEST=$( ls -rt $OPTION_MTA_LOG_PATH 2>/dev/null | tail -3 )
for X in $LATEST
do
    bundle exec ./runner 'MailServerLog.load_file("'$X'")'
done