#!/bin/bash

#Added by Mason.  The files this creates store all the IP's an interface
#has used.  Mason uses these to figure out the smallest network that will
#accomodate all these IP's.
#This short section of code (without the first "#"):
#
#	[ -f /var/lib/mason/saveips ] && . /var/lib/mason/saveips		#Added by Mason
#
#should be appended to:
#	- /etc/rc.d/rc.local (or some file that gets run at boot time)
#	- any script that's run _after_ a new IP address is acquired, such as:
#	- /etc/ppp/ip-up or /etc/ppp/ip-up.local
#	- /etc/dhclient-script
#	- /etc/sysconfig/network-scripts/dhcpcd-eth*
#	- /etc/pcmcia/network  (in the start_fn function)

#FIXME - add to Makefile and install scripts...
for ONEIF in `ifconfig | grep 'Link encap' | awk '{print $1}'` ; do
	NEWIP=`ifconfig $ONEIF | awk '/inet addr/{print substr($2,6)}'`
	if [ -n "$NEWIP" ] && [ -z "`cat /var/lib/mason/$ONEIF-ips | grep ^$NEWIP\$`" ]; then
		echo $NEWIP >>/var/lib/mason/$ONEIF-ips
	fi
done

