Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
# Main ansible notebook
- name: Configure mirrors infrastructure
hosts: all
become: true

roles:
- role: nginx
tags: [nginx]
- mirrors
# - role: maintenance
# tags: [maintenance]
# tags: [mirrors]
# - role: prometheus
# tags: [prometheus]
# - role: router
# tags: [router]
# - role: tor
# tags: [tor]

post_tasks:
- name: Display mirrors configuration status
ansible.builtin.debug:
msg: "Mirrors infrastructure has been successfully configured"

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[Unit]
Description=Sync Almalinux Mirror
After=network.target

[Service]
Type=simple
User=mirrors
Group=mirrors
ExecStart=/usr/bin/rsync -avSH --bwlimit=2048 --exclude='.~tmp~' --delete-delay --delay-updates rsync://rsync.repo.almalinux.org/almalinux/ /srv/almalinux/
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[Unit]
Description=Timer to sync Almalinux Mirror at random minutes each hour

[Timer]
OnCalendar=hourly
RandomizedDelaySec=3600
Persistent=true

[Install]
WantedBy=timers.target
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[Unit]
Description=Sync Arch Linux Mirror
After=network.target

[Service]
Type=simple
User=mirrors
Group=mirrors
ExecStart=/usr/local/bin/archlinux-syncrepo.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[Unit]
Description=Timer to sync Arch Linux Mirror at random minutes each hour

[Timer]
OnCalendar=hourly
RandomizedDelaySec=3600
Persistent=true

[Install]
WantedBy=timers.target
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
#!/bin/bash
#
########
#
# Copyright © 2014-2019 Florian Pritz <[email protected]>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>.
#
########
#
# This is a simple mirroring script. To save bandwidth it first checks a
# timestamp via HTTP and only runs rsync when the timestamp differs from the
# local copy. As of 2016, a single rsync run without changes transfers roughly
# 6MiB of data which adds up to roughly 250GiB of traffic per month when rsync
# is run every minute. Performing a simple check via HTTP first can thus save a
# lot of traffic.

# Directory where the repo is stored locally. Example: /srv/repo
target="/srv/archlinux"

# Lockfile path
lock="/var/lock/syncrepo.lck"

# If you want to limit the bandwidth used by rsync set this.
# Use 0 to disable the limit.
# The default unit is KiB (see man rsync /--bwlimit for more)
bwlimit=0

# The source URL of the mirror you want to sync from.
# If you are a tier 1 mirror use rsync.archlinux.org, for example like this:
# rsync://rsync.archlinux.org/ftp_tier1
# Otherwise chose a tier 1 mirror from this list and use its rsync URL:
# https://www.archlinux.org/mirrors/
source_url='rsync://mirrors.ocf.berkeley.edu/archlinux'

# An HTTP(S) URL pointing to the 'lastupdate' file on your chosen mirror.
# If you are a tier 1 mirror use: https://rsync.archlinux.org/lastupdate
# Otherwise use the HTTP(S) URL from your chosen mirror.
lastupdate_url='https://mirrors.ocf.berkeley.edu/archlinux/lastupdate'

#### END CONFIG

[ ! -d "${target}" ] && mkdir -p "${target}"

exec 9>"${lock}"
flock -n 9 || exit

# Cleanup any temporary files from old run that might remain.
# Note: You can skip this if you have rsync newer than 3.2.3
# not affected by https://github.com/WayneD/rsync/issues/192
find "${target}" -name '.~tmp~' -exec rm -r {} +

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+=(--quiet)
fi

if ((bwlimit>0)); then
cmd+=("--bwlimit=$bwlimit")
fi

"${cmd[@]}" "$@"
}


# if we are called without a tty (cronjob) only run when there are changes
if ! tty -s && [[ -f "$target/lastupdate" ]] && diff -b <(curl -Ls "$lastupdate_url") "$target/lastupdate" >/dev/null; then
# keep lastsync file in sync for statistics generated by the Arch Linux website
rsync_cmd "$source_url/lastsync" "$target/lastsync"
exit 0
fi

rsync_cmd \
--exclude='*.links.tar.gz*' \
--exclude='/other' \
--exclude='/sources' \
"${source_url}" \
"${target}"

#echo "Last sync was $(date -d @$(cat ${target}/lastsync))"
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[Unit]
Description=Sync Debian-cd Mirror
After=network.target

[Service]
Type=simple
User=mirrors
Group=mirrors
ExecStart=/usr/bin/rsync --bwlimit=2048 --times --links --hard-links --partial --block-size=8192 --delete --archive rsync://mirrors.ocf.berkeley.edu/debian-cd/ /srv/debian-cd/
WorkingDirectory=/home/mirrors
10 changes: 10 additions & 0 deletions mirrors/files/distros/Debian/ISO/confd/debian-cd-mirror-sync.timer
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[Unit]
Description=Timer to sync Debian-cd Mirror at random minutes each hour

[Timer]
OnCalendar=hourly
RandomizedDelaySec=3600
Persistent=true

[Install]
WantedBy=timers.target
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[Unit]
Description=Sync Debian Mirror
After=network.target

[Service]
Type=simple
User=mirrors
Group=mirrors
ExecStart=/home/mirrors/bin/debian-mirror-sync-check.sh
WorkingDirectory=/home/mirrors
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[Unit]
Description=Timer to sync Debian Mirror every 15 minutes

[Timer]
OnCalendar=*:0/15
Persistent=true

[Install]
WantedBy=timers.target
5 changes: 5 additions & 0 deletions mirrors/files/distros/Debian/repository/ftpsync/.jigdo-mirror
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
jigdoDir="/srv/debian-cd/current/jigdo"
imageDir="/srv/debian-cd/current/images"
tmpDir="/srv/debian-cd/current/images"
debianMirror="file:/srv/debian"
include='.'; exclude='-1\.'
Loading