summaryrefslogtreecommitdiff
path: root/upgrade-to-3.0-native-from-2.3-openpkg/31-count-groupware-messages.sh
blob: 87edce5867b5fa787a63cb085489d54caf394926 (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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/bin/bash

# Interesting Annotations
declare -a ia

ia[${#ia[@]}]="/shared/vendor/kolab/folder-type"

pushd /root/pykolab.git >/dev/null 2>&1

for folder_search in user/*@kolabsys.com shared/*@kolabsys.com; do
    ./kolab.py list-mailbox-metadata "${folder_search}" | while read line; do
        if [ ! -z "$(echo $line | grep ^Folder)" ]; then
            current_folder=$(echo $line | cut -d' ' -f2-)
        else
            annotation_key=$(echo $line | awk '{print $1}')
            annotation_value=$(echo $line | awk '{print $2}')

            # See if it is indeed interesting metadata
            i=0
            interesting_annotation=0
            while [ $i -lt ${#ia[@]} ]; do
                if [ "${ia[$i]}" == "${annotation_key}" ]; then
                    case "${annotation_value}" in
                        contact|contact.default)
                            interesting_annotation=1
                        ;;

                        event|event.default)
                            interesting_annotation=1
                        ;;

                        journal|journal.default)
                            interesting_annotation=1
                        ;;

                        note|note.default)
                            interesting_annotation=1
                        ;;

                        task|task.default)
                            interesting_annotation=1
                        ;;

                    esac
                fi
                let i++
            done

            if [ ${interesting_annotation} -eq 0 ]; then
                continue
            fi

            /usr/lib/cyrus-imapd/mbpath "${current_folder}"

        fi

    done | \

    while read folder2; do
        find "${folder2}" -mindepth 1 -maxdepth 1 -type f -name "*."
    done
done | wc -l

popd >/dev/null 2>&1