No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

smd-pull 1.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #!/bin/sh
  2. #
  3. # Released under the terms of GPLv3 or at your option any later version.
  4. # No warranties.
  5. # Copyright Enrico Tassi <gares@fettunta.org>
  6. # the idea is (where == is a bi-directional pipe) :
  7. #
  8. # ssh foo smd-server == tee log == smd-client
  9. #
  10. set -e
  11. #set -x
  12. PREFIX="@PREFIX@"
  13. if [ `echo "$PREFIX" | cut -c -1` = "@" ]; then
  14. SMDROOT=.
  15. echo "smd-pull not installed, assuming smd-common is ./smd-common"
  16. else
  17. SMDROOT=$PREFIX/share/syncmaildir
  18. fi
  19. . $SMDROOT/smd-common
  20. init
  21. parse_args "$@"
  22. read_conffile
  23. # this could be a system wide pre-hook
  24. check_lockfile
  25. setup_plumbing
  26. setup_logging
  27. setup_mailboxnames
  28. # we move to the home, since Mail paths are relative
  29. # to the home
  30. cd
  31. # reset log file before caclling hooks
  32. > $CL
  33. run_hooks $CONFDIR pre pull 0
  34. ($MITM $CtS > $LtS) < $CtL &
  35. LOGGER1=$!
  36. atexit_kill $LOGGER1
  37. ($MITM $StC > $LtC) < $StL &
  38. LOGGER2=$!
  39. atexit_kill $LOGGER2
  40. ($PROGRESS_REPORTER $CL) < $PRp &
  41. REPORTER=$!
  42. atexit_kill $REPORTER
  43. (run_local_client < $LtC 2> $PRp) > $CtL &
  44. CLIENT=$!
  45. atexit_kill $CLIENT
  46. EXITCODE=0
  47. (run_remote_server < $LtS 2> $SL) > $StL || EXITCODE=1
  48. wait $CLIENT || EXITCODE=1
  49. wait $REPORTER || EXITCODE=1
  50. run_hooks $CONFDIR post pull $EXITCODE
  51. report $EXITCODE $SHOWTAGS smd-pull smd-push smd-client smd-server
  52. exit $EXITCODE