summaryrefslogtreecommitdiffstats
path: root/alpine-mirror.sh
blob: 2050c8820b312824b83d4db7aaf4f1a8375fd5e3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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