Sh3ll



Directory :  /scripts2/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

Current File : //scripts2/imapsync_simple.sh
#!/bin/bash

HOST1=$1
HOST2=$HOSTNAME

SRC=$2

if ! [ $HOST1 ]; then
  echo "Missing remote hostname."
  exit 1
elif ! [ $SRC ]; then
  echo "Missing source file."
  exit 2
fi

> mailbox_ok.txt
> mailbox_error.txt

{ while IFS=';' read u p1 p2 IGNORE
    do 
        if imapsync --host1 "$HOST1" --user1 "$u" --password1 "$p1" \
                 --host2 "$HOST2" --user2 "$u" --password2 "$p2" 
        then
            echo "$u: migration was successful." | tee -a mailbox_ok.txt
        else
            echo "$u: migration finished with an error -> $?." | tee -a mailbox_error.txt
        fi
    done
echo "$HOST1: migration finished. Logs in mailbox_ok.txt, mailbox_error.txt, LOG_imapsync/."
} < "$SRC"

Sh3LL