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-uniform-names 2.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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:
  7. # 0) it is the first run (no db)
  8. # 1) we compute the local db with mddiff
  9. # 2) we push it to the remote host via ssh
  10. # 3) we start a special pull where smd-server uses the special db
  11. # and where smd-client just emits a shell script with all the renaming
  12. # 4) we remove the remote db
  13. set -e
  14. #set -x
  15. PREFIX="@PREFIX@"
  16. if [ `echo "$PREFIX" | cut -c -1` = "@" ]; then
  17. SMDROOT=.
  18. echo "smd-uniform-names not installed, assuming smd-common is ./smd-common"
  19. else
  20. SMDROOT=$PREFIX/share/syncmaildir
  21. fi
  22. . $SMDROOT/smd-common
  23. init
  24. parse_args "$@"
  25. read_conffile
  26. # this could be a system wide pre-hook
  27. check_lockfile
  28. setup_plumbing
  29. setup_logging
  30. setup_mailboxnames
  31. # we move to the home, since Mail paths are relative
  32. # to the home
  33. cd
  34. setup_workarea
  35. ORIG_CHILDARGS="$CHILDSARGS"
  36. CHILDSARGS="$ORIG_CHILDARGS --get-mddiff-cmdline"
  37. DB=`run_local_server | sed 's?^.*--db-file \([^ ][^ ]*\) .*$?\1?'`
  38. if [ -e "$DB" ]; then
  39. echo "Found db file: $DB"
  40. echo "This utility can be used only before any synchronization"
  41. echo "takes place. See the manpage for more details."
  42. exit 1
  43. fi
  44. CHILDSARGS="$ORIG_CHILDARGS --get-mddiff-cmdline --override-db ~/$RENAMEDB"
  45. MDLINE=`run_local_server`
  46. EXITCODE=0
  47. gc_mktemp
  48. TMPERR="$RC"
  49. gc_mktemp
  50. TMPOUT="$RC"
  51. (cd $WORKAREA; $MDLINE) > $TMPOUT 2> $TMPERR || EXITCODE=1
  52. grep -v '^warning.*unable to open db' $TMPERR || true
  53. grep '^ERROR' $TMPOUT || true
  54. if [ $EXITCODE = 1 ]; then exit $EXITCODE; fi
  55. mv ~/$RENAMEDB.new ~/$RENAMEDB
  56. atexit_rm ~/$RENAMEDB.mtime.new
  57. atexit_rm ~/$RENAMEDB
  58. CHILDSARGS="$ORIG_CHILDARGS --dump-stdin ~/$RENAMEDB"
  59. cat ~/$RENAMEDB | run_remote_server
  60. ($MITM $CtS > $LtS) < $CtL &
  61. LOGGER1=$!
  62. atexit_kill $LOGGER1
  63. ($MITM $StC > $LtC) < $StL &
  64. LOGGER2=$!
  65. atexit_kill $LOGGER2
  66. ($PROGRESS_REPORTER $CL) < $PRp &
  67. REPORTER=$!
  68. atexit_kill $REPORTER
  69. CHILDSARGS="$ORIG_CHILDARGS --rename-only --override-db ~/$RENAMEDB"
  70. (run_local_client < $LtC 2> $PRp) > $CtL &
  71. CLIENT=$!
  72. atexit_kill $CLIENT
  73. CHILDSARGS="$ORIG_CHILDARGS --no-move --stop-after-diff --override-db ~/$RENAMEDB"
  74. (run_remote_server < $LtS 2> $SL) > $StL || EXITCODE=1
  75. wait $CLIENT || EXITCODE=1
  76. wait $REPORTER || EXITCODE=1
  77. report $EXITCODE 0 smd-push smd-pull smd-server smd-client
  78. exit $EXITCODE