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-check-conf 2.4KB

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. #set -x
  7. SSH="@SSH@"
  8. if [ `echo "$SSH" | cut -c -1` = "@" ]; then
  9. SSH=ssh
  10. echo "`basename $0` not installed, assuming secure shell client is $SSH"
  11. fi
  12. PREFIX="@PREFIX@"
  13. MDDIFF=$PREFIX/bin/mddiff
  14. if [ `echo "$PREFIX" | cut -c -1` = "@" ]; then
  15. MDDIFF=./mddiff
  16. SMDROOT=.
  17. echo "`basename $0` not installed, assuming mddiff is $MDDIFF"
  18. else
  19. SMDROOT=$PREFIX/share/syncmaildir
  20. fi
  21. . $SMDROOT/smd-common
  22. init
  23. parse_args "$@"
  24. read_conffile
  25. check_lockfile
  26. setup_plumbing
  27. setup_logging
  28. setup_mailboxnames
  29. if [ -z "$SERVERNAME" -o -z "$CLIENTNAME" ]; then
  30. echo "ERROR: SERVERNAME or CLIENTNAME not set"
  31. exit 1
  32. fi
  33. if [ ! -z "$MAILBOX" -a ! -z "$MAILBOX_LOCAL" -a "$MAILBOX" != "$MAILBOX_LOCAL" ]; then
  34. echo "ERROR: both MAILBOX and MAILBOX_LOCAL set"
  35. exit 1
  36. fi
  37. if [ ! -z "$MAILBOX" -a ! -z "$MAILBOX_REMOTE" -a "$MAILBOX" != "$MAILBOX_REMOTE" ]; then
  38. echo "ERROR: both MAILBOX and MAILBOX_REMOTE set"
  39. exit 1
  40. fi
  41. if [ -z "$TRANSLATOR_LR" -o -z "$TRANSLATOR_RL" ]; then
  42. echo ERROR: TRANSLATOR_LR and TRANSLATOR_RL not defined
  43. exit 1
  44. fi
  45. cd
  46. TL=`mktemp`
  47. TR=`mktemp`
  48. echo Local mailboxes translated to remote and back:
  49. $MDDIFF $LOCALEXCLUDE -l $MAILBOX_LOCAL > $TL
  50. if [ ! $? -eq 0 ]; then
  51. echo Error while listing the content of $MAILBOX_LOCAL, skipping
  52. else
  53. while read M; do
  54. MM="`echo "$M" | $TRANSLATOR_LR | head -n 1`"
  55. MMM="`echo "$MM" | $TRANSLATOR_RL | head -n 1`"
  56. echo " " $M "->" $MM "->" $MMM
  57. if [ "$M" != "$MMM" ]; then
  58. echo Failed round trip check: $M "->" $MMM
  59. echo " echo "$M" | $TRANSLATOR_LR -> $MM"
  60. echo " echo "$MM" | $TRANSLATOR_RL -> $MMM"
  61. exit 1
  62. fi
  63. done < $TL
  64. fi
  65. echo
  66. echo Remote mailboxes translated to local and back:
  67. $SSH $SERVERNAME $MDDIFF $REMOTEEXCLUDE -l $MAILBOX_REMOTE > $TR
  68. if [ ! $? -eq 0 ]; then
  69. echo Error while listing the content of $MAILBOX_REMOTE, skipping
  70. else
  71. while read M; do
  72. MM="`echo "$M" | $TRANSLATOR_RL | head -n 1`"
  73. MMM="`echo "$MM" | $TRANSLATOR_LR | head -n 1`"
  74. echo " " $M "->" $MM "->" $MMM
  75. if [ "$M" != "$MMM" ]; then
  76. echo Failed round trip check: $M "->" $MMM
  77. echo " echo $M | $TRANSLATOR_RL -> $MM"
  78. echo " echo $MM | $TRANSLATOR_LR -> $MMM"
  79. exit 1
  80. fi
  81. done < $TR
  82. fi
  83. rm $TL $TR
  84. echo "Endpoint $REPNAME configuration file successfully checked"
  85. exit 0
  86. # vim:ts=4: