This repository has been archived by the owner on Jun 30, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
smd-check-conf
executable file
·99 lines (86 loc) · 2.37 KB
/
smd-check-conf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#!/bin/sh
#
# Released under the terms of GPLv3 or at your option any later version.
# No warranties.
# Copyright Enrico Tassi <[email protected]>
#set -x
SSH="@SSH@"
if [ `echo "$SSH" | cut -c -1` = "@" ]; then
SSH=ssh
echo "`basename $0` not installed, assuming secure shell client is $SSH"
fi
PREFIX="@PREFIX@"
MDDIFF=$PREFIX/bin/mddiff
if [ `echo "$PREFIX" | cut -c -1` = "@" ]; then
MDDIFF=./mddiff
SMDROOT=.
echo "`basename $0` not installed, assuming mddiff is $MDDIFF"
else
SMDROOT=$PREFIX/share/syncmaildir
fi
. $SMDROOT/smd-common
init
parse_args "$@"
read_conffile
check_lockfile
setup_plumbing
setup_logging
setup_mailboxnames
if [ -z "$SERVERNAME" -o -z "$CLIENTNAME" ]; then
echo "ERROR: SERVERNAME or CLIENTNAME not set"
exit 1
fi
if [ ! -z "$MAILBOX" -a ! -z "$MAILBOX_LOCAL" -a "$MAILBOX" != "$MAILBOX_LOCAL" ]; then
echo "ERROR: both MAILBOX and MAILBOX_LOCAL set"
exit 1
fi
if [ ! -z "$MAILBOX" -a ! -z "$MAILBOX_REMOTE" -a "$MAILBOX" != "$MAILBOX_REMOTE" ]; then
echo "ERROR: both MAILBOX and MAILBOX_REMOTE set"
exit 1
fi
if [ -z "$TRANSLATOR_LR" -o -z "$TRANSLATOR_RL" ]; then
echo ERROR: TRANSLATOR_LR and TRANSLATOR_RL not defined
exit 1
fi
cd
TL=`mktemp`
TR=`mktemp`
echo Local mailboxes translated to remote and back:
$MDDIFF $LOCALEXCLUDE -l $MAILBOX_LOCAL > $TL
if [ ! $? -eq 0 ]; then
echo Error while listing the content of $MAILBOX_LOCAL, skipping
else
while read M; do
MM="`echo "$M" | $TRANSLATOR_LR | head -n 1`"
MMM="`echo "$MM" | $TRANSLATOR_RL | head -n 1`"
echo " " $M "->" $MM "->" $MMM
if [ "$M" != "$MMM" ]; then
echo Failed round trip check: $M "->" $MMM
echo " echo "$M" | $TRANSLATOR_LR -> $MM"
echo " echo "$MM" | $TRANSLATOR_RL -> $MMM"
exit 1
fi
done < $TL
fi
echo
echo Remote mailboxes translated to local and back:
$SSH $SERVERNAME $MDDIFF $REMOTEEXCLUDE -l $MAILBOX_REMOTE > $TR
if [ ! $? -eq 0 ]; then
echo Error while listing the content of $MAILBOX_REMOTE, skipping
else
while read M; do
MM="`echo "$M" | $TRANSLATOR_RL | head -n 1`"
MMM="`echo "$MM" | $TRANSLATOR_LR | head -n 1`"
echo " " $M "->" $MM "->" $MMM
if [ "$M" != "$MMM" ]; then
echo Failed round trip check: $M "->" $MMM
echo " echo $M | $TRANSLATOR_RL -> $MM"
echo " echo $MM | $TRANSLATOR_LR -> $MMM"
exit 1
fi
done < $TR
fi
rm $TL $TR
echo "Endpoint $REPNAME configuration file successfully checked"
exit 0
# vim:ts=4: