2012-12-29 01:43:39 +01:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
2014-05-30 03:56:21 +02:00
|
|
|
# $Id: sync_loop_unix.sh,v 1.4 2014/05/22 14:22:15 gilles Exp gilles $
|
2012-12-29 01:43:39 +01:00
|
|
|
|
|
|
|
# Example for imapsync massive migration on Unix systems.
|
|
|
|
#
|
|
|
|
# Data is supposed to be in file.txt in the following format
|
2014-05-30 03:56:21 +02:00
|
|
|
# user001_1;password001_1;user001_2;password001_2
|
|
|
|
# ...
|
|
|
|
# Separator is character semi-colon ";" it can be changed by any character changing IFS=';'
|
|
|
|
# in the while loop below.
|
2012-12-29 01:43:39 +01:00
|
|
|
# Each data line contains 4 columns, columns are parameters for --user1 --password1 --user2 --password2
|
|
|
|
#
|
2014-05-30 03:56:21 +02:00
|
|
|
# For Mac users you may have to add a fake fifth element in file.txt to avoid that a CR character
|
|
|
|
# goes in the p2 variable. Change also the read command to "read u1 p1 u2 p2 fake".
|
|
|
|
#
|
|
|
|
# Replace "imap.side1.org" and "imap.side2.org" with your own hostname values.
|
|
|
|
# You can add extra options after --password2 "$p2"
|
|
|
|
# Use character backslash \ at the end of each suplementary line, exept for the last one.
|
2012-12-29 01:43:39 +01:00
|
|
|
|
2014-05-30 03:56:21 +02:00
|
|
|
echo Looping on account credentials found in file.txt
|
|
|
|
echo
|
2012-12-29 01:43:39 +01:00
|
|
|
|
|
|
|
{ while IFS=';' read u1 p1 u2 p2
|
|
|
|
do
|
2014-05-30 03:56:21 +02:00
|
|
|
{ echo "$u1" | egrep "^#" ; } > /dev/null && continue # this skip commented lines in file.txt
|
|
|
|
echo "==== Syncing user $u1 to user $u2 ===="
|
|
|
|
imapsync --host1 imap.side1.org --user1 "$u1" --password1 "$p1" \
|
|
|
|
--host2 imap.side2.org --user2 "$u2" --password2 "$p2"
|
|
|
|
|
|
|
|
echo "==== End syncing user $u1 to user $u2 ===="
|
|
|
|
echo
|
2012-12-29 01:43:39 +01:00
|
|
|
done
|
|
|
|
} < file.txt
|
|
|
|
|