Last active
April 14, 2021 03:36
-
-
Save odyssey4me/a7cfb95a16a48a6c3c9b2314315e31cd to your computer and use it in GitHub Desktop.
Poor man's frozen apt mirror - it still needs work to do an auto clean based on files not referenced
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
apt-get update | |
apt-get purge -y nano | |
apt-get install -y vim tmux fail2ban nginx apt-mirror lxc | |
# change nginx config: | |
# /etc/nginx/sites-enabled/default | |
systemctl restart nginx | |
# change apt-mirror config: | |
# /etc/apt/mirror.list | |
# /var/spool/apt-mirror/var/postmirror.sh | |
su - apt-mirror -c apt-mirror | |
lxc-attach -n client1 | |
lxc-create -t download -n client1 -- --dist ubuntu --release xenial --arch amd64 | |
root@client1:/# cat /etc/apt/sources.list | |
deb http://archive.ubuntu.com/ubuntu xenial main universe | |
deb http://10.0.3.1/ubuntu xenial-updates-20170319 main universe |
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
server { | |
listen 80 default_server; | |
listen [::]:80 default_server; | |
root /var/www/html; | |
index index.html index.htm index.nginx-debian.html; | |
server_name _; | |
location / { | |
# First attempt to serve request as file, then | |
# as directory, then fall back to displaying a 404. | |
try_files $uri $uri/ =404; | |
} | |
gzip on; | |
location /ubuntu { | |
root /var/spool/apt-mirror/mirror/archive.ubuntu.com; | |
autoindex on; | |
allow 10.0.3.0/24; | |
allow 127.0.0.1/32; | |
deny all; | |
} | |
} |
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
############# config ################## | |
# | |
# set base_path /var/spool/apt-mirror | |
# | |
# set mirror_path $base_path/mirror | |
# set skel_path $base_path/skel | |
# set var_path $base_path/var | |
# set cleanscript $var_path/clean.sh | |
# set defaultarch <running host architecture> | |
# set postmirror_script $var_path/postmirror.sh | |
# set run_postmirror 0 | |
set nthreads 20 | |
set _tilde 0 | |
# | |
############# end config ############## | |
deb http://archive.ubuntu.com/ubuntu xenial-updates main universe | |
# NB: | |
# The poor man's frozen mirror *must not* use the clean script | |
# as it will invalidate older snapshots. | |
# TODO: | |
# Figure out a way to do the cleaning up of any files that are | |
# not present in any of the stored snapshots. | |
#clean http://archive.ubuntu.com/ubuntu |
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/sh -e | |
## Anything in this file gets run AFTER the mirror has been run. | |
## Put your custom post mirror operations in here (like rsyncing the installer | |
## files and running clean.sh automatically)! | |
rsync -a -delete --delete-after /var/spool/apt-mirror/mirror/archive.ubuntu.com/ubuntu/dists/xenial-updates/ /var/spool/apt-mirror/mirror/archive.ubuntu.com/ubuntu/dists/xenial-updates-$(date +%Y%m%d) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment