summaryrefslogtreecommitdiff
path: root/ucs-3.x/20-mail-to-jane-forwarded-to-john.sh
blob: db346a8cdfbce06ef5578d58fef891e22d66bbad (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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/bin/bash

eval "$(ucr shell)"

retval=$(./*-create-user-john-doe.sh >/dev/null 2>&1; echo $?)

if [ $retval -ne 0 ]; then
    echo "SKIP: prerequisite test $(ls -1 *-create-user-john-doe*) has failed"
    exit 1
fi

retval=$(./*-create-user-jane-doe.sh >/dev/null 2>&1; echo $?)

if [ $retval -ne 0 ]; then
    echo "SKIP: prerequisite test $(ls -1 *-create-user-jane-doe*) has failed"
    exit 1
fi

md5hash=`date | md5sum | awk '{print $1}'`

echo "${md5hash}" | mail -s "${md5hash}" doe@${domainname}

found=0
for emailaddress in doe@${domainname} doe2@${domainname}; do
    x=10
    y=0

    mbpath=$(/usr/lib/cyrus-imapd/mbpath user/${emailaddress})

    while [ ${y} -lt ${x} ]; do
        result=`grep "Subject: ${md5hash}" ${mbpath}/*. 2>/dev/null`

        if [ -z "${result}" ]; then
            # Not yet found
            sleep 1
        else
            y=${x}
            found=$[ $found + 1 ]
        fi
        let y++
    done
done

if [ $found -eq 1 ]; then
    echo "OK"
else
    echo "FAILED"
fi