mirror of
https://gitlab.archlinux.org/archlinux/infrastructure.git
synced 2025-01-18 08:06:16 +01:00
This role will still handle setting up nginx and rsyncd, due to specific configuration requirements these services have. We're also effectively relieving build.archlinux.org of rsyncd duties as it is not something it should be doing anyway.
41 lines
1.1 KiB
Django/Jinja
Executable File
41 lines
1.1 KiB
Django/Jinja
Executable File
#!/bin/bash
|
|
|
|
target="{{ item.value.target }}"
|
|
lock="/run/lock/sync{{ item.key }}.lck"
|
|
source_url='{{ item.value.source }}'
|
|
lastupdate_url='{{ item.value.last_update_url }}'
|
|
|
|
[ ! -d "${target}" ] && mkdir -p "${target}"
|
|
|
|
exec 9>"${lock}"
|
|
flock -n 9 || exit
|
|
|
|
{% set delay_updates = '--delay-updates' if item.value.delay_updates | default(true) %}
|
|
rsync_cmd() {
|
|
local -a cmd=(rsync -rlptH --safe-links --delete-delay {{ delay_updates }}
|
|
"--timeout=600" "--contimeout=60" --no-motd)
|
|
|
|
if stty &>/dev/null; then
|
|
cmd+=(-h -v --progress)
|
|
else
|
|
cmd+=("--info=name1")
|
|
fi
|
|
|
|
"${cmd[@]}" "$@"
|
|
}
|
|
|
|
# if we are called without a tty (cronjob) only run when there are changes
|
|
if ! tty -s && [[ -f "$target/{{ item.value.last_update_dst }}" ]] && diff -b <(curl -Ls "$lastupdate_url") "$target/{{ item.value.last_update_dst }}" >/dev/null; then
|
|
{% if item.value.save_lastsync | default(false) %}
|
|
# keep lastsync file in sync for statistics generated by the Arch Linux website
|
|
rsync_cmd "$source_url/lastsync" "$target/lastsync"
|
|
{% endif %}
|
|
exit 0
|
|
fi
|
|
|
|
rsync_cmd \
|
|
{% for opt in item.value.rsync_options | default() %}
|
|
{{ opt }} \
|
|
{% endfor %}
|
|
"${source_url}" "${target}"
|