Skip to content

Instantly share code, notes, and snippets.

@thomasdullien
Created June 19, 2020 15:33
Show Gist options
  • Save thomasdullien/61f78b190c86da8680103a307e5c6b92 to your computer and use it in GitHub Desktop.
Save thomasdullien/61f78b190c86da8680103a307e5c6b92 to your computer and use it in GitHub Desktop.
A small shell script to mirror upstream package repositories
DIRECTORIES="main contrib non-free restricted universe multiverse"
UBUNTU="http://mirror.hetzner.de/ubuntu/packages/pool/ http://ddebs.ubuntu.com/pool/";
DEBIAN="http://mirror.hetzner.de/debian/packages/pool/ http://debug.mirrors.debian.org/debian-debug/pool/"
if [[ $# -eq 0 ]]
then
echo "Choose 'all', 'debian', or 'ubuntu' as first argument."
exit 1
fi
SERVERS=""
if [ $1 = "all" ]
then
SERVERS="$UBUNTU $DEBIAN"
fi
if [ $1 = "ubuntu" ]
then
SERVERS="$UBUNTU"
fi
if [ $1 = "debian" ]
then
SERVERS="$DEBIAN"
fi
echo $SERVERS
# Download the packages in the pool
for directory in $DIRECTORIES; do
for server in $SERVERS; do
GREPSTR="$directory\/.+\/"
for i in $(wget -r -l1 --spider $server$directory/ 2>&1 | grep http | cut -d' ' -f4 | sort | uniq | egrep $GREPSTR ); do echo wget -np -mirror -A\"*amd64*\" $i; done
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment