41 lines
900 B
Bash
Executable file
41 lines
900 B
Bash
Executable file
#!/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"
|
|
extra_options=""
|
|
|
|
. /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 \
|
|
$extra_options \
|
|
"$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
|