mirror of
https://github.com/imapsync/imapsync.git
synced 2025-06-07 05:05:23 +02:00
2.140
This commit is contained in:
parent
4ce248c075
commit
f26b2573c3
370 changed files with 14441 additions and 136699 deletions
|
@ -1,6 +1,11 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# $Id: sync_parallel_unix.sh,v 1.7 2018/12/06 10:09:03 gilles Exp gilles $
|
||||
# $Id: sync_parallel_unix.sh,v 1.9 2021/02/19 13:41:51 gilles Exp gilles $
|
||||
|
||||
# If you're on Windows there is a possibility to install and use parallel
|
||||
# but I have never tested it. I found:
|
||||
# https://stackoverflow.com/questions/52393850/how-to-install-gnu-parallel-on-windows-10-using-git-bash
|
||||
|
||||
|
||||
# Example for imapsync massive migration on Unix systems.
|
||||
# See also http://imapsync.lamiral.info/FAQ.d/FAQ.Massive.txt
|
||||
|
@ -12,8 +17,11 @@
|
|||
# in the while loop below.
|
||||
# # Each line contains 6 columns, columns are parameter values for
|
||||
# --host1 --user1 --password1 --host2 --user2 --password2
|
||||
# and a trailing empty fake column to avoid CR LF part going
|
||||
# in the 6th parameter password2. Don't forget the last semicolon.
|
||||
#
|
||||
# Extra columns can be used to pass extra parameters but the script reading
|
||||
# this file have to read them into some variables.
|
||||
#
|
||||
# Last, don't forget the last semicolon.
|
||||
#
|
||||
# You can add extra options after the last line
|
||||
# Use character backslash \ at the end of each supplementary line, except for the last one.
|
||||
|
@ -22,32 +30,93 @@
|
|||
# The credentials filename "file.txt" used for the loop can be renamed
|
||||
# by changing "file.txt" below.
|
||||
|
||||
# The part 'echo {1} | egrep "^#" > /dev/null ||' is just there to skip commented lines in file.txt
|
||||
# It can be removed if there is no comment lines in file.txt
|
||||
# Now I explain what come next, the actual stuff, which is barely
|
||||
# a single long command line written on several lines for the reading
|
||||
# convenience
|
||||
|
||||
# The first word is the parallel command itself, it's a perl utility
|
||||
# written by Ole Tange, available on Linux systems, already packaged.
|
||||
# It is also called GNU Parallel. The GNU Parallel homepage is
|
||||
# https://www.gnu.org/software/parallel/
|
||||
# Parallel is very powerful, you could easily distribute the parallel stuff
|
||||
# on remote machines with it (not used here).
|
||||
|
||||
# The parallel command is then followed by its parameters.
|
||||
# parallel parameters explained:
|
||||
#
|
||||
# --max-procs 7 means parallel will parallelize up to 7 jobs at a time,
|
||||
# adjust this value by monitoring your system capacity.
|
||||
#
|
||||
# --delay 1.1 means parallel will pause 1.1 seconds after starting each job.
|
||||
#
|
||||
# --colsep ';' means the separator between values is the character semi-colon ;
|
||||
#
|
||||
# --arg-file file.txt means the actual input file is named file.txt
|
||||
#
|
||||
# --line-buffer means outputs will be of whole lines instead of a big mess
|
||||
# of part of them for the different processes. One line belongs to one process.
|
||||
#
|
||||
# --tagstring "from {2} to {5} : " mean that each line will begin with the
|
||||
# words "from {2} to {5} : " where {2} will be replaced by the second column
|
||||
# and {5} will be replaced by the fifth column. Hack this part as you wish
|
||||
|
||||
|
||||
# The remaining parameters is the command to be executed by the parallel
|
||||
# command, ie, the command to be run several times in parallel with
|
||||
# different parameters each time.
|
||||
|
||||
# Some explanations about this remaining parts.
|
||||
#
|
||||
# The part 'echo {1} | egrep "^#" > /dev/null ||' is just there to skip
|
||||
# commented lines in file.txt
|
||||
# It can be removed if there is no comment lines in file.txt
|
||||
|
||||
# The part $DRYRUN is a variable that can be either the echo command
|
||||
# or nothing. It is a trick to permit you to see the command and its
|
||||
# parameters without running it
|
||||
#
|
||||
|
||||
# {1} will be replaced by the first column in file.txt
|
||||
# {2} will be replaced by the second column in file.txt
|
||||
# {3} will be replaced by the third column in file.txt
|
||||
# ...
|
||||
|
||||
|
||||
# "$@" will be replaced by the parameters of this script itself,
|
||||
# the one you are reading now. It's usefull if you want to
|
||||
# add temporarly a parameter for all runs without editing any file.
|
||||
# For example,
|
||||
# sync_parallel_unix.sh --justlogin
|
||||
# will run all imapsync with the --justlogin parameter added.
|
||||
|
||||
# --simulong 5 is just there to show that you can also add parameters
|
||||
# here and that you have read this section. --simulong 5 does nothing
|
||||
# else than printing "Are you still here ETA: xx/25 msgs left"
|
||||
# five times per second. It will show the living output of all
|
||||
# paralelized runs
|
||||
|
||||
# --delay 2 means parallel will pause 2 seconds after starting each job.
|
||||
|
||||
check_parallel_is_here() {
|
||||
parallel --version > /dev/null || { echo "parallel command is not installed. Install it first."; return 1; }
|
||||
}
|
||||
|
||||
# First, there is no need to go further if the parallel command is not avalable
|
||||
# one the current system.
|
||||
|
||||
check_parallel_is_here || exit 1 ;
|
||||
|
||||
echo Looping with parallel on account credentials found in file.txt
|
||||
echo
|
||||
|
||||
|
||||
DRYRUN=echo
|
||||
# Comment the next line if you want to see the imapsync command instead of running it
|
||||
# since the previous echo value will be discarded
|
||||
DRYRUN=
|
||||
|
||||
parallel --max-procs 7 --delay 2 --colsep ';' --arg-file file.txt --line-buffer --tagstring "from {2} to {5} : " \
|
||||
parallel --max-procs 7 --delay 1.1 --colsep ';' --arg-file file.txt --line-buffer --tagstring "from {2} to {5} : " \
|
||||
'echo {1} | egrep "^#|^ *$" > /dev/null ||' \
|
||||
$DRYRUN imapsync --host1 {1} --user1 {2} --password1 {3} \
|
||||
--host2 {4} --user2 {5} --password2 {6}
|
||||
--host2 {4} --user2 {5} --password2 {6} "$@" --simulong 5
|
||||
|
||||
|
||||
|
||||
# {=7=} "$@"
|
Loading…
Add table
Add a link
Reference in a new issue