#!/bin/bash # ************************************************************ # AltEPG Project Source Code Version Control # $FileID: git::root/hack/bin/report_ipaddress $ # $Revision: altepg1.0c root 2011-09-17 23:39:32 +0100 Finalising altepg1.0c $ # Description: Send tivo message detailing IP address config # ************************************************************ # 2011-07-26 BM: corrected error in 'Clear out any useless values' section # - and then commented it out because if you're getting 0.0.0.0 it actually # tells you something (ie the card is loaded but has no IP address) tmpfile=/tmp/report.$$ # Loop trying very hard to get a valid IP address. 10 minutes is long enough for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 do eth=`ifconfig eth0 2> /dev/null|grep addr: | sed 's/.*addr://;s/ Bcast.*//'` ppp=`ifconfig ppp0 2> /dev/null|grep addr: | sed 's/.*addr://;s/ P-t-P.*//'` mac=`ifconfig eth0 2> /dev/null|grep HWadd | sed 's/.*HWaddr //'` if [ "$eth" != "" -a "$eth" != "0.0.0.0" ]; then break; fi if [ "$ppp" != "" -a "$ppp" != "0.0.0.0" ]; then break; fi sleep 30 done # Clear any useless values # if [ "$eth" = "0.0.0.0" ]; then eth=""; fi # if [ "$ppp" = "0.0.0.0" ]; then ppp=""; fi # Send the mail if we have a non-empty IP address if [ "$eth" != "" -o "$ppp" != "" ]; then echo -n 'Your TiVo has the following IP address(es). You' > $tmpfile echo -n ' should be able to Telnet to them and get a login' >> $tmpfile echo -n ' prompt. You should also be able to connect to the' >> $tmpfile echo ' TiVoWeb server using the URL shown.' >> $tmpfile if [ "$eth" != "" ]; then echo >> $tmpfile echo "Ethernet/Airnet: IP address $eth, MAC address $mac" >> $tmpfile echo "Connect to TiVoWeb using http://$eth" >> $tmpfile fi if [ "$ppp" != "" ]; then echo >> $tmpfile echo "Serial PPP link: IP address $ppp" >> $tmpfile echo "Connect to TiVonet using http://$ppp" >> $tmpfile fi echo >> $tmpfile echo -n "Time of reboot: " >> $tmpfile date >> $tmpfile Version="Unconfigured" sendtivomesg.tcl "TiVo AltEPG altepg1.0c" 'IP Addresses' < $tmpfile rm $tmpfile fi