Added imapsync-batch-run

This commit is contained in:
Ze'ev Schurmann 2023-11-21 11:38:39 +02:00
parent 99e779b0c5
commit 6d6eda8e57
3 changed files with 64 additions and 0 deletions

View File

@ -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

46
imapsync-batch-run/runsync.sh Executable file
View File

@ -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

14
imapsync-batch-run/status.sh Executable file
View File

@ -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