From 6d6eda8e57b4d73e059b55f8be439e25623490c7 Mon Sep 17 00:00:00 2001 From: Ze'ev Schurmann Date: Tue, 21 Nov 2023 11:38:39 +0200 Subject: [PATCH] Added imapsync-batch-run --- imapsync-batch-run/mail.list | 4 +++ imapsync-batch-run/runsync.sh | 46 +++++++++++++++++++++++++++++++++++ imapsync-batch-run/status.sh | 14 +++++++++++ 3 files changed, 64 insertions(+) create mode 100644 imapsync-batch-run/mail.list create mode 100755 imapsync-batch-run/runsync.sh create mode 100755 imapsync-batch-run/status.sh diff --git a/imapsync-batch-run/mail.list b/imapsync-batch-run/mail.list new file mode 100644 index 0000000..3547070 --- /dev/null +++ b/imapsync-batch-run/mail.list @@ -0,0 +1,4 @@ +source.domain.com destination.domain.com +email1@domain.com secretpassword email1@domain.com secretpassword +email2@domain.com secretpassword email2@domain.com secretpassword +email3@domain.com secretpassword email3@domain.com secretpassword diff --git a/imapsync-batch-run/runsync.sh b/imapsync-batch-run/runsync.sh new file mode 100755 index 0000000..981f652 --- /dev/null +++ b/imapsync-batch-run/runsync.sh @@ -0,0 +1,46 @@ +#!/bin/bash + +move=false + +if [[ ! -z $2 ]]; then + if [[ $2 == "move" ]]; then + move=true + elif [[ $2 == "sync" ]]; then + move=false + fi +fi + +size=$( wc -l < $1 ) +((size++)) +temp=$( cat $1 | head -1 ) +server=( $temp ) +echo "From Server: ${server[0]}" +echo "Dest Server: ${server[1]}" +for ((pos=2; pos<$size; pos++)) +do + temp=$( cat $1 | head -n $pos | tail -1 ) + email=( $temp ) + echo "Number: $((pos-1)) of $((size-2))" + echo "From Email: ${email[0]}" + echo "Password: ${email[1]}" + echo "To Email: ${email[2]}" + echo "Password: ${email[3]}" + echo "Number: $((pos-1)) of $((size-2))" > status.tmp + echo "Email: ${email[2]}" >> status.tmp + echo "Password: ${email[3]}" >> status.tmp + echo "" + if [[ $move == true ]]; then + echo "Moving mails..." + ./imapsync --host1 "${server[0]}" --host2 "${server[1]}" --password1 "${email[1]}" --password2 "${email[3]}" --user1 "${email[0]}" --user2 "${email[2]}" --noemailreport1 --noemailreport2 --delete --noexpunge + elif [[ $move == false ]]; then + echo "Copying mails..." + ./imapsync --host1 "${server[0]}" --host2 "${server[1]}" --password1 "${email[1]}" --password2 "${email[3]}" --user1 "${email[0]}" --user2 "${email[2]}" --noemailreport1 --noemailreport2 --nossl1 --nossl2 --notls1 --notls2 + else + echo "ERROR" + exit 1 + fi + echo "" + #wget -O mailsync.json "https://api.telegram.org/{putkeyhere}/sendMessage?chat_id={putchannelhere}&text=${email[2]}%20Synced!" + rm mailsync.json +done +rm status.tmp diff --git a/imapsync-batch-run/status.sh b/imapsync-batch-run/status.sh new file mode 100755 index 0000000..cee053f --- /dev/null +++ b/imapsync-batch-run/status.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +while true +do + clear + if [[ -f status.tmp ]] + then + cat status.tmp + else + echo "Done!" + exit + fi + sleep 10s +done