Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- tandberg@rusc01-devserver1-a:~$ cat /home/tandberg/bin/devserver1-sync-nfstool
- #!/bin/sh
- #
- # this script is started from /etc/init.d/devserver-rsync on rusc01-devserver1-a & rusc01-devserver1-b
- # via the HA mechanisim
- #
- EXPECTED_HOST_PATTERN=devserver1
- TARGET_DIR=/srv/export/tandberg/system/
- SOURCE_SERVER=nfstool
- #
- # Run the rsync command along with date & time logging
- # S1 - The source rsync server to connect to e.g. nfstool
- # $2 - The distination directory to sync to e.g. /srv/export/tandberg/system
- #
- run_rsync() {
- if [ -d "/srv" ]; then
- # /srv exists, we must be the active peer so lets rsync
- echo ==========
- date
- echo rsyncing $1 into $2
- echo ----------
- /usr/bin/rsync --timeout=30 -rlptDPv $1 $2
- echo ==========
- echo
- fi
- }
- #
- # can only run on a devserver1 box
- #
- if ! hostname | grep -q $EXPECTED_HOST_PATTERN; then
- echo "$0: must be run on a $EXPECTED_HOST_PATTERN box"
- exit 1
- fi
- #
- # run serially for now
- #
- LASTSYNCDAY=$(date +%d)
- while true; do
- run_rsync rsync://$SOURCE_SERVER/tandberg-system/thirdparty $TARGET_DIR
- run_rsync rsync://$SOURCE_SERVER/tandberg-system/releases $TARGET_DIR
- run_rsync rsync://$SOURCE_SERVER/tandberg-system/bin $TARGET_DIR
- run_rsync rsync://$SOURCE_SERVER/swtools /srv/export/net/swtools
- # We only run the toolchain sync during the night between midnight & 3am as it takes a while
- # and toolchains don't change that often
- if [ "$(date +%d)" != "${LASTSYNCDAY}" ]; then
- run_rsync rsync://$SOURCE_SERVER/tandberg-system/toolchain $TARGET_DIR
- LASTSYNCDAY=$(date +%d)
- fi
- echo
- echo sleeping for 60 seconds ...
- echo
- sleep 60
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement