-
Notifications
You must be signed in to change notification settings - Fork 6
/
dhcp
executable file
·42 lines (38 loc) · 890 Bytes
/
dhcp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/bin/bash
#list dhcp address currently assigned"
#by the raspberry pi hotspot"
#20200225 km4ack
DHCP=$(cat /var/lib/misc/dnsmasq.leases)
HSS=$(cat /usr/bin/autohotspotN | grep "ip a add" | awk '{ print $4 }' | sed 's/\/24//')
CIP=$(ifconfig | grep -A 1 wlan0 | grep inet | awk '{ print $2 }')
if [ $HSS = $CIP ]
then
HSS=ACTIVE
else
HSS=INACTIVE
fi
clear;echo;echo
echo "List of Current DHCP Addresses"
echo "$DHCP" | awk '{ print $3" "$4" "$5 }'
echo;echo
read -p "Flush DHCP Leases? y/n " ANS
if [ $HSS = 'ACTIVE' ] && [ $ANS = 'y' ] || [ $ANS = 'Y' ]
then
cat <<EOF
Hotspot is currently active.
Please shutdown the hotspot
by connecting to a known SSID
and try flushing DHCP leases
again
EOF
sleep 5
exit 1
fi
if [ $ANS = 'y' ] || [ $ANS = 'Y' ]
then
sudo systemctl stop dnsmasq
echo "" | sudo tee /var/lib/misc/dnsmasq.leases
sudo systemctl start dnsmasq
echo "flushed"
sleep 2
fi