#!/usr/bin/bash set -e # This CGI script is a caching Arch Linux mirror proxy: it forwards new package # requests to an actual mirror while caching contents to /var/cache/pacman/pkg. # Use in pacman.conf with: # # Server = https://server/path/to/proxy.cgi/$repo/os/$arch/ [[ $REMOTE_ADDR = 127.0.0.1 ]] cd /var/cache/pacman/pkg touch used-by-proxy MIR=$(awk -F '[$=]' '(!/^#/){print$2;exit}' /etc/pacman.d/mirrorlist) MIR=${MIR# } MIR=${MIR%/} PKG=${PATH_INFO##*/} if [[ $PATH_INFO = /vesath/* ]]; then MIR='https://arch.vesath.org/' PATH_INFO=${PATH_INFO#/vesath/os/} fi [[ $PKG = *.db* ]] && exec curl --silent --include "$MIR$PATH_INFO" cat <