afegit setup-network

This commit is contained in:
2026-03-16 09:56:32 +01:00
parent b705ad1b63
commit 773fb30ee6
7 changed files with 337 additions and 0 deletions
+60
View File
@@ -0,0 +1,60 @@
# retro-alcoi
Tools for configuring PCs at a retro gaming fair.
## Utilities
### setup-network
Assigns a static IP address and hostname to a Debian 13 machine based on a
machine number (1254). Designed for an isolated local network with no gateway
or DNS required.
```
sudo ./setup-network <machine_num>
```
Example:
```
sudo ./setup-network 4
# → IP: 10.0.1.4/24, hostname: retro-alcoi-4
```
See [`setup-network/`](setup-network/) for source and build instructions.
#### Quick start
```bash
cd setup-network/
python3 -m venv .venv
.venv/bin/pip install -r requirements.txt
bash build.sh
# Binary is at dist/setup-network
```
Copy `dist/setup-network` and `dist/config.ini` to a USB stick, then on each
fair PC:
```bash
sudo ./setup-network 4
```
#### Configuration
Edit `config.ini` (alongside the binary) before distributing:
```ini
[network]
subnet_root = 10.0.1
hostname_prefix = retro-alcoi-
```
#### How it works
1. Detects the first wired Ethernet interface (skips WiFi, bridges, veth).
2. Sets the hostname via `hostnamectl` and updates `/etc/hosts`.
3. Configures the static IP via `nmcli` if available, otherwise falls back to
`/etc/network/interfaces`.
Re-running with the same or a different machine number is safe (idempotent).