summaryrefslogtreecommitdiffstats
path: root/getimap
blob: cb87ec0b818706db466e77763057e626541f3854 (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
28
29
30
31
32
#!/bin/bash
pidof X || exit 13
export DISPLAY=":0"
echo "#########################`date`####################" >> ~/logs/getmail.log
if ! mount | grep -q wormole;then
    echo "Booh.... "
    exit 
fi

if ps auxww | grep  getmail | grep -v grep;then
    exit
fi




left=$(/bin/df -h | grep home | head -1 | awk '{ print $5 }' | tr -d '%')

if [[ $left > 90 ]];then
    echo "Low on space -- quitting" >> ~/logs/getmail.log
    notify-send "========== ALERT ==============" "LOW ON SPACE"
    exit 1
fi

DURATION=6 notify-send "Mailman" "....Fetching mails."

#setlock -X -n /tmp/locks/getmail getmail -n -q --rcfile=getmailrc.gmail --rcfile=getmailrc.yahoo --rcfile=getmailrc.wnohang --rcfile=getmailrc.gmail2
/usr/sbin/setlock -X -n /tmp/locks/getmail getmail -n -v --rcfile=getmailrc.gmail --rcfile=getmailrc.yahoo --rcfile=getmailrc.wnohang --rcfile=getmailrc.gmail2
exitcode=$?
echo "Fetch : Exit code: $exitcode #########################`date`#################### Done" >> ~/logs/getmail.log
sync
[[ $exitcode == 0 ]] && notify-send "Mailman" ".. Done "