#!/bin/sh -
#
# pccard_ether_remove interfacename
#
# example: pccard_ether_remove ep0
#
# Mar 9, 1996 by Hajimu UMEMOTO <ume@calm.imasy.or.jp>
# Mar 31, 1997 by Tatsumi Hosokawa <hosokawa@jp.FreeBSD.org>

# Suck in the /etc/sysconfig variables
if [ -f /etc/rc.conf ]; then
	. /etc/rc.conf
fi

interface=$1

if [ "x$pccard_ether" != "xNO" ] ; then
	eval ifconfig_args=\$ifconfig_${interface}
	if [ "x$ifconfig_args" = "xDHCP" ] ; then
		if [ -f /var/run/dhcpc.$interface.pid ] ; then
			kill `cat /var/run/dhcpc.$interface.pid`
		else
			killarg=`ps x | awk '$5 ~/(^|\/)dhcpc$/ && $6 ~/^'$1'$/ {print $1}'`
			if [ "x$killarg" != "x" ] ; then
				kill $killarg
			fi
		fi
	else
		ifconfig $interface delete
	fi
fi

if [ -n "$defaultrouter" -a "x$defaultrouter" != "xNO" ] ; then
	route -n flush
fi