#!/bin/sh # Copyright (c) 2026 AirNomadNetwork. All rights reserved. # Licensed only for use with AirNomadNetwork. You may read it; don't copy, change or redistribute it. # Removes the AirNomadNetwork agent from this router: stops it, disconnects any nomads, deletes its firewall # rules, its settings and its files. Your WireGuard server and every other router setting are left as they are. # Run on the router as root: # airnomad-agent.sh uninstall (works offline; saved on the router at install) # curl -fsS https://airnomadnetwork.com/agent/uninstall.sh | sh (public fallback, if the agent is missing or broken) ROOT=${AIRNOMAD_ROOT:-} # tests only: work under another directory CONF=$ROOT/etc/airnomad-agent.conf BIN=$ROOT/usr/bin/airnomad-agent.sh INIT=$ROOT/etc/init.d/airnomad-agent UNINSTALL=$ROOT/usr/bin/airnomad-uninstall.sh [ -n "$ROOT" ] || [ "$(id -u)" = 0 ] || { echo "Run this on the router as root (ssh root@)."; exit 1; } IFACE=$(sed -n 's/^IFACE=//p' "$CONF" 2>/dev/null) IFACE=${IFACE:-wgserver} echo "Stopping the AirNomadNetwork agent..." if [ -x "$INIT" ]; then "$INIT" stop 2>/dev/null; "$INIT" disable 2>/dev/null; fi echo "Disconnecting nomads..." for key in $(wg show "$IFACE" peers 2>/dev/null); do wg set "$IFACE" peer "$key" remove; done echo "Removing firewall rules..." if command -v nft >/dev/null 2>&1; then nft delete table inet airnomad_iso 2>/dev/null nft delete table ip airnomad 2>/dev/null fi if command -v iptables >/dev/null 2>&1; then while iptables -D FORWARD -j airnomad_fwd 2>/dev/null; do :; done while iptables -D INPUT -j airnomad_in 2>/dev/null; do :; done for c in airnomad_fwd airnomad_in; do iptables -F "$c" 2>/dev/null; iptables -X "$c" 2>/dev/null; done while iptables -t nat -D POSTROUTING -j airnomad_snat 2>/dev/null; do :; done iptables -t nat -F airnomad_snat 2>/dev/null; iptables -t nat -X airnomad_snat 2>/dev/null fi if command -v ip6tables >/dev/null 2>&1; then for c in FORWARD INPUT; do while ip6tables -D "$c" -i "$IFACE" -j DROP 2>/dev/null; do :; done; done fi echo "Deleting the agent and its settings..." rm -f "$INIT" "$BIN" "$BIN.bak" "$CONF" "$UNINSTALL" /tmp/airnomad-agent.snat echo echo "AirNomadNetwork is removed. This is a standard GL.iNet router again." echo "If you also want to turn off the WireGuard server, go to VPN -> WireGuard Server in the router's admin page."