#!/bin/sh

lockfile="/tmp/alpine-mirror.lock"
if [ -z "$flock" ] ; then
  exec env flock=1 flock -n $lockfile "$0" "$@"
fi

src=rsync://rsync.alpinelinux.org/alpine
dest=/var/www/si.tux.mirror/alpine

options="-rtlvuH --delete --delete-after --delete-excluded --prune-empty-dirs --delay-updates --timeout=300"

mkdir -p "$dest"
/usr/bin/rsync $options \
	--include '**/' \
	--include 'v3.18/*/x86_64/*' \
	--include 'v3.19/*/x86_64/*' \
	--include 'edge/*/x86_64/*' \
	--include 'MIRRORS.txt' \
	--include 'last-updated' \
	--exclude '*' \
	"$src" "$dest"


fstrim /var/www/si.tux.mirror/alpine
