% Miroir APT pour Debian
#!/bin/bash
# source https://www.tobanet.de/s/2017/11/create-your-own-debian-mirror-with-debmirror/
# https://doc.lesmorin.fr/index.php/Debmirror
#HOST=ftp.fr.debian.org;
#HOST=debian.univ-tlse2.fr
HOST=deb.debian.org
#METHOD=rsync
#METHOD=http
METHOD=ftp
# destination directory
DEST=/srv/data/debian
# Debian version(s) to mirror
DIST=bookworm
# architecture
ARCH=amd64
MIRROR_USER=miroir
# log timestamp
logger -t mirror[$$] "updating Debian mirror"
su ${MIRROR_USER} -c \
"debmirror \
--nosource \
--method=${METHOD} \
--host=${HOST} \
--root=debian/ \
--dist=${DIST} \
--section=main,contrib,non-free,main/debian-installer \
--i18n \
--arch=${ARCH} \
--passive --postcleanup \
--getcontents --keyring /usr/share/keyrings/debian-archive-keyring.gpg \
-v \
${DEST} \
"
logger -t mirror[$$] "finished updating Debian mirror"
$ cat /etc/nginx/sites-available/debianmiroir
server {
listen 80 default_server;
server_name _;
access_log /var/log/nginx/mirror.access.log;
error_log /var/log/nginx/mirror.error.log;
server_name_in_redirect off;
autoindex off;
server_tokens off;
root /var/www/html;
location /debian {
alias /srv/data/debian;
fancyindex on;
fancyindex_exact_size off;
fancyindex_header /head.html;
fancyindex_footer /foot.html;
}
location /debian-security {
alias /srv/data/debian-security;
fancyindex on;
fancyindex_exact_size off;
fancyindex_header /head.html;
fancyindex_footer /foot.html;
}
error_page 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 421 422 423 424 425 426 428 429 431 451 500 501 502 503 504 505 506 507 508 510 511 /error.html;
location /error.html {
root /var/www/html;
internal;
}
}