#!/bin/bash
#
# ::copy::
# ::maintainer::
#
CMD=$(basename "$0")
CMDVER="1.2"
CMDSTR="$CMD v$CMDVER (2020/02)"
ignorefile="$0.ignore"

uname=$(uname -n)

header='Content-type: text/html

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
	<link href="/css/klabs-report-styles.css" type="text/css" rel="stylesheet" />
'


# (MAIN)

echo "$header
	<title>$uname - Network Infos</title>
</head>
"
echo '
<body id="info">
<div class="header">
 <h1>'$uname'</h1>
  <div class="subtitle">Network Infos</div>
</div>

<br clear="all" />

<div class="col">'

for dev in $(/sbin/ifconfig | grep '^[a-z]' | sed -e 's/:* .*//')
do
	[ "$dev" = "lo" ] && continue
	[ -s "$ignorefile" ] && {
		grep -q "^$dev$" "$ignorefile" && continue
	}

	out=$(/sbin/ifconfig $dev)
	echo "$out" | grep -q 'inet ' || continue
	echo "$out" | egrep -q 'Link:UNSPEC|unspec ' && continue

	out=$(sudo /usr/sbin/ku-netdiscover --html $dev 2>/dev/null || :)
	[ "$out" != "" ] && {
		echo -e "\n <div class="infoTable">\n$out\n </div>"
	}
done

echo '
</div>

</body>
</html>
'

exit 0
