#!/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\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+="\n" body+="" body+="" body+="" body+="" done body+="
HostnameIP AddressMAC AddressWakeup
" body+="
X
" body+="" body+="" body+="
$hostname$ip$mac\n" body+="
\n" body+="

Dynamic leases

\n" body+="\n\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+="\n" body+="\n" body+="" body+="" body+="" body+="" fi done body+="
HostnameIP AddressMAC AddressWakeup
" body+="
X
" body+="" body+="" body+="
$hostname$ip$mac\n" body+="
\n\n\n" cat <