#!/bin/bash

# announce-ip su 19.2.2012 20.48.12 +0200
#
# Changes since ti 17.1.2012 18.35.32 +0200
#	- pick up wlanN interfaces too
#
# Changes since su 11.12.2011 16.55.17 +0200
#	- exit 0 to keep ifupdown happy (see lp:916890)
#
# Changes since pe 7.10.2011 18.11.26 +0300
#	- eat multiple eth interfaces (last one picked)
#
# Changes since pe 7.10.2011 17.51.02 +0300
#	- config file name: dash to underscore
#
# pe 7.10.2011 17.51.02 +0300: First release

source "/usr/local/etc/announce_ip" >/dev/null 2>&1 || exit 1
test "x$URL" = "x" && exit 1
for iface in `ifconfig | grep -E 'eth|wlan' | cut -d\  -f 1`
do
  IP=`ifconfig $iface | grep inet | awk '{printf $2}' | cut -d: -f2 | cut -da -f1`
  test "x$IP" = "x" || break
done
test "x$IP" = "x" && exit 0
curl -4 -s "${URL}${IP}"
