diff options
author | Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com> | 2012-08-23 13:50:15 (GMT) |
---|---|---|
committer | Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com> | 2012-08-23 13:50:15 (GMT) |
commit | 811f83ace1e63d493093dff78151e9a64d90cf53 (patch) | |
tree | f3dde9326fdc7b4d3592f46c95bf687915ed4513 | |
parent | be3183ea867ad6fe909e9684b45d6e3667cf2ede (diff) | |
download | kolab-scripts-811f83ace1e63d493093dff78151e9a64d90cf53.tar.gz |
Add the kolab-scripts used in migration and development
23 files changed, 898 insertions, 0 deletions
diff --git a/populate-ldap/000-add-kolab-users-and-groups.sh b/populate-ldap/000-add-kolab-users-and-groups.sh new file mode 100755 index 0000000..5cc5575 --- /dev/null +++ b/populate-ldap/000-add-kolab-users-and-groups.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +if [ -z "$1" ]; then + num_add=10 +else + num_add=$1 +fi + +./00a-add-kolab-users.sh ${num_add} +./00b-add-kolab-users-group.sh diff --git a/populate-ldap/00a-add-kolab-users.sh b/populate-ldap/00a-add-kolab-users.sh new file mode 100755 index 0000000..3c1586a --- /dev/null +++ b/populate-ldap/00a-add-kolab-users.sh @@ -0,0 +1,84 @@ +#!/bin/bash + + . ./settings.sh + +i=0 +while [ $i -lt 0$1 ]; do + + givenname=`head -c 200 /dev/urandom | tr -dc A-Za-z | head -c5` + surname=`head -c 200 /dev/urandom | tr -dc A-Za-z | head -c10` + + givenname="$(echo ${givenname:0:1} | tr '[:lower:]' '[:upper:]')$(echo ${givenname:1} | tr '[:upper:]' '[:lower:]')" + givenname_lower="$(echo ${givenname} | tr '[:upper:]' '[:lower:]')" + surname="$(echo ${surname:0:1} | tr '[:lower:]' '[:upper:]')$(echo ${surname:1} | tr '[:upper:]' '[:lower:]')" + surname_lower="$(echo ${surname} | tr '[:upper:]' '[:lower:]')" + + uid="$(echo ${givenname:0:1}.${surname} | tr '[:upper:]' '[:lower:]')" + + userpassword="Welcome2KolabSystems" + + telephonenumber="" + if [ $(( $RANDOM % 2 )) -eq 0 ]; then + telephonenumber="+" + while [ "$(echo ${telephonenumber} | wc -c)" -lt 12 ]; do + telephonenumber="${telephonenumber}$(echo $RANDOM)" + done + fi + + mobile="" + if [ $(( $RANDOM % 2 )) -eq 0 ]; then + mobile="+" + while [ "$(echo ${mobile} | wc -c)" -lt 12 ]; do + mobile="${mobile}$(echo $RANDOM)" + done + fi + + jpegphoto_from="" + if [ $(( $RANDOM % 2 )) -eq 0 ]; then + [ ! -f "/root/hackergotchi.png" ] && \ + wget -q -O/root/hackergotchi.png \ + http://kanarip.fedorapeople.org/kanarip.png + + jpegphoto_from="< file:/root/hackergotchi.png" + fi + + mailalternateaddress="" + if [ $(( $RANDOM % 2 )) -eq 0 ]; then + mailalternateaddress="${uid}@${surname_lower}.com" + fi + + echo "dn: uid=$uid,ou=People,${rootdn}" + echo "uid: $uid" + echo "givenName: $givenname" + echo "objectClass: top" + echo "objectClass: person" + echo "objectClass: inetOrgPerson" + echo "objectclass: kolabinetorgperson" + echo "objectclass: organizationalperson" + echo "objectclass: mailrecipient" + + if [ ! -z "${telephonenumber}" ]; then + echo "telephonenumber: ${telephonenumber}" + fi + + if [ ! -z "${mobile}" ]; then + echo "mobile: ${mobile}" + fi + + if [ ! -z "${jpegphoto_from}" ]; then + echo "jpegphoto:${jpegphoto_from}" + fi + + if [ ! -z "${mailalternateaddress}" ]; then + echo "mailalternateaddress: ${mailalternateaddress}" + fi + + echo "sn: $surname" + echo "cn: $givenname $surname" + echo "displayname: $surname, $givenname" + echo "mail: ${givenname_lower}.${surname_lower}@${domain}" + echo "" + + let i++ +done | ldapadd -x -h ${ldap_host} -D "${ldap_binddn}" -w "${ldap_bindpw}" -c + diff --git a/populate-ldap/00b-add-kolab-users-group.sh b/populate-ldap/00b-add-kolab-users-group.sh new file mode 100755 index 0000000..6f1670c --- /dev/null +++ b/populate-ldap/00b-add-kolab-users-group.sh @@ -0,0 +1,15 @@ +#!/bin/bash + + . ./settings.sh + +( + echo "dn: cn=Kolab Users,ou=Groups,${rootdn}" + echo "objectClass: top" + echo "objectClass: groupofurls" + echo "objectClass: kolabgroupofuniquenames" + echo "cn: Kolab Users" + echo "mail: kolab-users@${domain}" + echo "memberURL: ldap:///ou=People,${rootdn}??sub?(&(objectClass=kolabinetorgperson)(mail=*))" + echo "" +) | ldapadd -x -h ${ldap_host} -D "${ldap_binddn}" -w "${ldap_bindpw}" -c + diff --git a/populate-ldap/100-add-vlv.sh b/populate-ldap/100-add-vlv.sh new file mode 100755 index 0000000..d4b90c1 --- /dev/null +++ b/populate-ldap/100-add-vlv.sh @@ -0,0 +1,9 @@ +#!/bin/bash + + . ./settings.sh + +./10a-add-vlv-searches.sh +./10b-add-vlv-indexes.sh +./10c-run-vlv-index-tasks.sh +./10d-test-use-detected-vlv.sh + diff --git a/populate-ldap/10a-add-vlv-searches.sh b/populate-ldap/10a-add-vlv-searches.sh new file mode 100755 index 0000000..96f5752 --- /dev/null +++ b/populate-ldap/10a-add-vlv-searches.sh @@ -0,0 +1,28 @@ +#!/bin/bash + + . ./settings.sh + +( + echo "dn: cn=People VLV Search,cn=${domain_db},cn=ldbm database,cn=plugins,cn=config" + echo "objectClass: top" + echo "objectClass: vlvSearch" + echo "cn: People VLV Search" + echo "vlvBase: ou=People,${rootdn}" + echo "vlvScope: 2" + echo "vlvFilter: (objectclass=inetorgperson)" + echo "aci: (targetattr = \"*\") (version 3.0;acl \"Read Access\";allow (read,compare,search)(userdn = \"ldap:///anyone\");)" + echo "" +) | ldapadd -x -h ${ldap_host} -D "${ldap_binddn}" -w "${ldap_bindpw}" -c + +( + echo "dn: cn=Groups VLV Search,cn=${domain_db},cn=ldbm database,cn=plugins,cn=config" + echo "objectClass: top" + echo "objectClass: vlvSearch" + echo "cn: Groups VLV Search" + echo "vlvBase: ou=Groups,${rootdn}" + echo "vlvScope: 2" + echo "vlvFilter: (|(objectclass=groupofuniquenames)(objectclass=groupofurls))" + echo "aci: (targetattr = \"*\") (version 3.0;acl \"Read Access\";allow (read,compare,search)(userdn = \"ldap:///anyone\");)" + echo "" +) | ldapadd -x -h ${ldap_host} -D "${ldap_binddn}" -w "${ldap_bindpw}" -c + diff --git a/populate-ldap/10b-add-vlv-indexes.sh b/populate-ldap/10b-add-vlv-indexes.sh new file mode 100755 index 0000000..92fcabc --- /dev/null +++ b/populate-ldap/10b-add-vlv-indexes.sh @@ -0,0 +1,24 @@ +#!/bin/bash + + . ./settings.sh + +( + echo "dn: cn=People VLV Index,cn=People VLV Search,cn=${domain_db},cn=ldbm database,cn=plugins,cn=config" + echo "objectClass: top" + echo "objectClass: vlvIndex" + echo "cn: People VLV Index" + echo "vlvSort: displayname sn givenname cn" + echo "aci: (targetattr = \"*\") (version 3.0;acl \"Read Access\";allow (read,compare,search)(userdn = \"ldap:///anyone\");)" + echo "" +) | ldapadd -x -h ${ldap_host} -D "${ldap_binddn}" -w "${ldap_bindpw}" -c + +( + echo "dn: cn=Groups VLV Index,cn=Groups VLV Search,cn=${domain_db},cn=ldbm database,cn=plugins,cn=config" + echo "objectClass: top" + echo "objectClass: vlvIndex" + echo "cn: Groups VLV Index" + echo "vlvSort: cn" + echo "aci: (targetattr = \"*\") (version 3.0;acl \"Read Access\";allow (read,compare,search)(userdn = \"ldap:///anyone\");)" + echo "" +) | ldapadd -x -h ${ldap_host} -D "${ldap_binddn}" -w "${ldap_bindpw}" -c + diff --git a/populate-ldap/10c-run-vlv-index-tasks.sh b/populate-ldap/10c-run-vlv-index-tasks.sh new file mode 100755 index 0000000..31fd2ca --- /dev/null +++ b/populate-ldap/10c-run-vlv-index-tasks.sh @@ -0,0 +1,71 @@ +#!/bin/bash + + . ./settings.sh + +( + echo "dn: cn=${domain_db} People VLV Index,cn=index,cn=tasks,cn=config" + echo "objectclass: top" + echo "objectclass: extensibleObject" + echo "cn: ${domain_db} People VLV Index" + echo "nsinstance: ${domain_db}" + echo "nsIndexVLVAttribute: People VLV Index" + echo "" +) | ldapmodify -a -x -h ${ldap_host} -D "${ldap_binddn}" -w "${ldap_bindpw}" -c + +ldap_complete=0 + +while [ ${ldap_complete} -ne 1 ]; do + result=$( + ldapsearch \ + -x \ + -h ${ldap_host} \ + -D "${ldap_binddn}" \ + -w "${ldap_bindpw}" \ + -c \ + -LLL \ + -b "cn=${domain_db} People VLV Index,cn=index,cn=tasks,cn=config" \ + -s base 2>/dev/null + ) + if [ -z "$result" ]; then + ldap_complete=1 + echo "" + else + echo -n "." + sleep 1 + fi +done + +( + echo "dn: cn=${domain_db} Groups VLV Index,cn=index,cn=tasks,cn=config" + echo "objectclass: top" + echo "objectclass: extensibleObject" + echo "cn: ${domain_db} Groups VLV Index" + echo "nsinstance: ${domain_db}" + echo "nsIndexVLVAttribute: Groups VLV Index" + echo "" +) | ldapmodify -a -x -h ${ldap_host} -D "${ldap_binddn}" -w "${ldap_bindpw}" -c + +ldap_complete=0 + +while [ ${ldap_complete} -ne 1 ]; do + result=$( + ldapsearch \ + -x \ + -h ${ldap_host} \ + -D "${ldap_binddn}" \ + -w "${ldap_bindpw}" \ + -c \ + -LLL \ + -b "cn=${domain_db} Groups VLV Index,cn=index,cn=tasks,cn=config" \ + -s base 2>/dev/null + ) + if [ -z "$result" ]; then + ldap_complete=1 + echo "" + else + echo -n "." + sleep 1 + fi +done + + diff --git a/populate-ldap/10d-test-use-detected-vlv.sh b/populate-ldap/10d-test-use-detected-vlv.sh new file mode 100755 index 0000000..1b21aca --- /dev/null +++ b/populate-ldap/10d-test-use-detected-vlv.sh @@ -0,0 +1,78 @@ +#!/bin/bash + + . ./settings.sh + +( + ldapsearch -x -h ${ldap_host} -D "${ldap_binddn}" -w "${ldap_bindpw}" -LLL -b "cn=ldbm database,cn=plugins,cn=config" "(objectclass=vlvsearch)" entrydn | grep ^dn | cut -d':' -f2- +) | while read vlvsearch; do + vlvbasedn=`ldapsearch -x -h ${ldap_host} -D "${ldap_binddn}" -w "${ldap_bindpw}" -LLL -b "${vlvsearch}" -s base vlvbase | grep -i ^vlvbase | awk 'BEGIN { FS = ": " } ; {print $2}'` + vlvscope=`ldapsearch -x -h ${ldap_host} -D "${ldap_binddn}" -w "${ldap_bindpw}" -LLL -b "${vlvsearch}" -s base vlvscope | grep -i ^vlvscope | awk 'BEGIN { FS = ": " } ; {print $2}'` + vlvfilter=`ldapsearch -x -h ${ldap_host} -D "${ldap_binddn}" -w "${ldap_bindpw}" -LLL -b "${vlvsearch}" -s base vlvfilter | grep -i ^vlvfilter | awk 'BEGIN { FS = ": " } ; {print $2}'` + vlvsort=`ldapsearch -x -h ${ldap_host} -D "${ldap_binddn}" -w "${ldap_bindpw}" -LLL -b "${vlvsearch}" -s sub "(objectclass=vlvIndex)" vlvsort | grep -i ^vlvsort | awk 'BEGIN { FS = ": " } ; {print $2}'` + + echo "Found a VLV index and search with parameters:" + echo " - Base: ${vlvbasedn}" + echo -n " - Scope: " + + case ${vlvscope} in + 0) + echo "base" + vlvscope="base" + ;; + + 1) + echo "one" + vlvscope="one" + ;; + + 2) + echo "sub" + vlvscope="sub" + ;; + esac + + echo " - Filter: ${vlvfilter}" + echo " - Sorting by: ${vlvsort}" + + # Use it + + uses_before=`ldapsearch \ + -x \ + -h ${ldap_host} \ + -D "${ldap_binddn}" \ + -w "${ldap_bindpw}" \ + -b "cn=ldbm database,cn=plugins,cn=config" \ + -s sub \ + "(&(objectclass=vlvindex)(vlvsort=${vlvsort}))" \ + -LLL \ + vlvuses | \ + grep -i ^vlvuses | awk '{print $2}'` + + echo "after" | ldapsearch \ + -x \ + -h ${ldap_host} \ + -D "${ldap_binddn}" \ + -w "${ldap_bindpw}" \ + -b "${vlvbasedn}" \ + -s ${vlvscope} "${vlvfilter}" \ + -E '!vlv=5/5/1/10' \ + -E "!sss=$(echo ${vlvsort} | sed -e 's| |/|g')" >/dev/null 2>&1 + + uses_after=`ldapsearch \ + -x \ + -h ${ldap_host} \ + -D "${ldap_binddn}" \ + -w "${ldap_bindpw}" \ + -b "cn=ldbm database,cn=plugins,cn=config" \ + -s sub \ + "(&(objectclass=vlvindex)(vlvsort=${vlvsort}))" \ + -LLL \ + vlvuses | \ + grep -i ^vlvuses | awk '{print $2}'` + + if [ ${uses_before} -lt ${uses_after} ]; then + echo "Actually works, too (before: ${uses_before}, after: ${uses_after})" + fi +done + + diff --git a/populate-ldap/99-cleanup-users-and-groups.sh b/populate-ldap/99-cleanup-users-and-groups.sh new file mode 100755 index 0000000..38c3f39 --- /dev/null +++ b/populate-ldap/99-cleanup-users-and-groups.sh @@ -0,0 +1,33 @@ +#!/bin/bash + + . ./settings.sh + +( + ldapsearch \ + -x \ + -h ${ldap_host} \ + -D "${ldap_binddn}" \ + -w "${ldap_bindpw}" \ + -b "ou=People,${rootdn}" \ + -s one \ + "(objectclass=inetorgperson)" \ + -LLL \ + dn | \ + grep ^dn | \ + sed -e 's/dn: //g' +) | ldapdelete -x -h ${ldap_host} -D "${ldap_binddn}" -w "${ldap_bindpw}" -c + +( + ldapsearch \ + -x \ + -h ${ldap_host} \ + -D "${ldap_binddn}" \ + -w "${ldap_bindpw}" \ + -b "ou=Groups,${rootdn}" \ + "(|(objectclass=groupofuniquenames)(objectclass=groupofurls))" \ + -LLL \ + dn | \ + grep ^dn | \ + sed -e 's/dn: //g' +) | ldapdelete -x -h ${ldap_host} -D "${ldap_binddn}" -w "${ldap_bindpw}" -c + diff --git a/populate-ldap/settings.sh b/populate-ldap/settings.sh new file mode 120000 index 0000000..a08eca5 --- /dev/null +++ b/populate-ldap/settings.sh @@ -0,0 +1 @@ +../settings.sh
\ No newline at end of file diff --git a/settings.sh b/settings.sh new file mode 100755 index 0000000..1eb1dce --- /dev/null +++ b/settings.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +export rootdn="dc=example,dc=org" +export domain="example.org" +export domain_db="example_org" +export ldap_host="localhost" +export ldap_binddn="cn=Directory Manager" +export ldap_bindpw="Welcome2KolabSystems" + +export cyrus_admin="cyrus-admin" + +export kolab2_base="kolab.kolabsys.com:/kolab/var/imapd/" + +export imap_host="${ldap_host}" +export cyrus_admin_pw="${ldap_bindpw}" 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 |