How to setup a Alpine Linux mirror
This document describes how to set up an Alpine Linux mirror and make it available via http and rsync.
- create the dir where we have the mirror
- set up a cron job to sync with master mirror every hour
- set up lighttpd for http access
- set up rsync so other mirrors can rsync from you
Make sure that you have enough disk space; each v3.x branch has around 20 GiB.
Setting up the cron job
Install rsync which will be used to sync from the master mirror.
Save the following file as /etc/periodic/hourly/alpine-mirror
#!/bin/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 src=rsync://rsync.alpinelinux.org/alpine/ dest=/var/www/localhost/htdocs/alpine/ # uncomment this to exclude old v2.x branches #exclude="--exclude v2.*" mkdir -p "$dest" /usr/bin/rsync -prua \ $exclude \ --delete \ --timeout=600 \ --delay-updates \ --delete-after \ "$src" "$dest"
Make it executable:
Now it will sync every hour. (given cron runs)
Setting up HTTP access via lighttpd
Install the lighttpd server
Enable dir listings by uncommenting the following line in /etc/lighttpd/lighttpd.conf:
dir-listing.activate = "enable"
Also set cache-control to force cache revalidate every 30 mins. Uncomment mod_setenv in /etc/lighttpd/lighttpd.conf:
Add also the following lines to /etc/lighttpd/lighttpd.conf:
setenv.add-response-header += ( "Cache-Control" => "must-revalidate" )
Start lighttpd and make it start at boot:
Setting up rsyncd
Add the following lines to /etc/rsyncd.conf:
[alpine] path = /var/www/localhost/htdocs/alpine comment = My Alpine Linux Mirror
Optionally set a bandwidth limit in /etc/conf.d/rsyncd. In this example we limit to 500Kbytes/s (approx 5Mbit/s)