List static leases and dynamic leases separately.
Also increased the delays between updates to cause less server load. Updated bashserv.
This commit is contained in:
+35
-6
@@ -41,16 +41,45 @@ if [ -z "$REQUEST_PATH_SANE" -o "$REQUEST_PATH_SANE" == "index.html" ]; then
|
||||
body+="<link rel='stylesheet' href='main.css'></link>\n</head>\n"
|
||||
fi
|
||||
|
||||
body+="<body>\n<table>\n<tr><td></td><td>Hostname</td><td>IP Address</td><td>MAC Address</td><td>Wakeup</td></tr>\n"
|
||||
body+="<body>\n"
|
||||
body+="<h3>Static leases</h3>\n"
|
||||
body+="<table>\n<tr><td></td><td>Hostname</td><td>IP Address</td><td>MAC Address</td><td>Wakeup</td></tr>\n"
|
||||
|
||||
hosts=$(grep -i "^dhcp-host=" /etc/dnsmasq.conf | cut -d '=' -f2 | tr '[:upper:]' '[:lower:]')
|
||||
for host in $hosts; do
|
||||
mac=$(echo "$host" | cut -d ',' -f1)
|
||||
ip=$(echo "$host" | cut -d ',' -f2)
|
||||
hostname="?"
|
||||
lease_hostname=$(grep -i "$mac" /var/lib/misc/dnsmasq.leases | cut -d ' ' -f4)
|
||||
if [ -n "$lease_hostname" ]; then
|
||||
hostname="$lease_hostname"
|
||||
fi
|
||||
body+="<tr class='host' data-ip='$ip' data-mac='$mac'>\n"
|
||||
body+="<td class='status'>"
|
||||
body+="<div 'class='fail'>X</div>"
|
||||
body+="<div class='success' style='display: none;'>✓</div>"
|
||||
body+="<div class='undef' style='display: none;'>?</div>"
|
||||
body+="</td>\n"
|
||||
|
||||
body+="<td>$hostname</td>"
|
||||
body+="<td>$ip</td>"
|
||||
body+="<td>$mac</td>"
|
||||
body+="<td><button class='wol' value="$mac">⏻</button><td>\n"
|
||||
body+="</tr>"
|
||||
done
|
||||
|
||||
body+="</table>\n"
|
||||
body+="<h3>Dynamic leases</h3>\n"
|
||||
body+="<table>\n<tr><td></td><td>Hostname</td><td>IP Address</td><td>MAC Address</td><td>Wakeup</td></tr>\n"
|
||||
|
||||
IFS=$'\n'
|
||||
leases=$(cat /var/lib/misc/dnsmasq.leases | cut -d ' ' -f2-4)
|
||||
for lease in $leases; do
|
||||
mac=$(echo $lease | cut -d ' ' -f1)
|
||||
ip=$(echo $lease | cut -d ' ' -f2)
|
||||
hostname=$(echo $lease | cut -d ' ' -f3)
|
||||
mac=$(echo "$lease" | cut -d ' ' -f1)
|
||||
ip=$(echo "$lease" | cut -d ' ' -f2)
|
||||
hostname=$(echo "$lease" | cut -d ' ' -f3)
|
||||
|
||||
if [ -n "$(grep -i "$mac" /etc/dnsmasq.conf)" ]; then
|
||||
if [ -z "$(grep -i "$mac" /etc/dnsmasq.conf)" ]; then
|
||||
body+="<tr class='host' data-ip='$ip' data-mac='$mac'>\n"
|
||||
|
||||
body+="<td class='status'>"
|
||||
@@ -62,7 +91,7 @@ if [ -z "$REQUEST_PATH_SANE" -o "$REQUEST_PATH_SANE" == "index.html" ]; then
|
||||
body+="<td>$hostname</td>"
|
||||
body+="<td>$ip</td>"
|
||||
body+="<td>$mac</td>"
|
||||
body+="<td><button class='wol' value="$mac">Wake up!</button><td>\n"
|
||||
body+="<td><button class='wol' value="$mac">⏻</button><td>\n"
|
||||
body+="</tr>"
|
||||
fi
|
||||
done
|
||||
|
||||
Reference in New Issue
Block a user