Subversion Repositories sysadmin_scripts

Rev

Go to most recent revision | Details | 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=amy.dailydata.net
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 src u1 p1 u2 p2; do \
39
          imapsync \
40
          --maxsize 20971520 \
41
          --syncinternaldates \
42
          --maxage 1 \
43
          $TESTPARAMS \
44
          --host1 $src --user1 "$u1" --password1 "$p1" --authmech1 PLAIN \
45
          --host2 $TARGET_SERVER --user2 "$u2" --password2 "$p2" --authmech2 PLAIN --sep2 . --prefix2 '' ;
46
done ; } < $INPUT >> $OUTPUT
47
# show completion date/time
48
date >> $OUTPUT
49
 
50
# other parameters of interest for imapsync (place in TESTPARAMS
51
# --justconnect \
52
# --maxsize 5242880 \
53
# --dry \
54
# --delete2 \
55
# --delete2 --expunge2 \
56
#          --maxage 1 \
57
# --justfolders \
58
# --justfoldersizes \
59
#          --maxage 1 \