summaryrefslogtreecommitdiff
path: root/upgrade-to-3.0-native-from-2.3-openpkg/22-fix-annotations.sh
blob: 05ce1ab8d4053b20563a56697199c4ad5bbf849f (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
#!/bin/bash

# Interesting Annotations
declare -a ia

ia[${#ia[@]}]="/shared/vendor/kolab/folder-type"
ia[${#ia[@]}]="/shared/vendor/kolab/folder-test"
ia[${#ia[@]}]="/shared/vendor/cmu/cyrus-imapd/sharedseen"

pushd /root/pykolab.git

if [ ! -f "/etc/kolab/kolab2.conf" ]; then
    echo "No configuration file for the kolab 2 server at /etc/kolab/kolab2.conf"
    popd
    exit 1
fi

for folder_search in user/*@kolabsys.com shared/*@kolabsys.com; do
    ./kolab.py -c /etc/kolab/kolab2.conf list-mailbox-metadata "${folder_search}" | \
        while read line; do
            if [ ! -z "$(echo $line | grep ^Folder)" ]; then
                current_folder=$(echo $line | cut -d' ' -f2-)

                echo "Folder: '${current_folder}'"
            else
                annotation_key=$(echo $line | awk '{print $1}')
                annotation_value=$(echo $line | awk '{print $2}')

                i=0
                set_annotation=0
                while [ $i -lt ${#ia[@]} ]; do
                    if [ "${ia[$i]}" == "${annotation_key}" ]; then
                        set_annotation=1
                        break
                    fi
                    let i++
                done

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

                echo "Setting ${annotation_key} to ${annotation_value}"

                ./kolab.py \
                    set-mailbox-metadata "${current_folder}" \
                    "${annotation_key}" \
                    "${annotation_value}"
            fi
        done
done

popd