#ª/bin/bash

source /tmp/net-eth0.conf
FILEINFOHTML=$OGLOG/`ogGetIpAddress`.info.html
FILEINFOCACHE=$OGLOG/`ogGetIpAddress`.cache.txt
ogMountCache 2>/dev/null
CACHECONTENIDO=`ls -m $OGCAC/$OGIMG 2>/dev/null`

SPEED=$(LANG=C ethtool $DEVICE 2>/dev/null | awk '$1~/Speed/ {print $2}')
case "$SPEED" in
	1000[Mm]b/s)	;;
	100[Mm]b/s)	SPEED="<font color=\"blue\">$SPEED</font>" ;;
	10[Mm]b/s)	SPEED="<font color=\"grey\">$SPEED</font>" ;;
	*)		SPEED="<font color=\"red\">$SPEED</font>" ;;
esac
DUPLEX=$(LANG=C ethtool $DEVICE 2>/dev/null | awk '$1~/Duplex/ {print $2}')
case "$DUPLEX" in
	[Ff]ull)	;;
	*)		DUPLEX="<font color=\"red\">$DUPLEX</font>"
esac
CACHESIZEFREE=$(ogGetFreeSize `ogFindCache`)
expr $CACHESIZEFREE / 1024 > $FILEINFOCACHE 2>/dev/null && echo '.MB,' >> $FILEINFOCACHE

#
#  echo '';
#

cat > $FILEINFOHTML << EOF
<div align="center" style="font-family: Arial, Helvetica, sans-serif;">
<p style="color:#999999; font-size: 16px; margin: 2em;">

<table border=1 width="100%">
<tr>
<td rowspan="2"><p align="left"><img border="0" src="../images/iconos/logoopengnsys.png"><p> </td>
<td> Hostname </td> <td> IP </td> <td> MAC </td> <td> Speed </td> <td> Duplex </td> </tr>
<tr> <td>$HOSTNAME </td> <td> $(ogGetIpAddress) </td> <td> $(ogGetMacAddress) </td> <td> $SPEED </td> <td> $DUPLEX </td> </tr>
</table>

</p>
<p style="font-size: 14px; margin: 2em;">
</p>
</div>

EOF
cat >> $FILEINFOCACHE << EOF
$CACHECONTENIDO
EOF

