zektyc/scripts/upnp-watch.sh
riricdev 8e7ec41f18 chore: checkpoint initial — Zektyc dataset, avant humanisation
- site vitrine + fingerprint test + zmap + z-panel
- remplacement duckdns -> riricdev.tail5ea5cd.ts.net (canonical/og/alternates/docs)
- suppression du token DuckDNS (plus utilisé)
2026-09-06 13:03:25 +02:00

29 lines
829 B
Shell
Executable file

#!/bin/bash
UPNP_URL="http://192.168.1.254:5678/desc/root"
LOCAL_IP="192.168.1.50"
LOG_TAG="upnp-watch"
log() {
logger -t "$LOG_TAG" "$1"
echo "[$(date '+%Y-%m-%d %H:%M:%S')] $1"
}
MAPPINGS=$(upnpc -u "$UPNP_URL" -l 2>/dev/null)
if [ -z "$MAPPINGS" ]; then
log "ERREUR: passerelle UPnP injoignable"
exit 1
fi
for PORT in 80 443; do
if echo "$MAPPINGS" | grep -q "TCP.*${PORT}->${LOCAL_IP}:${PORT}"; then
log "OK: port ${PORT}/TCP déjà ouvert"
else
log "port ${PORT}/TCP absent -> ouverture"
RESULT=$(upnpc -u "$UPNP_URL" -a "$LOCAL_IP" "$PORT" "$PORT" TCP 2>&1 | tail -1)
if echo "$RESULT" | grep -q "is redirected"; then
log "port ${PORT}/TCP ouvert avec succès"
else
log "ECHEC ouverture ${PORT}/TCP: $RESULT"
fi
fi
done