#!/bin/csh -f # Is Kevin still at work? # # kpi - 04/20/07 # # All this so my wife can know if I have left work yet. # # Ahh technology savior of relationships. # # This all assumes you have a static DHCP lease and that DNS points to this # lease. If you don't have a DNS setup then use IP. # # 2008-06/30 I added logic to make sure I am at my cubical's subnet # as I was getting false postives when I VPN'ed in. # # Globals set laptop="mylaptop.somewhere.us" set work_subnet="10.1.27" set aprs="http://www.findu.com/cgi-bin/inputpos.cgi?call=k4zxy-3&passwd=somepassword&lat=28.32456&lon=-081.12345" set dummy="/home/kevin/tmp/at_work.tmp" set msg="/home/kevin/tmp/at_work_msg.tmp" set dat="/home/kinscoe/pers/atworkstatus.dat" set arrival_log="/home/kinscoe/logs/arrival_log.log" # Announce ourselves echo "$0 starting at `/bin/date`..." /bin/date > $dummy /usr/bin/id # Ping the laptop to see if I am docked /bin/ping -c1 $laptop set result=$status echo "result=$result" set found_subnet=`/usr/bin/host mylaptop.somewhere.us | /bin/awk '{ print $4 }' | /bin/awk -F. '{ print $1 "." $2 "." $3 }'` echo "found=$found_subnet cubical subnet=$work_subnet" if ( "$result" == "0" ) then if ( "$found_subnet" == "$work_subnet") then echo "He's still at work." echo "

Kevin is currently at work

" > $msg test -e $dat || (echo "Updating APRS..."; /usr/bin/lynx -dump "$aprs") test -e $dat || (/bin/date >> $arrival_log) -P 72 $msg "$wmsg") test -e $dat || /home/kinscoe/bin/tweet "cubebot: Kevin has arrived at the Orlando office." /bin/touch $dat else echo "We found the laptop connected but the subnet is not" echo "Kevin's cubical so we will do nothing." /usr/bin/host mylaptop.somewhere.us endif else echo "He left work, remove status flag..." echo "

Kevin has left work

" > $msg if ( -e $dat ) then /bin/rm -f $dat /home/kinscoe/bin/tweet "cubebot: Kevin has left the Orlando office" endif endif # Exit echo "$0 completed at `/bin/date`..."