Skip to content
Snippets Groups Projects
Verified Commit 02b5f6db authored by Evangelos Foutras's avatar Evangelos Foutras :smiley_cat:
Browse files

Combine sync{archive,debug,riscv} into mirrorsync

These roles are very similar and can be merged into a single new role.

Note: The archive mirror is changed from a 4-hour sync to minutely for
conformity with the other two mirrors. In practice this doesn't matter
as it was already taking over 4 hours to finish and was starting again
right after its previous run.
parent fe07dc0c
No related branches found
No related tags found
No related merge requests found
Pipeline #31257 passed
#!/bin/bash
target="/srv/riscv"
lock="/var/lock/syncriscv.lck"
source_url='rsync://archriscv.felixc.at/archriscv'
lastupdate_url='https://archriscv.felixc.at/.status/lastupdate.txt'
[ ! -d "${target}" ] && mkdir -p "${target}"
exec 9>"${lock}"
flock -n 9 || exit
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/.status/lastupdate.txt" ]] && diff -b <(curl -Ls "$lastupdate_url") "$target/.status/lastupdate.txt" >/dev/null; then
exit 0
fi
rsync_cmd "${source_url}" "${target}"
[Unit]
Description=Synchronize RISC-V mirror
RequiresMountsFor=/srv/riscv
Wants=network-online.target
After=network-online.target
[Service]
Type=oneshot
ExecStart=/usr/local/bin/syncriscv
Nice=19
IOSchedulingClass=best-effort
IOSchedulingPriority=7
- name: Create ssl cert
include_role:
name: certificate
vars:
domains: ["{{ riscv_mirror_domain }}"]
challenge: "DNS-01"
- name: Install rsync
pacman: name=rsync state=present
- name: Install syncriscv script
copy: src=syncriscv dest=/usr/local/bin/syncriscv owner=root group=root mode=0755
- name: Install syncriscv units
copy: src={{ item }} dest=/etc/systemd/system/{{ item }} owner=root group=root mode=0644
with_items:
- syncriscv.timer
- syncriscv.service
- name: Start and enable syncriscv timer
systemd: name=syncriscv.timer enabled=yes state=started daemon_reload=yes
- name: Set up nginx
template: src=nginx.d.conf.j2 dest=/etc/nginx/nginx.d/riscv.conf owner=root group=root mode=0644
notify: Reload nginx
tags: ['nginx']
- name: Make nginx log dir
file: path=/var/log/nginx/{{ riscv_mirror_domain }} state=directory owner=root group=root mode=0755
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment