1
0
mirror of https://github.com/imapsync/imapsync.git synced 2024-11-17 08:12:48 +01:00
imapsync/examples/sync_loop_unix.sh

42 lines
1.6 KiB
Bash
Raw Normal View History

2012-12-29 01:43:39 +01:00
#!/bin/sh
#
2018-05-07 16:04:23 +02:00
# $Id: sync_loop_unix.sh,v 1.8 2018/02/12 21:53:40 gilles Exp gilles $
2012-12-29 01:43:39 +01:00
# Example for imapsync massive migration on Unix systems.
2015-12-03 18:16:32 +01:00
# See also http://imapsync.lamiral.info/FAQ.d/FAQ.Massive.txt
#
# Data is supposed to be in file.txt in the following format:
# host001_1;user001_1;password001_1;host001_2;user001_2;password001_2;
2014-05-30 03:56:21 +02:00
# ...
# Separator is character semi-colon ";" it can be changed by any character changing IFS=';'
# in the while loop below.
2015-12-03 18:16:32 +01:00
# # Each line contains 6 columns, columns are parameter values for
# --host1 --user1 --password1 --host2 --user2 --password2
2018-05-07 16:04:23 +02:00
# and a trailing empty fake column to avoid CR LF part going
2015-12-03 18:16:32 +01:00
# in the 6th parameter password2. Don't forget the last semicolon.
2012-12-29 01:43:39 +01:00
#
2015-12-03 18:16:32 +01:00
# You can add extra options after the variable "$@"
2018-05-07 16:04:23 +02:00
# Use character backslash \ at the end of each supplementary line, except for the last one.
2015-12-03 18:16:32 +01:00
# You can also pass extra options via the parameters of this script since
# they will be in "$@"
# The credentials filename "file.txt" used for the loop can be renamed
# by changing "file.txt" below.
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
2015-12-03 18:16:32 +01:00
{ while IFS=';' read h1 u1 p1 h2 u2 p2 fake
2012-12-29 01:43:39 +01:00
do
2018-05-07 16:04:23 +02:00
{ echo "$h1" | tr -d '\r' | egrep '^#|^ *$' ; } > /dev/null && continue # this skip commented lines in file.txt
2015-12-03 18:16:32 +01:00
echo "==== Starting imapsync from host1 $h1 user1 $u1 to host2 $h2 user2 $u2 ===="
imapsync --host1 "$h1" --user1 "$u1" --password1 "$p1" \
--host2 "$h2" --user2 "$u2" --password2 "$p2" \
"$@"
echo "==== Ended imapsync from host1 $h1 user1 $u1 to host2 $h2 user2 $u2 ===="
2014-05-30 03:56:21 +02:00
echo
2012-12-29 01:43:39 +01:00
done
} < file.txt