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/."
}
lock() {
+ mkdir -p "$BASEDIR"
exec 200< "$BASEDIR"
if ! flock -e 200; then
log "Cannot acquire 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"
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"
}
}
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 ? {