X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=modules%2Froles%2Ffiles%2Fstatic-mirroring%2Fstatic-master-ssh-wrap;h=8387560b0f38863e976d800f9b2d0643179763e5;hb=23b3472027a552a8d691d19cdfb60a521f027955;hp=6041a567b31441e314a202e965d0aa5d8d70efa5;hpb=59b7870d664545dcb4a065d17da669805ecc9458;p=mirror%2Fdsa-puppet.git diff --git a/modules/roles/files/static-mirroring/static-master-ssh-wrap b/modules/roles/files/static-mirroring/static-master-ssh-wrap index 6041a567b..8387560b0 100755 --- a/modules/roles/files/static-mirroring/static-master-ssh-wrap +++ b/modules/roles/files/static-mirroring/static-master-ssh-wrap @@ -72,22 +72,26 @@ lock() { do_rsync() { local remote_host="$1"; shift - - local args="--server --sender -vltrze.iLsf --safe-links ." - if [ "$*" = "$args -new-/" ] || [ "$*" = "$args ./-new-/" ] ; then - local path="$BASEDIR/current-push" - info "serving $remote_host with $path" - rsync $args "$path/." - elif [ "$*" = "$args . -live-/" ] || [ "$*" = "$args . ./-live-/" ] ; then - local path="$BASEDIR/current-live" - info "host $remote_host wants $path, acquiring lock" - lock 200 "$path" 0 - rsync $args "$path/." - else - info "NOT allowed for $remote_host: rsync $*" - echo >&2 "This rsync command ($@) not allowed." - exit 1 - fi + local args="--server --sender -vlHtrze.iLsf --safe-links ." + + for component in $(awk -v this_host="$(hostname -f)" '$1 == this_host {print $2}' $COMPONENTLIST); do + if [ "$*" = "$args $component/-new-/" ] || [ "$*" = "$args ./$component/-new-/" ] ; then + local path="$BASEDIR/$component-current-push" + info "serving $remote_host with $path" + rsync $args "$path/." + return + elif [ "$*" = "$args . $component/-live-/" ] || [ "$*" = "$args . ./$component/-live-/" ] ; then + local path="$BASEDIR/$component-current-live" + info "host $remote_host wants $path, acquiring lock" + lock 200 "$path" 0 + rsync $args "$path/." + return + fi + done + + info "NOT allowed for $remote_host: rsync $*" + echo >&2 "This rsync command ($@) not allowed." + exit 1 } do_update_component() { @@ -97,7 +101,23 @@ do_update_component() { component="$1" shift - hit="$(awk -v component="$component" -v host="$remote_host" '$1 == component && $2 == host {print $3; exit}' "$COMPONENTLIST")" + hit="$( + awk -v this_host="$(hostname -f)" component="$component" -v host="$remote_host" ' + $1 == this_host && $2 == component { + if ($3 == host) { + print $4 + exit + } + split($5,extra,",") + for (i in extra) { + if (host == extra[i]) { + printf "%s:%s\n", $3, $4 + exit + } + } + exit + }' "$COMPONENTLIST" + )" if [ -n "$hit" ]; then exec static-master-update-component "$component" echo >&2 "Exec failed"