Subversion Repositories sysadmin_scripts

Rev

Rev 14 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
14 rodolico 1
#! /bin/bash
2
 
3
# script to run imapsync on a group of e-mail accounts
4
# Accounts are listed in users.list (default) or any text file of your choice
5
#     in the SAME DIRECTORY as the script
6
# Two optional and positional parameters
7
#    Param 1 -- input file name overriding default users.list (filename only)
8
#    Param 2 -- If entered (any value), will place script in test mode
9
# INPUT file is a line terminated, colon separated list of e-mail addresses/passwords
10
#     source_email:source_password:target_email:target_password
11
# each line in the file is considered to be a new entry.
12
# all e-mail will be copied from source to target
13
# NOTE: passwords can not contain colons, dollar signs, or any characters subject to shell substitution!!!
14
 
15
# set these to the source and target servers. Source is where you are coping FROM
16
SOURCE_SERVER=10.111.110.204
17
TARGET_SERVER=localhost
18
 
19
# get the path of this script
20
MYPATH=`dirname $0`
21
# load the initialization file. INPUT, OUTPUT defined
22
source $MYPATH/imapsync.include
23
# If first parameter, set it to the INPUT file name
24
[ "$1" == "" ] || INPUT=$MYPATH/$1
25
# validate the input file exists
26
if [ ! -e $INPUT ]
27
then
28
   echo $INPUT does not exist for processing, dying
29
   exit 1
30
fi
31
# if second parameter exists, create test parameters
32
[ "$2" == "" ] || TESTPARAMS=" --dry --justfolders"
33
# show start date/time
34
date > $OUTPUT
35
# and file name processed
36
echo Processing $INPUT > $OUTPUT
37
# loop through all entries in input file, performing 
38
{ while IFS=':' read  u1 p1 u2 p2; do \
39
          imapsync \
40
          --maxsize 20971520 \
41
          --syncinternaldates \
42
          $TESTPARAMS \
43
          --host1 $SOURCE_SERVER --user1 "$u1" --password1 "$p1" --authmech1 PLAIN \
44
          --host2 $TARGET_SERVER --user2 "$u2" --password2 "$p2" --authmech2 PLAIN ;
45
done ; } < $INPUT >> $OUTPUT
46
# show completion date/time
47
date >> $OUTPUT
48
 
49
# other parameters of interest for imapsync (place in TESTPARAMS
50
# --justconnect \
51
# --maxsize 5242880 \
52
# --dry \
53
# --delete2 \
54
# --delete2 --expunge2 \
55
# --justfolders \
56
# --justfoldersizes \