View Single Post
  #26 (permalink)  
Old 12-01-2005, 10:13 AM
mintra mintra is offline
Special Member
 
Posts: 108
Default IMAP Shell Script

Here is my little script I use for IMAP Sync, it may be of use to someone.

basiclly all the users are in a file called userlist.txt

which looks like this,

Code:
username1;password1
username2;password2
username3;password3
username4;password4
username5;password5
This assumes that the usernames and passwords are the same on both servers. also, the username

is just everything before the @ in the email address.

I wrote it so I could monitor IMAP sync's progress and keep logs of what it does.

Code:
#!/bin/bash

logfile="sinklog.txt"

host1=123.123.123.123
#host1 is Source

host2=321.321.321.321
#host2 is Dest

domain=xyz.com
#domain is where email account is
#everything after @ symbol

###### Do not modify past here
#######################################

date=`date +%X_-_%x`

echo "" >> $logfile
echo "------------------------------------" >> $logfile
echo "IMAPSync started..  $date" >> $logfile
echo "" >> $logfile

{ while IFS=';' read  u1 p1; do 
        user=$u1"@"$domain    
	echo "Syncing User $user"
	date=`date +%X_-_%x`
        echo "Start Syncing User $u1"
        echo "Starting $u1 $date" >> $logfile
imapsync --nosyncacls --syncinternaldates --host1 $host1 --user1 "$user" --password1 "$p1" 

--host2 $host2 --user2 "$user" --password2 "$p1"
     	date=`date +%X_-_%x`
        echo "User $user done"
        echo "Finished $user $date" >> $logfile
	echo "" >> $logfile

	done ; } < userlist.txt

date=`date +%X_-_%x`

echo "" >> $logfile
echo "IMAPSync Finished..  $date" >> $logfile
echo "------------------------------------" >> $logfile
Reply With Quote