File: smd-pull

package info (click to toggle)
syncmaildir 1.2.5-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 1,104 kB
  • sloc: ansic: 6,643; sh: 1,780; makefile: 247
file content (69 lines) | stat: -rwxr-xr-x 1,285 bytes parent folder | download | duplicates (7)
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
#!/bin/sh
#
# Released under the terms of GPLv3 or at your option any later version.
# No warranties.
# Copyright Enrico Tassi <gares@fettunta.org>

# the idea is (where == is a bi-directional pipe) :
#
#   ssh foo smd-server == tee log == smd-client
#

set -e
#set -x

PREFIX="@PREFIX@"
if [ `echo "$PREFIX" | cut -c -1` = "@" ]; then
	SMDROOT=.
	echo "smd-pull not installed, assuming smd-common is ./smd-common"
else
	SMDROOT=$PREFIX/share/syncmaildir
fi

. $SMDROOT/smd-common

init
parse_args "$@"
read_conffile
# this could be a system wide pre-hook
check_lockfile
setup_plumbing
setup_logging
setup_mailboxnames

# we move to the home, since Mail paths are relative
# to the home
cd

# reset log file before caclling hooks
> $CL

run_hooks $CONFDIR pre pull 0

($MITM $CtS > $LtS) < $CtL &
LOGGER1=$!
atexit_kill $LOGGER1

($MITM $StC > $LtC) < $StL &
LOGGER2=$!
atexit_kill $LOGGER2

($PROGRESS_REPORTER $CL) < $PRp &
REPORTER=$!
atexit_kill $REPORTER

(run_local_client < $LtC 2> $PRp) > $CtL &
CLIENT=$!
atexit_kill $CLIENT

EXITCODE=0
(run_remote_server < $LtS 2> $SL) > $StL  || EXITCODE=1

wait $CLIENT || EXITCODE=1 
wait $REPORTER || EXITCODE=1 

run_hooks $CONFDIR post pull $EXITCODE

report $EXITCODE $SHOWTAGS smd-pull smd-push smd-client smd-server

exit $EXITCODE