-
Notifications
You must be signed in to change notification settings - Fork 0
/
zarafaArchive.sh
executable file
·61 lines (48 loc) · 1.59 KB
/
zarafaArchive.sh
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
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/bin/bash
#######################################
# Archiver Script #
# Written by Tom #
#######################################
CONFIGFILE="/usr/local/sbin/archiver-wrapper.cfg"
. $CONFIGFILE
while getopts ":c:" opt; do
case $opt in
c)
if [ -f $OPTARG ]; then CONFIGFILE=$OPTARG; else echo "File not found"; fi
;;
esac
done
function increase_error_count {
ERRORCOUNT=$((${ERRORCOUNT}+1))
}
function not_found {
echo "${1} not found!" >&2
exit 1
}
for soft in ldapsearch mail zarafa-archiver
do
which $soft &>/dev/null || not_found $soft
done
(
### Run Archiver ###
for i in "${!FILTERGROUP[@]}"
do
array=( $(${LDAPSEARCH} -x -b "${SEARCHBASE}" "${FILTERGROUP[${i}]}" | grep -w "${SEARCHSTRING}" | cut -d " " -f 2) )
for j in "${array[@]}"
do
if ${ARCHIVER} -u $j -A -c ${CONFIG[${i}]}; then
echo "Zarafa Archiver for user $j succeeded"
else
echo "Zarafa Archiver for user $j failed"
increase_error_count
fi
done
done
### Logging ###
) > ${LOGS}/archiver-custom-${DATE}.log 2>&1
if [ $? -eq 0 ]
then
${MAIL} -s "Zarafa Archiver [OK]" -r $SENDER $RCPT < ${LOGS}/archiver-custom-${DATE}.log
else
${MAIL} -s "Zarafa Archiver [FAILED]" -r $SENDER $RCPT < ${LOGS}/archiver-custom-${DATE}.log
fi