APmanageur Wi-Fi V1.0
This commit is contained in:
1 parent
43ec72a72d
commit
204b9b1abb
7 files changed
+60
-16
No files matched your search
@@ -5,3 +5,4 @@ __pycache__/
|
|||||||
*.sqlite3
|
*.sqlite3
|
||||||
.DS_Store
|
.DS_Store
|
||||||
up.sh
|
up.sh
|
||||||
|
version.json
|
||||||
+2
-2
@@ -55,10 +55,10 @@ RUN chmod +x /entrypoint.sh && rm -f /var/www/html/index.html.orig \
|
|||||||
ENV AP_DB_FILE=/data/ap-dashboard.sqlite3 \
|
ENV AP_DB_FILE=/data/ap-dashboard.sqlite3 \
|
||||||
AP_CONNECTION_FILE=/data/connection \
|
AP_CONNECTION_FILE=/data/connection \
|
||||||
AP_UPTIME_FILE=/data/uptime \
|
AP_UPTIME_FILE=/data/uptime \
|
||||||
AP_BACKUP_DIR=/backups \
|
AP_BACKUP_DIR=/data/backups \
|
||||||
AP_DNS="1.1.1.1,9.9.9.9"
|
AP_DNS="1.1.1.1,9.9.9.9"
|
||||||
|
|
||||||
VOLUME ["/data", "/backups", "/etc/NetworkManager/system-connections", "/var/lib/NetworkManager"]
|
VOLUME ["/data"]
|
||||||
ENV AP_WEB_PORT=1001
|
ENV AP_WEB_PORT=1001
|
||||||
EXPOSE 1001
|
EXPOSE 1001
|
||||||
|
|
||||||
|
|||||||
@@ -319,8 +319,8 @@ def lease_entries():
|
|||||||
if is_bridge_mode(): return []
|
if is_bridge_mode(): return []
|
||||||
except Exception: pass
|
except Exception: pass
|
||||||
import glob
|
import glob
|
||||||
files = ['/var/lib/misc/dnsmasq.leases', '/var/lib/NetworkManager/dnsmasq.leases']
|
files = ['/var/lib/misc/dnsmasq.leases', '/var/lib/NetworkManager/dnsmasq.leases', '/data/nm-state/dnsmasq.leases']
|
||||||
files += sorted(glob.glob('/var/lib/NetworkManager/dnsmasq-*.leases'))
|
files += sorted(glob.glob('/var/lib/NetworkManager/dnsmasq-*.leases') + glob.glob('/data/nm-state/dnsmasq-*.leases'))
|
||||||
entries = []
|
entries = []
|
||||||
for path in files:
|
for path in files:
|
||||||
try:
|
try:
|
||||||
@@ -3043,7 +3043,7 @@ def clean_stale_router_leases():
|
|||||||
station_live_ips = {k: v for k, v in station_live_ips.items() if not v.startswith('10.42.')}
|
station_live_ips = {k: v for k, v in station_live_ips.items() if not v.startswith('10.42.')}
|
||||||
except Exception: pass
|
except Exception: pass
|
||||||
import glob
|
import glob
|
||||||
for lf in glob.glob('/var/lib/NetworkManager/dnsmasq*.leases') + ['/var/lib/misc/dnsmasq.leases']:
|
for lf in glob.glob('/var/lib/NetworkManager/dnsmasq*.leases') + glob.glob('/data/nm-state/dnsmasq*.leases') + ['/var/lib/misc/dnsmasq.leases']:
|
||||||
try: open(lf, 'w').close()
|
try: open(lf, 'w').close()
|
||||||
except OSError: pass
|
except OSError: pass
|
||||||
try:
|
try:
|
||||||
@@ -8398,7 +8398,7 @@ def inspect_backup_bytes(raw_bytes, filename=''):
|
|||||||
raise ValueError(f"Fichier de sauvegarde non reconnu (ni ZIP, ni SQLite, ni JSON) : {e}")
|
raise ValueError(f"Fichier de sauvegarde non reconnu (ni ZIP, ni SQLite, ni JSON) : {e}")
|
||||||
|
|
||||||
|
|
||||||
BACKUP_DIR = os.environ.get('AP_BACKUP_DIR', '/backups').strip() or '/backups'
|
BACKUP_DIR = os.environ.get('AP_BACKUP_DIR', '/data/backups').strip() or '/data/backups'
|
||||||
BACKUP_ALLOWED_EXTS = ('.zip', '.json', '.sqlite', '.sqlite3', '.db')
|
BACKUP_ALLOWED_EXTS = ('.zip', '.json', '.sqlite', '.sqlite3', '.db')
|
||||||
backup_lock = threading.Lock()
|
backup_lock = threading.Lock()
|
||||||
_last_backup_cron_minute = None
|
_last_backup_cron_minute = None
|
||||||
|
|||||||
+3
-5
@@ -27,18 +27,16 @@ services:
|
|||||||
AP_BRIDGE_NAME: "br0"
|
AP_BRIDGE_NAME: "br0"
|
||||||
# Limite du nombre de connexions Wi-Fi simultanées (laisser vide ou 0 = illimité, ex. "10")
|
# Limite du nombre de connexions Wi-Fi simultanées (laisser vide ou 0 = illimité, ex. "10")
|
||||||
AP_MAX_CLIENTS: "0"
|
AP_MAX_CLIENTS: "0"
|
||||||
# Dossier interne des sauvegardes automatiques et manuelles (monté ci-dessous dans volumes)
|
# Dossier interne des sauvegardes automatiques et manuelles (enregistrées dans le volume /data/backups)
|
||||||
AP_BACKUP_DIR: "/backups"
|
AP_BACKUP_DIR: "/data/backups"
|
||||||
# Serveurs DNS fournis aux clients Wi-Fi :
|
# Serveurs DNS fournis aux clients Wi-Fi :
|
||||||
# - En mode "ap" (NAT) : distribués directement aux clients via DHCP (Option 6)
|
# - En mode "ap" (NAT) : distribués directement aux clients via DHCP (Option 6)
|
||||||
# - En mode "bridge" (Pont) : redirige automatiquement et de manière transparente toutes les requêtes DNS des clients Wi-Fi vers ces serveurs
|
# - En mode "bridge" (Pont) : redirige automatiquement et de manière transparente toutes les requêtes DNS des clients Wi-Fi vers ces serveurs
|
||||||
# Exemples : "1.1.1.1,9.9.9.9", "8.8.8.8,8.8.4.4", ou l'IP locale d'un Pi-hole / AdGuard Home ("192.168.1.50")
|
# Exemples : "1.1.1.1,9.9.9.9", "8.8.8.8,8.8.4.4", ou l'IP locale d'un Pi-hole / AdGuard Home ("192.168.1.50")
|
||||||
AP_DNS: "1.1.1.1,9.9.9.9"
|
AP_DNS: "1.1.1.1,9.9.9.9"
|
||||||
volumes:
|
volumes:
|
||||||
|
# Volume unique de données persistantes (regroupe la base sqlite, les sauvegardes, les connexions et l'état NetworkManager)
|
||||||
- /path/to/APmanageur/data:/data
|
- /path/to/APmanageur/data:/data
|
||||||
- /path/to/APmanageur/backups:/backups # Dossier des sauvegardes automatiques (Cron) et manuelles
|
|
||||||
- /path/to/APmanageur/nm-connections:/etc/NetworkManager/system-connections
|
|
||||||
- /path/to/APmanageur/nm-state:/var/lib/NetworkManager
|
|
||||||
- /etc/localtime:/etc/localtime:ro # Synchronise l'horloge avec l'hôte
|
- /etc/localtime:/etc/localtime:ro # Synchronise l'horloge avec l'hôte
|
||||||
- /lib/modules:/lib/modules:ro # Permet à modprobe d'accéder aux modules du noyau hôte
|
- /lib/modules:/lib/modules:ro # Permet à modprobe d'accéder aux modules du noyau hôte
|
||||||
- /run/udev:/run/udev:ro # NetworkManager reconnaît ainsi la carte USB
|
- /run/udev:/run/udev:ro # NetworkManager reconnaît ainsi la carte USB
|
||||||
|
|||||||
+47
-2
@@ -60,8 +60,51 @@ export AP_INTERFACE="$IFACE"
|
|||||||
log "Interface Wi-Fi sélectionnée : $IFACE"
|
log "Interface Wi-Fi sélectionnée : $IFACE"
|
||||||
log "Configuration pont (si mode pont activé dans l'interface) : pont=$AP_BRIDGE_NAME, eth=${AP_BRIDGE_ETH:-auto}"
|
log "Configuration pont (si mode pont activé dans l'interface) : pont=$AP_BRIDGE_NAME, eth=${AP_BRIDGE_ETH:-auto}"
|
||||||
|
|
||||||
# 2. NetworkManager : gère UNIQUEMENT l'interface Wi-Fi (l'interface Ethernet hôte ne doit JAMAIS être gérée par NM dans le conteneur)
|
# 2. Volume unique de données persistantes (/data)
|
||||||
mkdir -p /etc/NetworkManager/conf.d /run/dbus /run/NetworkManager /var/run/apache2 /var/lock/apache2 /var/log/apache2 /data "${AP_BACKUP_DIR:-/backups}" /etc/wireguard /etc/openvpn /run/ap-vpn /dev/net
|
# Regroupe dans /data : ap-dashboard.sqlite3, connection, uptime, backups/, nm-connections/ et nm-state/
|
||||||
|
AP_BACKUP_DIR="${AP_BACKUP_DIR:-/data/backups}"
|
||||||
|
export AP_BACKUP_DIR
|
||||||
|
mkdir -p /data/backups /data/nm-connections /data/nm-state
|
||||||
|
chmod 755 /data /data/backups /data/nm-state 2>/dev/null || true
|
||||||
|
chmod 700 /data/nm-connections 2>/dev/null || true
|
||||||
|
|
||||||
|
# Redirection de /backups vers /data/backups (si /backups n'est pas un volume monté séparément)
|
||||||
|
if ! mountpoint -q /backups 2>/dev/null; then
|
||||||
|
if [[ -d /backups && ! -L /backups ]]; then
|
||||||
|
cp -rn /backups/* /data/backups/ 2>/dev/null || true
|
||||||
|
rm -rf /backups 2>/dev/null || true
|
||||||
|
fi
|
||||||
|
ln -sfn /data/backups /backups 2>/dev/null || true
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Liaison persistante des connexions NetworkManager vers /data/nm-connections
|
||||||
|
mkdir -p /etc/NetworkManager/system-connections
|
||||||
|
if ! mountpoint -q /etc/NetworkManager/system-connections 2>/dev/null; then
|
||||||
|
if [[ -d /etc/NetworkManager/system-connections && ! -L /etc/NetworkManager/system-connections ]]; then
|
||||||
|
cp -rn /etc/NetworkManager/system-connections/* /data/nm-connections/ 2>/dev/null || true
|
||||||
|
fi
|
||||||
|
chmod 700 /data/nm-connections 2>/dev/null || true
|
||||||
|
if ! mount --bind /data/nm-connections /etc/NetworkManager/system-connections 2>/dev/null; then
|
||||||
|
rm -rf /etc/NetworkManager/system-connections 2>/dev/null || true
|
||||||
|
ln -sfn /data/nm-connections /etc/NetworkManager/system-connections 2>/dev/null || true
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Liaison persistante de l'état NetworkManager (baux DHCP, états) vers /data/nm-state
|
||||||
|
mkdir -p /var/lib/NetworkManager
|
||||||
|
if ! mountpoint -q /var/lib/NetworkManager 2>/dev/null; then
|
||||||
|
if [[ -d /var/lib/NetworkManager && ! -L /var/lib/NetworkManager ]]; then
|
||||||
|
cp -rn /var/lib/NetworkManager/* /data/nm-state/ 2>/dev/null || true
|
||||||
|
fi
|
||||||
|
chmod 755 /data/nm-state 2>/dev/null || true
|
||||||
|
if ! mount --bind /data/nm-state /var/lib/NetworkManager 2>/dev/null; then
|
||||||
|
rm -rf /var/lib/NetworkManager 2>/dev/null || true
|
||||||
|
ln -sfn /data/nm-state /var/lib/NetworkManager 2>/dev/null || true
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# NetworkManager : gère UNIQUEMENT l'interface Wi-Fi (l'interface Ethernet hôte ne doit JAMAIS être gérée par NM dans le conteneur)
|
||||||
|
mkdir -p /etc/NetworkManager/conf.d /run/dbus /run/NetworkManager /var/run/apache2 /var/lock/apache2 /var/log/apache2 /data "$AP_BACKUP_DIR" /etc/wireguard /etc/openvpn /run/ap-vpn /dev/net
|
||||||
chown -R www-data:www-data /var/run/apache2 /var/lock/apache2 /var/log/apache2 2>/dev/null || true
|
chown -R www-data:www-data /var/run/apache2 /var/lock/apache2 /var/log/apache2 2>/dev/null || true
|
||||||
if [[ ! -c /dev/net/tun ]]; then
|
if [[ ! -c /dev/net/tun ]]; then
|
||||||
mknod /dev/net/tun c 10 200 2>/dev/null || true
|
mknod /dev/net/tun c 10 200 2>/dev/null || true
|
||||||
@@ -386,6 +429,8 @@ cleanup() {
|
|||||||
"$_ipt" -t nat -X AP_NAT_POST 2>/dev/null || true
|
"$_ipt" -t nat -X AP_NAT_POST 2>/dev/null || true
|
||||||
done
|
done
|
||||||
kill "$WEB_PID" "$API_PID" "$NM_PID" 2>/dev/null || true
|
kill "$WEB_PID" "$API_PID" "$NM_PID" 2>/dev/null || true
|
||||||
|
mountpoint -q /etc/NetworkManager/system-connections && umount /etc/NetworkManager/system-connections 2>/dev/null || true
|
||||||
|
mountpoint -q /var/lib/NetworkManager && umount /var/lib/NetworkManager 2>/dev/null || true
|
||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
trap cleanup EXIT TERM INT
|
trap cleanup EXIT TERM INT
|
||||||
|
|||||||
+1
-1
@@ -5609,7 +5609,7 @@
|
|||||||
restaurez ou supprimez vos sauvegardes stockées dans le volume Docker.</p>
|
restaurez ou supprimez vos sauvegardes stockées dans le volume Docker.</p>
|
||||||
</div>
|
</div>
|
||||||
<span id="backupDirBadge" class="pill pill-blue pill-no-dot" style="font-size:12px;font-family:monospace">📁
|
<span id="backupDirBadge" class="pill pill-blue pill-no-dot" style="font-size:12px;font-family:monospace">📁
|
||||||
/backups</span>
|
/data/backups</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Actions rapides : Créer / Exporter / Importer -->
|
<!-- Actions rapides : Créer / Exporter / Importer -->
|
||||||
|
|||||||
+2
-2
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"version": "V5.5",
|
"version": "V5.5",
|
||||||
"commit": "ab03ed72111bda56a5227294bc4ba724cf628a14",
|
"commit": "43ec72a72d44155b28f93dcb60f392bc6e713a59",
|
||||||
"build_date": "2026-11-22T00:11:41Z"
|
"build_date": "2026-11-22T01:17:36Z"
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user