1996-03-12 15:39:26 +00:00
|
|
|
#!/bin/sh -
|
|
|
|
#
|
1999-08-27 23:37:10 +00:00
|
|
|
# $FreeBSD$
|
1998-09-02 01:34:57 +00:00
|
|
|
#
|
2000-10-16 19:11:11 +00:00
|
|
|
# pccard_ether interfacename [start|stop] [ifconfig option]
|
1996-03-12 15:39:26 +00:00
|
|
|
#
|
2000-10-16 19:11:11 +00:00
|
|
|
# example: pccard_ether ep0 start -link0
|
1996-03-12 15:39:26 +00:00
|
|
|
#
|
|
|
|
|
2000-10-16 19:11:11 +00:00
|
|
|
stop_dhcp() {
|
2000-12-25 09:21:18 +00:00
|
|
|
if [ -s /var/run/dhclient.${interface}.pid ]; then
|
2000-10-16 19:11:11 +00:00
|
|
|
pidfile="/var/run/dhclient.${interface}.pid"
|
2000-12-25 09:21:18 +00:00
|
|
|
elif [ -s /var/run/dhcpc.${interface}.pid ]; then
|
2000-10-16 19:11:11 +00:00
|
|
|
pidfile="/var/run/dhcpc.${interface}.pid"
|
2000-12-25 09:21:18 +00:00
|
|
|
else
|
|
|
|
return
|
2000-10-16 19:11:11 +00:00
|
|
|
fi
|
2000-12-25 09:21:18 +00:00
|
|
|
kill `cat ${pidfile}`
|
|
|
|
rm -f ${pidfile}
|
2000-10-16 19:11:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
start_dhcp() {
|
|
|
|
stop_dhcp
|
2002-12-11 23:30:34 +00:00
|
|
|
case ${pccard_ether_delay} in
|
|
|
|
[Nn][Oo])
|
|
|
|
;;
|
|
|
|
[0-9])
|
|
|
|
sleep ${pccard_ether_delay}
|
|
|
|
;;
|
|
|
|
esac
|
2000-12-25 09:21:18 +00:00
|
|
|
if [ -x "${dhcp_program}" ]; then
|
|
|
|
if [ `basename ${dhcp_program}` = "dhclient" ]; then
|
|
|
|
pidfile="/var/run/dhclient.${interface}.pid"
|
|
|
|
dhcp_flags="${dhcp_flags} -pf ${pidfile}"
|
|
|
|
fi
|
|
|
|
${dhcp_program} ${dhcp_flags} ${interface}
|
2000-10-16 19:11:11 +00:00
|
|
|
else
|
2000-12-25 09:21:18 +00:00
|
|
|
echo "${dhcp_program}: DHCP client software not available"
|
2000-10-16 19:11:11 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
1999-02-10 18:08:16 +00:00
|
|
|
# Suck in the configuration variables
|
1999-09-13 15:44:20 +00:00
|
|
|
#
|
|
|
|
if [ -r /etc/defaults/rc.conf ]; then
|
1999-02-10 18:08:16 +00:00
|
|
|
. /etc/defaults/rc.conf
|
2000-04-27 08:43:49 +00:00
|
|
|
source_rc_confs
|
1999-09-13 15:44:20 +00:00
|
|
|
elif [ -r /etc/rc.conf ]; then
|
1997-06-30 19:10:50 +00:00
|
|
|
. /etc/rc.conf
|
1996-03-12 15:39:26 +00:00
|
|
|
fi
|
|
|
|
|
2000-02-11 14:49:42 +00:00
|
|
|
interface=$1
|
|
|
|
shift
|
2000-10-28 14:31:40 +00:00
|
|
|
startstop=$1
|
2000-10-16 19:11:11 +00:00
|
|
|
shift
|
2000-02-11 14:49:42 +00:00
|
|
|
|
2000-12-25 09:21:18 +00:00
|
|
|
case ${pccard_ifconfig} in
|
|
|
|
[Nn][Oo] | '')
|
|
|
|
expr "${removable_interfaces}" : ".*${interface}" > /dev/null || exit 0
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
# Backward compatible
|
|
|
|
eval ifconfig_${interface}=\${pccard_ifconfig}
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2000-10-16 19:11:11 +00:00
|
|
|
case ${startstop} in
|
|
|
|
[Ss][Tt][Aa][Rr][Tt] | '')
|
2002-12-12 09:31:10 +00:00
|
|
|
if ifconfig ${interface} | grep -s UP, > /dev/null 2>&1; then
|
2002-12-11 23:30:34 +00:00
|
|
|
# Interface is already up, so ignore it.
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2000-12-25 09:21:18 +00:00
|
|
|
if [ -r /etc/start_if.${interface} ]; then
|
|
|
|
. /etc/start_if.${interface}
|
|
|
|
fi
|
|
|
|
|
|
|
|
eval ifconfig_args=\$ifconfig_${interface}
|
|
|
|
case ${ifconfig_args} in
|
2000-10-16 19:11:11 +00:00
|
|
|
[Nn][Oo] | '')
|
|
|
|
;;
|
|
|
|
[Dd][Hh][Cc][Pp])
|
2000-12-25 09:21:18 +00:00
|
|
|
# Start up the DHCP client program
|
2000-10-16 19:11:11 +00:00
|
|
|
start_dhcp
|
|
|
|
;;
|
|
|
|
*)
|
2000-12-25 09:21:18 +00:00
|
|
|
# Do the primary ifconfig if specified
|
|
|
|
ifconfig ${interface} ${ifconfig_args} $*
|
1997-11-19 18:51:25 +00:00
|
|
|
|
2000-12-25 09:21:18 +00:00
|
|
|
# Check to see if aliases need to be added
|
|
|
|
alias=0
|
|
|
|
while :
|
|
|
|
do
|
|
|
|
eval ifx_args=\$ifconfig_${interface}_alias${alias}
|
|
|
|
if [ -n "${ifx_args}" ]; then
|
|
|
|
ifconfig ${interface} ${ifx_args} alias
|
|
|
|
alias=`expr ${alias} + 1`
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
# Do ipx address if specified
|
|
|
|
eval ifx_args=\$ifconfig_${interface}_ipx
|
|
|
|
if [ -n "${ifx_args}" ]; then
|
|
|
|
ifconfig ${interface} ${ifx_args}
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Add default route into $static_routes
|
|
|
|
case ${defaultrouter} in
|
|
|
|
[Nn][Oo] | '')
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
static_routes="default ${static_routes}"
|
|
|
|
route_default="default ${defaultrouter}"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
# Add private route for this interface into $static_routes
|
|
|
|
eval ifx_routes=\$static_routes_${interface}
|
|
|
|
if [ -n "${ifx_routes}" ]; then
|
|
|
|
static_routes="${ifx_routes} ${static_routes}"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Set up any static routes if specified
|
|
|
|
if [ -n "${static_routes}" ]; then
|
|
|
|
for i in ${static_routes}; do
|
|
|
|
eval route_args=\$route_${i}
|
|
|
|
route add ${route_args}
|
|
|
|
done
|
|
|
|
fi
|
2000-10-16 19:11:11 +00:00
|
|
|
;;
|
|
|
|
esac
|
1999-09-13 15:44:20 +00:00
|
|
|
|
2000-10-16 19:11:11 +00:00
|
|
|
# IPv6 setup
|
|
|
|
case ${ipv6_enable} in
|
2000-07-17 12:33:57 +00:00
|
|
|
[Yy][Ee][Ss])
|
2003-05-05 19:06:46 +00:00
|
|
|
if [ -r /etc/rc.d/network_ipv6 ]; then
|
|
|
|
. /etc/rc.d/network_ipv6
|
2001-04-26 17:33:37 +00:00
|
|
|
network6_interface_setup ${interface}
|
|
|
|
fi
|
2000-07-17 12:33:57 +00:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
;;
|
2000-10-16 19:11:11 +00:00
|
|
|
# Stop the interface
|
|
|
|
*)
|
2000-12-25 09:21:18 +00:00
|
|
|
if [ -r /etc/stop_if.${interface} ]; then
|
|
|
|
. /etc/stop_if.${interface}
|
|
|
|
fi
|
|
|
|
|
|
|
|
eval ifconfig_args=\$ifconfig_${interface}
|
|
|
|
case ${ifconfig_args} in
|
|
|
|
[Nn][Oo] | '')
|
|
|
|
;;
|
|
|
|
[Dd][Hh][Cc][Pp])
|
|
|
|
# Stop the DHCP client for this interface
|
|
|
|
stop_dhcp
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
# Delelte static route if specified
|
|
|
|
eval ifx_routes=\$static_routes_${interface}
|
|
|
|
if [ -n "${ifx_routes}" ]; then
|
|
|
|
for i in ${ifx_routes}; do
|
|
|
|
eval route_args=\$route_${i}
|
|
|
|
route delete ${route_args}
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Delete aliases if exist
|
|
|
|
alias=0
|
|
|
|
while :
|
|
|
|
do
|
|
|
|
eval ifx_args=\$ifconfig_${interface}_alias${alias}
|
|
|
|
if [ -n "${ifx_args}" ]; then
|
|
|
|
ifconfig ${interface} ${ifx_args} alias delete
|
|
|
|
alias=`expr ${alias} + 1`
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
# Remove the network interface and cleaning ARP table
|
|
|
|
ifconfig ${interface} delete
|
|
|
|
arp -d -a
|
|
|
|
|
|
|
|
# Clean the routing table
|
|
|
|
case ${removable_route_flush} in
|
|
|
|
[Nn][Oo])
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
# flush beforehand, just in case....
|
2001-05-09 20:30:55 +00:00
|
|
|
route -n flush -inet
|
2000-12-25 09:21:18 +00:00
|
|
|
;;
|
|
|
|
esac
|
2000-10-16 19:11:11 +00:00
|
|
|
;;
|
2000-07-17 12:33:57 +00:00
|
|
|
esac
|