Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2018
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.73 KB | None | 0 0
  1. tandberg@rusc01-devserver1-a:~$ cat /home/tandberg/bin/devserver1-sync-nfstool
  2. #!/bin/sh
  3.  
  4. #
  5. # this script is started from /etc/init.d/devserver-rsync on rusc01-devserver1-a & rusc01-devserver1-b
  6. # via the HA mechanisim
  7. #
  8.  
  9. EXPECTED_HOST_PATTERN=devserver1
  10. TARGET_DIR=/srv/export/tandberg/system/
  11. SOURCE_SERVER=nfstool
  12.  
  13. #
  14. # Run the rsync command along with date & time logging
  15. # S1 - The source rsync server to connect to e.g. nfstool
  16. # $2 - The distination directory to sync to e.g. /srv/export/tandberg/system
  17. #
  18. run_rsync() {
  19. if [ -d "/srv" ]; then
  20. # /srv exists, we must be the active peer so lets rsync
  21. echo ==========
  22. date
  23. echo rsyncing $1 into $2
  24. echo ----------
  25. /usr/bin/rsync --timeout=30 -rlptDPv $1 $2
  26. echo ==========
  27. echo
  28. fi
  29. }
  30.  
  31. #
  32. # can only run on a devserver1 box
  33. #
  34. if ! hostname | grep -q $EXPECTED_HOST_PATTERN; then
  35. echo "$0: must be run on a $EXPECTED_HOST_PATTERN box"
  36. exit 1
  37. fi
  38.  
  39. #
  40. # run serially for now
  41. #
  42. LASTSYNCDAY=$(date +%d)
  43.  
  44. while true; do
  45. run_rsync rsync://$SOURCE_SERVER/tandberg-system/thirdparty $TARGET_DIR
  46. run_rsync rsync://$SOURCE_SERVER/tandberg-system/releases $TARGET_DIR
  47. run_rsync rsync://$SOURCE_SERVER/tandberg-system/bin $TARGET_DIR
  48. run_rsync rsync://$SOURCE_SERVER/swtools /srv/export/net/swtools
  49. # We only run the toolchain sync during the night between midnight & 3am as it takes a while
  50. # and toolchains don't change that often
  51. if [ "$(date +%d)" != "${LASTSYNCDAY}" ]; then
  52. run_rsync rsync://$SOURCE_SERVER/tandberg-system/toolchain $TARGET_DIR
  53. LASTSYNCDAY=$(date +%d)
  54. fi
  55. echo
  56. echo sleeping for 60 seconds ...
  57. echo
  58. sleep 60
  59. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement