#!/bin/bash
echo "[$(date +%T)] GET $REQUEST_PATH_SANE ($REQUEST_PATH)" >> get.log
./handle_requests.sh "$@"
if [ $? -eq 0 ]; then
exit 0
fi
user_agent=$($BASHSERV_DIR/get_request_field.sh "User-Agent")
if [[ $user_agent =~ Mobile ]]; then
mobile=1
fi
if [ -z "$REQUEST_PATH_SANE" -o "$REQUEST_PATH_SANE" == "index.html" ]; then
body="\n
\n$WAKEBOARD_TITLE\n"
body+="\n"
if [ $mobile ]; then
body+="\n\n"
else
body+="\n\n"
fi
body+="\n"
body+="
Static leases
\n"
body+="
\n
Hostname
IP Address
MAC Address
Wakeup
\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+="
\n"
body+="
"
body+="
X
"
body+="
✓
"
body+="
?
"
body+="
\n"
body+="
$hostname
"
body+="
$ip
"
body+="
$mac
"
body+="
\n"
body+="
"
done
body+="
\n"
body+="
Dynamic leases
\n"
body+="
\n
Hostname
IP Address
MAC Address
Wakeup
\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)
if [ -z "$(grep -i "$mac" /etc/dnsmasq.conf)" ]; then
body+="