diff options
author | joe <joe@FreeBSD.org> | 2000-10-16 19:11:11 +0000 |
---|---|---|
committer | joe <joe@FreeBSD.org> | 2000-10-16 19:11:11 +0000 |
commit | c96e987bcddc90bdd81d23366b1b50b37294ba2c (patch) | |
tree | 08b4a0c822fd1b0c0d944d4277fb3e16fe8150a1 /etc/pccard_ether | |
parent | fe13d4e327186b75749c4357c83ae48fa9f3cae4 (diff) | |
download | FreeBSD-src-c96e987bcddc90bdd81d23366b1b50b37294ba2c.zip FreeBSD-src-c96e987bcddc90bdd81d23366b1b50b37294ba2c.tar.gz |
Add an optional start/stop argument to pccard_ether, and migrate
the 'ifconfig ifN delete' into pccard_ether under the 'stop'
function.
In addition start dhclient with a pid file based on the interface
name, e.g. /var/run/dhclient.ep0.pid, and kill the correct dhclient
(or dhcpc) process when the card is removed.
Diffstat (limited to 'etc/pccard_ether')
-rwxr-xr-x | etc/pccard_ether | 135 |
1 files changed, 80 insertions, 55 deletions
diff --git a/etc/pccard_ether b/etc/pccard_ether index ae05453..80f4a22 100755 --- a/etc/pccard_ether +++ b/etc/pccard_ether @@ -2,11 +2,39 @@ # # $FreeBSD$ # -# pccard_ether interfacename [ifconfig option] +# pccard_ether interfacename [start|stop] [ifconfig option] # -# example: pccard_ether ep0 -link0 +# example: pccard_ether ep0 start -link0 # +stop_dhcp() { + if [ -r /sbin/dhclient ]; then + pidfile="/var/run/dhclient.${interface}.pid" + if [ -s ${pidfile} ]; then + kill `cat ${pidfile}` + rm ${pidfile} + fi + elif [ -r /usr/local/sbin/dhcpc ]; then + pidfile="/var/run/dhcpc.${interface}.pid" + if [ -s ${pidfile} ]; then + kill `cat ${pidfile}` + rm ${pidfile} + fi + fi +} + +start_dhcp() { + stop_dhcp + if [ -r /sbin/dhclient ]; then + pidfile="/var/run/dhclient.${interface}.pid" + /sbin/dhclient -pf ${pidfile} $interface + elif [ -r /usr/local/sbin/dhcpc ]; then + /usr/local/sbin/dhcpc $interface + else + echo "DHCP client software not available (isc-dhcp2)" + fi +} + # Suck in the configuration variables # if [ -r /etc/defaults/rc.conf ]; then @@ -18,65 +46,62 @@ fi interface=$1 shift +startstop=$2 +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 ${startstop} in +[Ss][Tt][Aa][Rr][Tt] | '') + case ${pccard_ifconfig} in + [Nn][Oo] | '') + ;; + [Dd][Hh][Cc][Pp]) + start_dhcp + ;; + *) + ifconfig ${interface} ${pccard_ifconfig} $* + ;; + esac -case ${defaultrouter} in -[Nn][Oo] | '') - ;; -*) - static_routes="default ${static_routes}" - route_default="default ${defaultrouter}" - ;; -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 + # 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 -# IPv6 setup -case ${ipv6_enable} in -[Yy][Ee][Ss]) - case ${ipv6_gateway_enable} in + # IPv6 setup + case ${ipv6_enable} in [Yy][Ee][Ss]) - ;; - *) - sysctl -w net.inet6.ip6.forwarding=0 - sysctl -w net.inet6.ip6.accept_rtadv=1 - ifconfig ${interface} up - rtsol ${interface} + case ${ipv6_gateway_enable} in + [Yy][Ee][Ss]) + ;; + *) + sysctl -w net.inet6.ip6.forwarding=0 + sysctl -w net.inet6.ip6.accept_rtadv=1 + ifconfig ${interface} up + rtsol ${interface} + ;; + esac ;; esac ;; +# Stop the interface +*) + /sbin/ifconfig $device delete + stop_dhcp + ;; esac |