Skip to content

Instantly share code, notes, and snippets.

@odyssey4me
Last active April 14, 2021 03:36
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save odyssey4me/a7cfb95a16a48a6c3c9b2314315e31cd to your computer and use it in GitHub Desktop.
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
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
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;
}
}
############# 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
#!/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