diff options
-rw-r--r-- | alpine-mirror.sh | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/alpine-mirror.sh b/alpine-mirror.sh new file mode 100644 index 0000000..2050c88 --- /dev/null +++ b/alpine-mirror.sh @@ -0,0 +1,54 @@ +#!/bin/sh +# This simple script is setting up a Alpine Linux installation in a chroot. +# chroot will be placed in the current working directory. +# +# This script can be used to setup a Alpine Linux mirror. +# http://wiki.alpinelinux.org/wiki/How_to_setup_a_Alpine_Linux_mirror +# +# Licensed under GPLv2 +# +# Copyright (c) 2011 Fabian Affolter <fabian at affolter-engineering.ch> + + +LATEST_RELEASE=2.3 +MAJOR=${LATEST_RELEASE%.*} +MINOR=${LATEST_RELEASE#*.} +FILE=excl-al.txt +SRC=rsync://rsync.alpinelinux.org/alpine/ +DEST=/data01/mirror/alpine/ + +## Delete the old exclusion file +rm $FILEmkdir -p $DEST + +## 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 "$@" + +## Exclude the v1.x releases +for ((i=1; i<=10; i++)); do + echo v1.$i/ >> $FILE +done +## Exclude all former releases +for ((i=0; i<=$MINOR-1; i++)); do + echo v$MAJOR.$i/ >> $FILE +done +## Exclude folders inside the current release tree +for i in releases/ main/x86/ testing/x86/ ; do + echo v$MAJOR.$MINOR/$i >> $FILE +done +## Exclude folders inside the current release tree +for i in releases/ main/x86/ testing/x86/ ; do + echo edge/$i >> $FILE +done + +## Syncing content +/usr/bin/rsync \ +--archive \ +--verbose \ +--stats \ +--partial \ +--progress \ +--exclude-from=$FILE \ +$SRC \ +$DEST |