freebsd-dev/etc/pccard_ether
Sheldon Hearn f66e7afa28 Add to defaults/rc.conf a new function source_rc_confs which rc
scripts may use to source safely overrides in ${rc_conf_files}
files.

This protects users who insist on the bad practice of copying
/etc/defaults/rc.conf to /etc/rc.conf from a recursive loop
that exhausts available file descriptors.

Several people have expressed interest in breaking this function
out into its own shell script.  Anyone who wants to embark on
such an undertaking would do well to study the attributed PR.

PR:		17595
Reported by:	adrian
Submitted by:	Doug Barton <Doug@gorean.org>
2000-04-27 08:43:49 +00:00

67 lines
1.2 KiB
Bash
Executable File

#!/bin/sh -
#
# $FreeBSD$
#
# pccard_ether interfacename [ifconfig option]
#
# example: pccard_ether ep0 -link0
#
# Suck in the configuration variables
#
if [ -r /etc/defaults/rc.conf ]; then
. /etc/defaults/rc.conf
source_rc_confs
elif [ -r /etc/rc.conf ]; then
. /etc/rc.conf
fi
interface=$1
shift
case ${pccard_ifconfig} in
[Nn][Oo] | '')
;;
[Dd][Hh][Cc][Pp])
if [ -r /sbin/dhclient ]; then
if [ -s /var/run/dhclient.pid ]; then
kill `cat /var/run/dhclient.pid`
rm /var/run/dhclient.pid
fi
/sbin/dhclient $interface
elif [ -r /usr/local/sbin/dhcpc ]; then
if [ -s /var/run/dhcpc.pid ]; then
kill `cat /var/run/dhcpc.pid`
rm /var/run/dhcpc.pid
fi
/usr/local/sbin/dhcpc $interface $*
else
echo "DHCP client software not available (isc-dhcp2)"
fi
;;
*)
ifconfig ${interface} ${pccard_ifconfig} $*
;;
esac
case ${defaultrouter} in
[Nn][Oo] | '')
;;
*)
static_routes="default ${static_routes}"
route_default="default ${defaultrouter}"
;;
esac
# Set up any static routes.
#
if [ -n "${static_routes}" ]; then
# flush beforehand, just in case....
route -n flush
arp -d -a
for i in ${static_routes}; do
eval route_args=\$route_${i}
route add ${route_args}
done
fi