APmanageur Wi-Fi V1.0 : conteneur Debian + Apache

This commit is contained in:
yoann committed 2026-10-04 23:04:16 +02:00
1 parent 0dce2f61fe
commit 697d1d253c
3 files changed
+20 -16

No files matched your search

+1 -3
View File
@@ -3,7 +3,7 @@ FROM debian:13-slim
ENV DEBIAN_FRONTEND=noninteractive \
PYTHONUNBUFFERED=1
# Apache2 + NetworkManager embarqué (pour la carte Netgear) + outils Wi-Fi + Python
# Apache2 + NetworkManager embarqué + outils Wi-Fi + Python
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
apache2 python3 \
@@ -16,12 +16,10 @@ RUN apt-get update \
# Vos fichiers
WORKDIR /app
COPY ap.py /app/ap.py
COPY favicon.png /app/favicon.png
# Nom de votre fichier HTML dans le dossier de build (par défaut index.html)
ARG HTML_FILE=index.html
COPY ${HTML_FILE} /app/index.html
COPY ${HTML_FILE} /var/www/html/index.html
COPY favicon.png /var/www/html/favicon.png
COPY apache-ap.conf /etc/apache2/sites-available/000-default.conf
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh && rm -f /var/www/html/index.html.orig \
+7 -3
View File
@@ -1,6 +1,8 @@
# 1. Trouver l'interface de la carte Netgear : iw dev
# 1. Trouver l'interface de la carte Wi-Fi : iw dev
# 2. Lancer : AP_INTERFACE=wlan0 docker compose up -d --build
# 3. Ouvrir : http://IP-DE-LA-MACHINE:1001/
# 3. Injecter la carte Wi-Fi dans le conteneur (à refaire à chaque redémarrage du conteneur) :
# sudo ./attach-wifi.sh wlan0
# 4. Ouvrir : http://IP-DE-LA-MACHINE:1001/
#
# Si votre fichier HTML ne s'appelle pas index.html, ajoutez sous "build:"
# args:
@@ -11,7 +13,9 @@ services:
build: .
container_name: ap-wifi
restart: unless-stopped
network_mode: host # accès direct à la carte Wi-Fi de l'hôte
ports:
- "1001:1001" # interface web (Apache)
- "8080:8080" # API (le HTML l'appelle sur ce port)
privileged: true # NetworkManager interne : rfkill, NAT, sysctl
environment:
AP_INTERFACE: ${AP_INTERFACE:-}
+12 -10
View File
@@ -3,18 +3,20 @@ set -euo pipefail
log() { echo "[ap-wifi] $*"; }
# 1. Interface Wi-Fi (Netgear) --------------------------------------------------
# 1. Interface Wi-Fi --------------------------------------------------
IFACE="${AP_INTERFACE:-}"
mapfile -t FOUND < <(iw dev 2>/dev/null | awk '$1=="Interface"{print $2}')
if [[ -z "$IFACE" ]]; then
if [[ ${#FOUND[@]} -eq 1 ]]; then
IFACE="${FOUND[0]}"
else
log "ERREUR : précisez AP_INTERFACE. Interfaces Wi-Fi détectées : ${FOUND[*]:-aucune}"
exit 1
log "Attente de la carte Wi-Fi ${IFACE}"
FOUND=()
for _ in $(seq 1 180); do
mapfile -t FOUND < <(iw dev 2>/dev/null | awk '$1=="Interface"{print $2}')
if [[ -n "$IFACE" ]]; then
printf '%s\n' "${FOUND[@]:-}" | grep -qx "$IFACE" && break
elif [[ ${#FOUND[@]} -eq 1 ]]; then
IFACE="${FOUND[0]}"; break
fi
fi
iw dev "$IFACE" info >/dev/null 2>&1 || { log "ERREUR : interface '$IFACE' introuvable (détectées : ${FOUND[*]:-aucune})"; exit 1; }
sleep 1
done
[[ -n "$IFACE" ]] && iw dev "$IFACE" info >/dev/null 2>&1 || { log "ERREUR : interface '${IFACE:-?}' absente après 3 min (détectées : ${FOUND[*]:-aucune})"; exit 1; }
export AP_INTERFACE="$IFACE"
log "Interface utilisée : $IFACE"