Skip to content

Commit ef66082

Browse files
author
Mattia Tadini
committed
Third mirror, at home, and the machines find it on their own
deb.skillfishos.com is live over HTTPS through the home Nginx Proxy Manager, serving a copy pushed from the release container. All three mirrors serve the identical Release, checked by hash rather than assumed. It goes last in the list on purpose: the upstream bandwidth of a home line does not carry normal traffic, but as a fallback it is worth as much as the others. The interesting part is that nobody has to be told about it. A machine that knew only the first two ran the weekly refresher, fetched the signed list from OVH, verified it against the archive key it already had, and rewrote its own list with three entries. Watched it happen on the Fujitsu rather than assuming it would. Addresses moved to the reserved range: 192.168.5.210 for releases and .211 for the mirror, with .210 to .220 kept for SkillFishOS. The DHCP pool ends at .40 so there is nothing to collide with. A change of address drags more behind it than it looks. All of these pointed at the old one and had to move with it: the two port-forward rules for the torrent port on the router, the from= restriction on the mirror's authorised key, the same restriction on the board's key for --dalla-scheda, the addresses written inside three scripts, and APT_HOST in the credentials file outside the repository, which is the one that bit — the publish failed on it twice. Two guards earned their keep along the way. The sync warned that the mirror had not received the copy and let the publish finish, because the other two already had everything; that was a missing host key, not a real outage. And the gh-pages sync refused to connect to an address whose host key it did not know, which is exactly what it should do — the key was registered only after comparing its fingerprint with the one already known for that machine.
1 parent 838b8d9 commit ef66082

4 files changed

Lines changed: 61 additions & 4 deletions

File tree

scripts/build-debs-ci.sh

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -377,11 +377,28 @@ put $P 0644 system/etc/apt/mirrors/skillfishos.list etc/apt/m
377377
put $P 0755 system/usr/local/bin/skillfish-aggiorna-mirror usr/local/bin/skillfish-aggiorna-mirror
378378
put $P 0644 system/usr/lib/systemd/system/skillfish-aggiorna-mirror.service usr/lib/systemd/system/skillfish-aggiorna-mirror.service
379379
put $P 0644 system/usr/lib/systemd/system/skillfish-aggiorna-mirror.timer usr/lib/systemd/system/skillfish-aggiorna-mirror.timer
380-
printf '#!/bin/sh\nset -e\n# Il timer che tiene aggiornato l elenco dei mirror. Con deb-systemd-invoke\n# perche% s rispetta la scelta di chi ha disabilitato i servizi.\nif [ "$1" = configure ] && command -v deb-systemd-invoke >/dev/null 2>&1; then\n systemctl daemon-reload >/dev/null 2>&1 || true\n deb-systemd-invoke enable --now skillfish-aggiorna-mirror.timer >/dev/null 2>&1 || true\nfi\nexit 0\n' '%s' > "$OUT/$P/DEBIAN/postinst"
381-
chmod 0755 "$OUT/$P/DEBIAN/postinst"
382380
ctrl $P "gnupg | gpgv" "SkillFishOS archive keyring and APT source" \
383381
"The signing key of our archive and the apt source that uses it. Without it apt
384382
cannot check where a SkillFishOS package came from."
383+
# ⚠️ DOPO ctrl, non prima: la cartella DEBIAN/ la crea ctrl, e scrivendoci
384+
# dentro una riga sopra la costruzione moriva con «No such file or directory».
385+
# Con un heredoc invece che con printf, cosi' non ci sono percentuali da
386+
# contare ne' barre da proteggere.
387+
cat > "$OUT/$P/DEBIAN/postinst" <<'POSTINST_KEYRING'
388+
#!/bin/sh
389+
set -e
390+
# Accende il timer che tiene aggiornato l'elenco dei mirror. Con
391+
# deb-systemd-invoke, che rispetta la scelta di chi i servizi li ha spenti
392+
# apposta: un pacchetto non riaccende quello che l'amministratore ha disattivato.
393+
if [ "$1" = configure ]; then
394+
systemctl daemon-reload >/dev/null 2>&1 || true
395+
if command -v deb-systemd-invoke >/dev/null 2>&1; then
396+
deb-systemd-invoke enable --now skillfish-aggiorna-mirror.timer >/dev/null 2>&1 || true
397+
fi
398+
fi
399+
exit 0
400+
POSTINST_KEYRING
401+
chmod 0755 "$OUT/$P/DEBIAN/postinst"
385402

