Import from Zimbra to Thunderbird
This commit is contained in:
parent
eaa9502347
commit
9bace6ecdc
1 changed files with 46 additions and 0 deletions
46
Bash/zimbra2thunderbird.sh
Normal file
46
Bash/zimbra2thunderbird.sh
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
#!/usr/bin/bash
|
||||||
|
|
||||||
|
if [ ! $# = 3 ]
|
||||||
|
then
|
||||||
|
echo 'Usage : zimbra2thunderbird.sh PROFILE_DIR ARCHIVE FOLDER_NAME'
|
||||||
|
echo
|
||||||
|
echo 'PROFILE_DIR Thunderbird Profile directory'
|
||||||
|
echo 'ARCHIVE Zip over Tarball archive (Zimbra EML files)'
|
||||||
|
echo "FOLDER_NAME E-mail folder name"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
declare -r ROOT_DIR="${1}/Mail/Local Folders"
|
||||||
|
declare -r TMP_DIR="/tmp/zimbra2thunderbird"
|
||||||
|
|
||||||
|
# from_line META_FILE
|
||||||
|
function from_line()
|
||||||
|
(
|
||||||
|
declare -r FILE="$1"
|
||||||
|
declare -r ADDRESS=$( grep -o '"sender":"[^,"]*' "${FILE}" | sed 's/"sender":"//;s/\s//' )
|
||||||
|
declare -r SECONDES=$( grep -o '"date":[0-9]*' "${FILE}" | sed 's/"date"://' )
|
||||||
|
declare -r DATE=$( LANG=C date -d "@${SECONDES}" '+%a %b %d %H:%M:%S %Y' )
|
||||||
|
echo "From ${ADDRESS} ${DATE}"
|
||||||
|
)
|
||||||
|
|
||||||
|
mkdir "$TMP_DIR"
|
||||||
|
cd "$TMP_DIR" || exit 1
|
||||||
|
|
||||||
|
tar -xzf "$2"
|
||||||
|
|
||||||
|
touch "${ROOT_DIR}/${3}"
|
||||||
|
mkdir "${ROOT_DIR}/${3}.sbd"
|
||||||
|
for folder in *
|
||||||
|
do
|
||||||
|
touch "${folder}.mbox"
|
||||||
|
for eml in ${folder}/*.eml
|
||||||
|
do
|
||||||
|
from_line "${eml}.meta"
|
||||||
|
cat "${eml}"
|
||||||
|
echo
|
||||||
|
done >> "${folder}.mbox"
|
||||||
|
mv "${folder}.mbox" "${ROOT_DIR}/${3}.sbd/${folder}"
|
||||||
|
done
|
||||||
|
|
||||||
|
cd || exit 1
|
||||||
|
rm -rf "$TMP_DIR"
|
Loading…
Reference in a new issue