summaryrefslogtreecommitdiff
path: root/upgrade-to-3.0-native-from-2.3-openpkg
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
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')
-rwxr-xr-xupgrade-to-3.0-native-from-2.3-openpkg/00-oops-i-did-it-again.sh12
-rwxr-xr-xupgrade-to-3.0-native-from-2.3-openpkg/00-sync-from-kolab2.sh66
-rwxr-xr-xupgrade-to-3.0-native-from-2.3-openpkg/01-convert-seen.sh10
-rwxr-xr-xupgrade-to-3.0-native-from-2.3-openpkg/20-start-cyrus-imapd.sh3
-rwxr-xr-xupgrade-to-3.0-native-from-2.3-openpkg/21-select-all-mailboxes.sh10
-rwxr-xr-xupgrade-to-3.0-native-from-2.3-openpkg/22-fix-annotations.sh53
-rwxr-xr-xupgrade-to-3.0-native-from-2.3-openpkg/31-count-groupware-messages.sh65
-rwxr-xr-xupgrade-to-3.0-native-from-2.3-openpkg/32-count-groupware-messages-with-7bit-encoding.sh69
-rwxr-xr-xupgrade-to-3.0-native-from-2.3-openpkg/32-count-groupware-messages-with-base64-encoding.sh69
-rwxr-xr-xupgrade-to-3.0-native-from-2.3-openpkg/32-count-groupware-messages-without-kolab-type-header.sh69
-rwxr-xr-xupgrade-to-3.0-native-from-2.3-openpkg/33-attempt-groupware-messages-formatupgrade.sh103
l---------upgrade-to-3.0-native-from-2.3-openpkg/settings.sh1
12 files changed, 530 insertions, 0 deletions
diff --git a/upgrade-to-3.0-native-from-2.3-openpkg/00-oops-i-did-it-again.sh b/upgrade-to-3.0-native-from-2.3-openpkg/00-oops-i-did-it-again.sh
new file mode 100755
index 0000000..f23ca14
--- /dev/null
+++ b/upgrade-to-3.0-native-from-2.3-openpkg/00-oops-i-did-it-again.sh
@@ -0,0 +1,12 @@
+#!/bin/bash
+
+./00-sync-from-kolab2.sh
+
+./01-convert-seen.sh
+
+./20-start-cyrus-imapd.sh
+
+./21-select-all-mailboxes.sh
+
+./22-fix-annotations.sh
+
diff --git a/upgrade-to-3.0-native-from-2.3-openpkg/00-sync-from-kolab2.sh b/upgrade-to-3.0-native-from-2.3-openpkg/00-sync-from-kolab2.sh
new file mode 100755
index 0000000..b1bf6a2
--- /dev/null
+++ b/upgrade-to-3.0-native-from-2.3-openpkg/00-sync-from-kolab2.sh
@@ -0,0 +1,66 @@
+#!/bin/bash
+
+ . ./settings.sh
+
+set_file_permissions=0
+
+while [ $# -gt 0 ]; do
+ case $1 in
+ --fix-perms|--fix-permissions)
+ set_file_permissions=1
+ shift
+ ;;
+ esac
+done
+
+service cyrus-imapd stop
+
+rm -rf /var/lib/imap/annotations.db
+
+rsync -rltHvz --delete --partial --progress ${kolab2_base}/mailboxes.db /var/lib/imap/mailboxes.db
+
+rsync -rltHvz --delete --partial --progress ${kolab2_base}/domain/ /var/lib/imap/domain/
+
+rsync -rltHvz --delete --partial --progress ${kolab2_base}/spool/ /var/spool/imap/
+
+chown -R cyrus:mail /var/lib/imap /var/spool/imap
+
+if [ ${set_file_permissions} -eq 1 ]; then
+ count_start=`date +'%s'`
+
+ echo -n "Counting files... "
+ total_files=`find /var/lib/imap /var/spool/imap -type f | wc -l`
+ count_end=`date +'%s'`
+ echo "DONE. (${total_files} in $(( ${count_end} - ${count_start} )) seconds)"
+
+ last_percent=0
+ i=0
+ find /var/lib/imap /var/spool/imap -type f | while read file; do
+ chmod 640 "${file}"
+ let i++
+ percent=$(( ${i} * 100 / ${total_files} ))
+ if [ ${percent} -gt ${last_percent} ]; then
+ echo "${percent}% completed."
+ last_percent=${percent}
+ fi
+ done
+
+ echo -n "Counting dirs... "
+ total_dirs=`find /var/lib/imap /var/spool/imap -type d | wc -l`
+ echo "DONE."
+
+ last_percent=0
+ i=0
+ find /var/lib/imap /var/spool/imap -type d | while read dir; do
+ chmod 750 "${dir}"
+ let i++
+ percent=$(( ${i} * 100 / ${total_files} ))
+ if [ ${percent} -gt ${last_percent} ]; then
+ echo "${percent}% completed."
+ last_percent=${percent}
+ fi
+ done
+
+fi
+rsync -aHvz --delete --progress --link-dest /var/lib/imap/ /var/lib/imap/ /var/lib/imap.orig/
+rsync -aHvz --delete --progress --link-dest /var/spool/imap/ /var/spool/imap/ /var/spool/imap.orig/
diff --git a/upgrade-to-3.0-native-from-2.3-openpkg/01-convert-seen.sh b/upgrade-to-3.0-native-from-2.3-openpkg/01-convert-seen.sh
new file mode 100755
index 0000000..afc4cad
--- /dev/null
+++ b/upgrade-to-3.0-native-from-2.3-openpkg/01-convert-seen.sh
@@ -0,0 +1,10 @@
+#!/bin/bash
+
+find /var/lib/imap/ -type f -name "*.seen" | \
+ sort | while read seendb; do
+ /usr/lib/cyrus-imapd/cvt_cyrusdb ${seendb} skiplist ${seendb}.txt flat
+ mv ${seendb} ${seendb}.orig
+ /usr/lib/cyrus-imapd/cvt_cyrusdb ${seendb}.txt flat ${seendb} skiplist
+ chown cyrus:mail ${seendb} ${seendb}.txt ${seendb}.orig
+ done
+
diff --git a/upgrade-to-3.0-native-from-2.3-openpkg/20-start-cyrus-imapd.sh b/upgrade-to-3.0-native-from-2.3-openpkg/20-start-cyrus-imapd.sh
new file mode 100755
index 0000000..08ce498
--- /dev/null
+++ b/upgrade-to-3.0-native-from-2.3-openpkg/20-start-cyrus-imapd.sh
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+service cyrus-imapd start
diff --git a/upgrade-to-3.0-native-from-2.3-openpkg/21-select-all-mailboxes.sh b/upgrade-to-3.0-native-from-2.3-openpkg/21-select-all-mailboxes.sh
new file mode 100755
index 0000000..fb0e293
--- /dev/null
+++ b/upgrade-to-3.0-native-from-2.3-openpkg/21-select-all-mailboxes.sh
@@ -0,0 +1,10 @@
+#!/bin/bash
+
+ . ./settings.sh
+
+echo '. LIST "" "*"' | imtest -t "" -u ${cyrus_admin} -a ${cyrus_admin} -w "${cyrus_admin_pw}" ${imap_host} | sed -r -e '/^\* LIST/!d' -e 's/.*\"\/\"\s(.*)/\1/g' -e 's/^"//g' -e 's/\s*\r*\n*$//g' -e 's/"$//g' | while read folder; do
+
+ echo ". SELECT \"${folder}\""
+
+done | imtest -t "" -u ${cyrus_admin} -a ${cyrus_admin} -w "${cyrus_admin_pw}" ${imap_host}
+
diff --git a/upgrade-to-3.0-native-from-2.3-openpkg/22-fix-annotations.sh b/upgrade-to-3.0-native-from-2.3-openpkg/22-fix-annotations.sh
new file mode 100755
index 0000000..05ce1ab
--- /dev/null
+++ b/upgrade-to-3.0-native-from-2.3-openpkg/22-fix-annotations.sh
@@ -0,0 +1,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
diff --git a/upgrade-to-3.0-native-from-2.3-openpkg/31-count-groupware-messages.sh b/upgrade-to-3.0-native-from-2.3-openpkg/31-count-groupware-messages.sh
new file mode 100755
index 0000000..87edce5
--- /dev/null
+++ b/upgrade-to-3.0-native-from-2.3-openpkg/31-count-groupware-messages.sh
@@ -0,0 +1,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
+
diff --git a/upgrade-to-3.0-native-from-2.3-openpkg/32-count-groupware-messages-with-7bit-encoding.sh b/upgrade-to-3.0-native-from-2.3-openpkg/32-count-groupware-messages-with-7bit-encoding.sh
new file mode 100755
index 0000000..c65e75e
--- /dev/null
+++ b/upgrade-to-3.0-native-from-2.3-openpkg/32-count-groupware-messages-with-7bit-encoding.sh
@@ -0,0 +1,69 @@
+#!/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 "*." | \
+ sort | \
+ while read file; do
+ grep -El "^Content-Transfer-Encoding:\s*7bit" "${file}"
+ done
+ done
+done | wc -l
+
+popd >/dev/null 2>&1
+
diff --git a/upgrade-to-3.0-native-from-2.3-openpkg/32-count-groupware-messages-with-base64-encoding.sh b/upgrade-to-3.0-native-from-2.3-openpkg/32-count-groupware-messages-with-base64-encoding.sh
new file mode 100755
index 0000000..245343d
--- /dev/null
+++ b/upgrade-to-3.0-native-from-2.3-openpkg/32-count-groupware-messages-with-base64-encoding.sh
@@ -0,0 +1,69 @@
+#!/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 "*." | \
+ sort | \
+ while read file; do
+ grep -El "^Content-Transfer-Encoding:\s*base64" "${file}"
+ done
+ done
+done | wc -l
+
+popd >/dev/null 2>&1
+
diff --git a/upgrade-to-3.0-native-from-2.3-openpkg/32-count-groupware-messages-without-kolab-type-header.sh b/upgrade-to-3.0-native-from-2.3-openpkg/32-count-groupware-messages-without-kolab-type-header.sh
new file mode 100755
index 0000000..ad191dc
--- /dev/null
+++ b/upgrade-to-3.0-native-from-2.3-openpkg/32-count-groupware-messages-without-kolab-type-header.sh
@@ -0,0 +1,69 @@
+#!/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 "*." | \
+ sort | \
+ while read file; do
+ grep -L "^X-Kolab-Type:" "${file}"
+ done
+ done
+done | wc -l
+
+popd >/dev/null 2>&1
+
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
+
diff --git a/upgrade-to-3.0-native-from-2.3-openpkg/settings.sh b/upgrade-to-3.0-native-from-2.3-openpkg/settings.sh
new file mode 120000
index 0000000..a08eca5
--- /dev/null
+++ b/upgrade-to-3.0-native-from-2.3-openpkg/settings.sh
@@ -0,0 +1 @@
+../settings.sh \ No newline at end of file