2022-04-25 19:33:10 +00:00
|
|
|
#!/usr/bin/env sh
|
|
|
|
|
|
|
|
# make sure we never run 2 rsync at the same time
|
|
|
|
lockfile="/tmp/alpine-mirror.lock"
|
|
|
|
if [ -z "$flock" ] ; then
|
|
|
|
exec env flock=1 flock -n $lockfile "$0" "$@"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# default config
|
|
|
|
src=rsync://rsync.alpinelinux.org/alpine/
|
|
|
|
dest=/var/lib/mirror/
|
|
|
|
versions="edge"
|
|
|
|
arches="x86_64"
|
2022-05-15 10:36:25 +00:00
|
|
|
extra_options=""
|
2022-04-25 19:33:10 +00:00
|
|
|
|
|
|
|
. /etc/alpine-mirror.conf
|
|
|
|
|
|
|
|
mirror() {
|
|
|
|
mkdir -p "$dest$1"
|
|
|
|
echo "running rsync $1"
|
|
|
|
/usr/bin/rsync \
|
|
|
|
--archive \
|
|
|
|
--update \
|
|
|
|
--hard-links \
|
|
|
|
--delete \
|
|
|
|
--delete-after \
|
|
|
|
--delay-updates \
|
|
|
|
--timeout=600 \
|
2022-05-15 10:36:25 +00:00
|
|
|
$extra_options \
|
2022-04-25 19:33:10 +00:00
|
|
|
"$src$1" "$dest$1"
|
|
|
|
exitcode=$?
|
|
|
|
[ $exitcode == 0 ] || echo "rsync $1 failed with exit code: $exitcode"
|
|
|
|
}
|
|
|
|
|
|
|
|
for version in $versions; do
|
|
|
|
for arch in $arches; do
|
|
|
|
mirror "$version/main/$arch/"
|
|
|
|
mirror "$version/community/$arch/"
|
|
|
|
[ "$version" = edge ] && mirror "$version/testing/$arch/"
|
|
|
|
done
|
|
|
|
done
|