386403
P=skillfish-base
387404
# La scheda AppStream: senza, la descrizione esiste solo in inglese,
@@ -1062,7 +1079,7 @@ rm -f /tmp/kr.$$ /tmp/krg.$$ /tmp/krf.$$
10621079
check skillfishos-archive-keyring_${VER}_all.deb ./etc/apt/sources.list.d/skillfishos.sources 'Signed-By: /usr/share/keyrings/skillfishos-archive-keyring.gpg'
10631080
# ⚠️ Se questi due non ci sono, la sorgente punta a un elenco che non
10641081
# viene spedito e la macchina resta senza archivio: si controlla.
1065-
check skillfishos-archive-keyring_${VER}_all.deb ./etc/apt/sources.list.d/skillfishos.sources 'URIs: mirror\+file:/etc/apt/mirrors/skillfishos.list'
1082+
check skillfishos-archive-keyring_${VER}_all.deb ./etc/apt/sources.list.d/skillfishos.sources 'URIs: mirror+file:/etc/apt/mirrors/skillfishos.list'
10661083
check skillfishos-archive-keyring_${VER}_all.deb ./etc/apt/mirrors/skillfishos.list 'https://skillfishos.com/apt'
10671084
deve_esserci "$OUT/skillfishos-archive-keyring/usr/local/bin/skillfish-aggiorna-mirror" "keyring: lo script che aggiorna i mirror"
10681085
check skillfishos-archive-keyring_${VER}_all.deb ./etc/apt/sources.list.d/skillfishos.sources 'Suites: aetherium'

scripts/pubblica-tutto.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
import time
2929
import urllib.request
3030

31-
CONTAINER = "192.168.5.103"
31+
CONTAINER = "192.168.5.210"
3232
IMPRONTA = "SHA256:+jpokXzLD6d6Stn/FPyuStdtZWOrcS3gS3XkpEWvqA4"
3333
PW = "47yk2d8r6c"
3434
QUI = os.path.dirname(os.path.abspath(__file__))
@@ -37,6 +37,7 @@
3737
MIRROR = [
3838
("OVH", "https://skillfishos.com/apt"),
3939
("GitHub Pages", "https://mtsistemi.github.io/SkillFishOS"),
40+
("casa", "https://deb.skillfishos.com"),
4041
]
4142

4243

system/etc/apt/mirrors/skillfishos.list

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,7 @@
2626

2727
https://skillfishos.com/apt
2828
https://mtsistemi.github.io/SkillFishOS
29+
# Il terzo, in casa: ci arriva una copia gia' firmata da Rilasci-SkillFishOS.
30+
# Ultimo di proposito: la banda in salita di una linea di casa non regge il
31+
# traffico normale, ma come riserva vale quanto gli altri.
32+
https://deb.skillfishos.com
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/bin/bash
2+
# Copia l'archivio gia' firmato sul terzo mirror (Mirror-SkillFishOS).
3+
#
4+
# ⚠️ SI SPINGE DA QUI, NON SI TIRA DA LA'. Un mirror che tira avrebbe bisogno di
5+
# una chiave capace di LEGGERE questa macchina, che e' quella che tiene la
6+
# chiave privata di firma. Meglio il contrario: una chiave qui che sul mirror sa
7+
# scrivere solo /srv/apt. Se il mirror finisse in mani sbagliate, di qui non si
8+
# porta via niente.
9+
#
10+
# ⚠️ conf/ e db/ RESTANO FUORI. Sono la configurazione e il database di
11+
# reprepro, cioe' gli arnesi con cui si indicizza e si firma. Sul mirror non
12+
# servono e non ci devono essere: il posto dove si firma e' uno solo.
13+
#
14+
# ⚠️ Un mirror che non risponde NON deve far fallire la pubblicazione. Gli altri
15+
# hanno gia' ricevuto tutto, e questo si riallinea al giro dopo. Esce comunque
16+
# 0, ma lo dice forte.
17+
set -u
18+
MIRROR="${1:-192.168.5.211}"
19+
CHIAVE=/root/.ssh/id_mirror
20+
21+
if [ ! -f "$CHIAVE" ]; then
22+
echo "manca $CHIAVE: il mirror non e' configurato, salto" >&2
23+
exit 0
24+
fi
25+
26+
if rsync -a --delete --exclude=conf --exclude=db \
27+
-e "ssh -i $CHIAVE -o BatchMode=yes -o ConnectTimeout=10 -o StrictHostKeyChecking=accept-new" \
28+
/srv/apt/ "root@$MIRROR:/"; then
29+
echo "mirror $MIRROR allineato"
30+
else
31+
echo "ATTENZIONE: il mirror $MIRROR non ha ricevuto la copia." >&2
32+
echo " Gli altri mirror sono a posto; questo resta indietro" >&2
33+
echo " e si riallinea alla prossima pubblicazione." >&2
34+
fi
35+
exit 0

0 commit comments

Comments
 (0)