40 lines
944 B
Bash
Executable File
40 lines
944 B
Bash
Executable File
#!/bin/sh
|
|
|
|
# Stop the local-only hotspot created by localhotspot
|
|
|
|
IFACE="wlan1" # Must match the interface used in localhotspot
|
|
|
|
# Check root
|
|
if [ "$(id -u)" -ne 0 ]; then
|
|
echo "This script must be run as root"
|
|
exit 1
|
|
fi
|
|
|
|
echo "[*] Stopping local hotspot..."
|
|
|
|
# Kill the daemons
|
|
killall hostapd dnsmasq 2>/dev/null
|
|
pkill -9 hostapd 2>/dev/null
|
|
pkill -9 dnsmasq 2>/dev/null
|
|
sleep 1
|
|
|
|
# Remove routing rules that were added
|
|
ip rule del pref 50 2>/dev/null
|
|
ip rule del from 192.168.43.1/32 table 200 2>/dev/null
|
|
ip route flush table 200 2>/dev/null
|
|
|
|
# Bring the interface down and remove the IP
|
|
ip addr flush dev "$IFACE" 2>/dev/null
|
|
ip link set "$IFACE" down 2>/dev/null
|
|
|
|
# Delete the AP interface
|
|
iw dev "$IFACE" del 2>/dev/null
|
|
|
|
# Clean up temporary files
|
|
rm -f /tmp/hostapd-"$IFACE".conf
|
|
rm -f /tmp/dnsmasq-"$IFACE".pid
|
|
rm -f /tmp/dnsmasq-"$IFACE".log
|
|
|
|
echo "[+] Hotspot stopped."
|
|
echo " Interface $IFACE has been removed."
|