From 8132d6d3af28cabda8f987a72c18187fa8026cc1 Mon Sep 17 00:00:00 2001 From: Seth Vidal Date: Wed, 5 Jun 2013 21:57:42 +0000 Subject: [PATCH] add syncFiles.sh to common-scripts --- files/common-scripts/syncFiles.sh | 48 +++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100755 files/common-scripts/syncFiles.sh diff --git a/files/common-scripts/syncFiles.sh b/files/common-scripts/syncFiles.sh new file mode 100755 index 0000000000..1f5a832999 --- /dev/null +++ b/files/common-scripts/syncFiles.sh @@ -0,0 +1,48 @@ +#!/bin/bash +# this script lets us sync files off of lockbox via rsync with locking and relatively niceness +# look in rsyncd.conf on lockbox for what's available here + +set +e + +HOST=lockbox01.vpn.fedoraproject.org + +function cleanlock() +{ + /bin/rm -f /var/lock/$1.lock +} + + +function quit() +{ + echo $1 + if [ $2 ] + then + cleanlock $2 + fi + exit 2 +} + +function newlock() +{ + if [ -f /var/lock/$1.lock ] + then + quit "Lockfile exists.. Remove /var/lock/$1.lock" + else + touch /var/lock/$1.lock + fi +} + +# General help +if [ $3 ] || [ ! $2 ] +then + quit "$0 source dest" +fi + +newlock $1 +if [ ! -d $2 ] +then + mkdir $2 +fi +/usr/bin/rsync -a $HOST::$1/* $2 +cleanlock $1 +