#!/bin/sh
PFILAP=/etc/opt/pfil/iu.ap

fixif()
{
	ifconfig $1 2>/dev/null 1>&2
	if [ $? -ne 0 ] ; then
		ifconfig $1 plumb
		ifconfig $1 unplumb
	fi
}


case "$1" in
	start)
		if [ ! -f /etc/ipf.conf -a ! -f /etc/opt/ipf/ipf.conf ] ; then
			exit 0;
		fi
		iflist="`echo /etc/hostname.*[0-9] 2>/dev/null`"
		if [ "$iflist" != '/etc/hostname.*[0-9]' ] ; then
			(
				y=xxx
				x=$IFS
				for i in /etc/hostname.*[0-9]; do
					ifname=`expr $i : '[^\.]*\.\(.*\)'`
					if [ $ifname != $y ] ; then
						y=$ifname
						fixif $ifname
					fi
				done
			)
		fi
		echo > /dev/pfil
		autopush -f ${PFILAP} 2>/dev/null 1>&2
		;;

	*)
		echo "Usage: $0 start" >&2
		exit 1
		;;

esac
exit 0
