]> git.donarmstrong.com Git - dsa-puppet.git/blobdiff - modules/roles/files/static-mirroring/staticsync-ssh-wrap
Add -x to allowed rsync parameteres due to jessie
[dsa-puppet.git] / modules / roles / files / static-mirroring / staticsync-ssh-wrap
index 2cb8c317928a0089c1e0e7fdb513118bf8417915..ba880881f1fd874294a657c3f39dbd8a68f7b3b0 100755 (executable)
@@ -25,7 +25,7 @@ set -e
 set -u
 
 MYLOGNAME="`basename "$0"`[$$]"
-BASEDIR="/home/staticsync/static-master"
+BASEDIR="/srv/static.debian.org"
 COMPONENTLIST=/etc/static-components.conf
 
 usage() {
@@ -59,7 +59,7 @@ do_mirror() {
        one_more_arg "$@"
        local serial="$1"; shift
 
-       masterhost="$(awk -v component="$component" '$2 == component {print $1; exit}' "$COMPONENTLIST")"
+       masterhost="$(awk -v component="$component" '!/^ *(#|$)/ && $2 == component {print $1; exit}' "$COMPONENTLIST")"
        if [ -z "$masterhost" ]; then
                croak "Did not find master for component $component."
        elif [ "$masterhost" != "$remote_host" ]; then
@@ -74,25 +74,31 @@ do_mirror() {
 
 do_rsync_on_master() {
        local remote_host="$1"; shift
-       local args="--server --sender -vlHtrze.iLsf --safe-links ."
+       local allowed_rsyncs
+       allowed_rsyncs=()
+       allowed_rsyncs+=("--server --sender -vlHtrze.iLsf --safe-links .") # wheezy
+       allowed_rsyncs+=("--server --sender -vlHtrze.iLsfx --safe-links .") # jessie
 
-       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/master/$component-current-push"
-                       info "serving $remote_host with $path"
-                       exec rsync $args "$path/."
-                       croak "Exec failed"
-               elif [ "$*" = "$args $component/-live-/" ] || [ "$*" = "$args ./$component/-live-/" ] ; then
-                       local path="$BASEDIR/master/$component-current-live"
-                       info "host $remote_host wants $path, acquiring lock"
-                       exec 200< "$path"
-                       if ! flock -s -w 0 200; then
-                       echo >&2 "Cannot acquire shared lock on $path - this should mean an update is already underway anyway."
-                       exit 1
+       for cmd_idx in ${!allowed_rsyncs[*]}; do
+               args="${allowed_rsyncs[$cmd_idx]}"
+               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/master/$component-current-push"
+                               info "serving $remote_host with $path"
+                               exec rsync $args "$path/."
+                               croak "Exec failed"
+                       elif [ "$*" = "$args $component/-live-/" ] || [ "$*" = "$args ./$component/-live-/" ] ; then
+                               local path="$BASEDIR/master/$component-current-live"
+                               info "host $remote_host wants $path, acquiring lock"
+                               exec 200< "$path"
+                               if ! flock -s -w 0 200; then
+                               echo >&2 "Cannot acquire shared lock on $path - this should mean an update is already underway anyway."
+                               exit 1
+                               fi
+                               exec rsync $args "$path/."
+                               croak "Exec failed"
                        fi
-                       exec rsync $args "$path/."
-                       croak "Exec failed"
-               fi
+               done
        done
 }
 
@@ -104,8 +110,9 @@ do_rsync_on_source() {
        allowed_rsyncs=()
 
        if [ -e "$COMPONENTLIST" ]; then
-               for path in $(awk -v host="$(hostname -f)" '$3 == host {print $4}' $COMPONENTLIST); do
-                       allowed_rsyncs+=("--server --sender -lHtrze.iLsf --safe-links . $path/.")
+               for path in $(awk -v host="$(hostname -f)" '!/^ *(#|$)/ && $3 == host {print $4}' $COMPONENTLIST); do
+                       allowed_rsyncs+=("--server --sender -lHtrze.iLsf --safe-links . $path/.") # wheezy
+                       allowed_rsyncs+=("--server --sender -lHtrze.iLsfx --safe-links . $path/.") # jessie
                done
        fi
        for cmd_idx in ${!allowed_rsyncs[*]}; do
@@ -136,7 +143,7 @@ do_update_component() {
 
        hit="$(
                awk -v this_host="$(hostname -f)" -v component="$component" -v host="$remote_host" '
-                       $1 == this_host && $2 == component {
+                       !/^ *(#|$)/ && $1 == this_host && $2 == component {
                                if ($3 == host) {
                                        print $4
                                        exit