summaryrefslogtreecommitdiff
path: root/upgrade-to-3.0-native-from-2.3-openpkg/33-attempt-groupware-messages-formatupgrade.sh
diff options
context:
space:
mode:
authorJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2012-08-23 13:50:15 (GMT)
committerJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2012-08-23 13:50:15 (GMT)
commit811f83ace1e63d493093dff78151e9a64d90cf53 (patch)
treef3dde9326fdc7b4d3592f46c95bf687915ed4513 /upgrade-to-3.0-native-from-2.3-openpkg/33-attempt-groupware-messages-formatupgrade.sh
parentbe3183ea867ad6fe909e9684b45d6e3667cf2ede (diff)
downloadkolab-scripts-811f83ace1e63d493093dff78151e9a64d90cf53.tar.gz
Add the kolab-scripts used in migration and development
Diffstat (limited to 'upgrade-to-3.0-native-from-2.3-openpkg/33-attempt-groupware-messages-formatupgrade.sh')
-rwxr-xr-xupgrade-to-3.0-native-from-2.3-openpkg/33-attempt-groupware-messages-formatupgrade.sh103
1 files changed, 103 insertions, 0 deletions
diff --git a/upgrade-to-3.0-native-from-2.3-openpkg/33-attempt-groupware-messages-formatupgrade.sh b/upgrade-to-3.0-native-from-2.3-openpkg/33-attempt-groupware-messages-formatupgrade.sh
new file mode 100755
index 0000000..702d3e7
--- /dev/null
+++ b/upgrade-to-3.0-native-from-2.3-openpkg/33-attempt-groupware-messages-formatupgrade.sh
@@ -0,0 +1,103 @@
+#!/bin/bash
+
+# Interesting Annotations
+declare -a ia
+
+ia[${#ia[@]}]="/shared/vendor/kolab/folder-type"
+
+export total_num=`./21-count-groupware-messages.sh`
+export done_num=0
+export last_percent=0
+
+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 "*." | \
+ sort | \
+ while read file; do
+ kolab-formatupgrade --mime "${file}" > /tmp/upgrade.log 2>&1
+ fail_dir="/root/conversion-fail/"
+ if [ ! -z "$(grep "^X-Kolab-Type:" "${file}")" ]; then
+ fail_dir="${fail_dir}/$(grep "^X-Kolab-Type:" "${file}" | cut -d':' -f2-)"
+ elif [ ! -z "$(grep "^X-Mailer:" "${file}")" ]; then
+ fail_dir="${fail_dir}/$(grep "^X-Mailer:" "${file}" | cut -d':' -f2-)"
+ fi
+
+ fail_dir=$(echo ${fail_dir} | sed -r -e 's/\s*//g' -e 's/\s*\n*\r*$//g')
+
+ if [ ! -d "${fail_dir}" ]; then
+ mkdir -p "${fail_dir}"
+ fi
+
+ if [ ! -z "$(grep 'failed to read mime file' /tmp/upgrade.log)" ]; then
+ cp -a "${file}" ${fail_dir}/$(md5sum "${file}" | awk '{print $1}').msg
+ mv /tmp/upgrade.log ${fail_dir}/$(md5sum "${file}" | awk '{print $1}').log
+ elif [ ! -z "$(grep 'invalid object type' /tmp/upgrade.log)" ]; then
+ cp -a "${file}" ${fail_dir}/$(md5sum "${file}" | awk '{print $1}').msg
+ mv /tmp/upgrade.log ${fail_dir}/$(md5sum "${file}" | awk '{print $1}').log
+ else
+ echo "${file}"
+ fi
+
+ let done_num++
+
+ percent=$(( ${done_num} * 100 / ${total_num} ))
+ if [ ${percent} -gt ${last_percent} ]; then
+ echo "${percent}% completed."
+ last_percent=${percent}
+ fi
+ done
+ done
+done
+
+popd >/dev/null 2>&1
+