File: smd-push

package info (click to toggle)
syncmaildir 1.2.6-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 1,180 kB
  • ctags: 476
  • sloc: ansic: 6,338; sh: 1,969; makefile: 258; xml: 14
file content (71 lines) | stat: -rwxr-xr-x 1,301 bytes parent folder | download | duplicates (6)
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
#!/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-client == tee log == smd-server
#

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 push 0

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

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

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

setup_workarea

(run_local_server < $LtC 2>> $CL) > $CtL &
CLIENT=$!
atexit_kill $CLIENT

EXITCODE=0
(run_remote_client < $LtS 2> $PRp) > $StL || EXITCODE=1

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

run_hooks $CONFDIR post push $EXITCODE

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

exit $EXITCODE