Last active
July 9, 2021 09:26
-
-
Save PhirePhly/165b176c7ac1664dba7a7008487fb267 to your computer and use it in GitHub Desktop.
Mirroring script for Raspbian repos
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# | |
## Setting variables with explanations. | |
# Set root working directory for where you want to store your mirrors | |
MIRRORBASE=/home/kenneth/mirror | |
mkdir -p $MIRRORBASE | |
# | |
# Don't touch the user's keyring, have our own instead | |
# | |
export GNUPGHOME=$MIRRORBASE/keyring | |
mkdir -p $GNUPGHOME | |
wget -O $GNUPGHOME/raspberrypi.gpg.key http://archive.raspberrypi.org/debian/raspberrypi.gpg.key | |
gpg --no-default-keyring --keyring $GNUPGHOME/trustedkeys.gpg --import $GNUPGHOME/raspberrypi.gpg.key | |
# Arch= -a # Architecture. For Ubuntu can be i386, powerpc or amd64. | |
# sparc, only starts in dapper, it is only the later models of sparc. | |
# | |
arch=armhf | |
# Minimum Ubuntu system requires main, restricted | |
# Section= -s # Section (One of the following - main/restricted/universe/multiverse). | |
# You can add extra file with $Section/debian-installer. ex: main/debian-installer,universe/debian-installer,multiverse/debian-installer,restricted/debian-installer | |
# | |
section=main,ui | |
# Release= -d # Release of the system (...Hardy, Intrepid... Lucid, Precise, Quantal, Saucy, Trusty ), and the -updates and -security ( -backports can be added if desired) | |
# List of updated releases in: https://wiki.ubuntu.com/Releases | |
# | |
release=stretch | |
# Server= -h # Server name, minus the protocol and the path at the end | |
# CHANGE "*" to equal the mirror you want to create your mirror from. au. in Australia ca. in Canada. | |
# This can be found in your own /etc/apt/sources.list file, assuming you have Ubuntu installed. | |
# | |
server=archive.raspberrypi.org | |
# Dir= -r # Path from the main server, so http://my.web.server/$dir, Server dependant | |
# | |
inPath=/debian | |
# Proto= --method= # Protocol to use for transfer (http, ftp, hftp, rsync) | |
# Choose one - http is most usual the service, and the service must be available on the server you point at. | |
# | |
proto=http | |
# Outpath= # Directory to store the mirror in | |
# Make this a full path to where you want to mirror the material. | |
# | |
outPath=$MIRRORBASE/archive.raspberrypi.org/debian | |
# The --nosource option only downloads debs and not deb-src's | |
# The --progress option shows files as they are downloaded | |
# --source \ in the place of --no-source \ if you want sources also. | |
# --nocleanup Do not clean up the local mirror after mirroring is complete. Use this option to keep older repository | |
# Start script | |
# | |
debmirror -a $arch \ | |
--no-source \ | |
-s $section \ | |
-h $server \ | |
-d $release \ | |
-r $inPath \ | |
--progress \ | |
--method=$proto \ | |
$outPath | |
# Mirror the raspbian repo using rsync because it's supported and more complete | |
# | |
# THIS WILL TAKE A STUPID LONG TIME THE FIRST TIME YOU RUN IT | |
rsync --archive --delete --delete-delay --delay-updates -v archive.raspbian.org::archive $MIRRORBASE/archive.raspbian.org | |
echo | |
echo "Mirrors created; now symlink them to your http server's folder" |
debmirror: command not found
Have you tried to install it? apt install debmirror
--rsync-extra=none
is needed to completely disable rsync(or debmirror will connect to rsync port which is not supported by server)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I have 156 Raspberry Pi's I use for testing and I am trying to create a mirror locally so that I am not tying the network constantly with traffic for updating pi security. I am using your script to create this mirror but I keep getting errors that are outside the line count, for example, "./create_rasbian_mirror.sh: line 139: debmirror: command not found" I think I need more help in getting this working.