several fixes
authorPeter Palfrader <peter@palfrader.org>
Thu, 25 Apr 2013 12:48:24 +0000 (14:48 +0200)
committerPeter Palfrader <peter@palfrader.org>
Thu, 25 Apr 2013 12:48:24 +0000 (14:48 +0200)
modules/roles/files/static-mirroring/static-master-ssh-wrap
modules/roles/files/static-mirroring/static-mirror-run
modules/roles/files/static-mirroring/static-mirror-ssh-wrap
modules/roles/manifests/static_mirror.pp

index da16215..d66f282 100755 (executable)
@@ -76,12 +76,12 @@ do_rsync() {
 
        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"
+                 local path="$BASEDIR/master/$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"
+         elif [ "$*" = "$args $component/-live-/" ] || [ "$*" = "$args ./$component/-live-/" ] ; then
+                 local path="$BASEDIR/master/$component-current-live"
                  info "host $remote_host wants $path, acquiring lock"
                  lock 200 "$path" 0
                  rsync $args "$path/."
index 72f7aea..0f7bc14 100755 (executable)
@@ -106,6 +106,7 @@ log() {
 }
 
 lock() {
+       mkdir -p "$BASEDIR"
        exec 200< "$BASEDIR"
        if ! flock -e 200; then
                log "Cannot acquire lock."
@@ -125,12 +126,12 @@ lock
 if [ -e "${BASEDIR}${ACTIVE}" ] && [ "$(readlink "${BASEDIR}${ACTIVE}")" = "$ALPHA" ] ; then
        staging="$BRAVO"
        active="$ALPHA"
-elif [ -e "${BASEDIR}${ACTIVE}" ] && [ "$(readlink "${BASEDIR}${ACTIVE}")" = "$BRAVO" ] ; then
-       staging="$ALPHA"
-       active="$BRAVO"
-else
+elif [ -e "${BASEDIR}${ACTIVE}" ] && [ "$(readlink "${BASEDIR}${ACTIVE}")" != "$BRAVO" ] ; then
        echo >&5 "Invalid state of ${BASEDIR}${ACTIVE}."
        exit 1
+else
+       staging="$ALPHA"
+       active="$BRAVO"
 fi
 log "active is $active; staging is $staging"
 
index 4ee9bbd..a76c645 100755 (executable)
@@ -66,7 +66,7 @@ do_mirror() {
        local serial="$1"; shift
 
        info "Host $remote_host triggered a mirror run for $component, serial $serial"
-       exec /usr/local/bin/static-mirror-run "$basedir/$component" "$remote_host:$component/-new-" "$serial"
+       exec /usr/local/bin/static-mirror-run "$basedir/mirrors/$component" "$remote_host:$component/-new-" "$serial"
        echo >&2 "Exec failed"
        croak "exec failed"
 }
index 5c5622e..01e5336 100644 (file)
@@ -24,7 +24,7 @@ class roles::static_mirror {
        }
 
        file { '/etc/cron.d/puppet-static-mirror':
-                       content => "PATH=/usr/local/bin:/usr/bin:/bin\n@reboot staticsync sleep 60; for a in `awk '!/^ *(#|$)/ {printf \"%s:%s/-live-\\n\", $1, $2}' /etc/static-components.conf`; do static-mirror-run --one-stage /srv/static.debian.org \"$a\" > /dev/null; done\n",
+                       content => "PATH=/usr/local/bin:/usr/bin:/bin\n@reboot staticsync sleep 60; awk '!/^ *(#|$)/ {print \$1, \$2}' /etc/static-components.conf | while read master component; do static-mirror-run --one-stage /srv/static.debian.org/mirrors/\$component \"\$master:\$components/-live-\" > /dev/null; done\n",
        }
 
        $vhost_listen = $::hostname ? {