pccard_ether revision 107761
114596Snate#!/bin/sh - 214596Snate# 350472Speter# $FreeBSD: head/etc/pccard_ether 107761 2002-12-11 23:30:34Z imp $ 438738Sbrian# 567221Sjoe# pccard_ether interfacename [start|stop] [ifconfig option] 614596Snate# 767221Sjoe# example: pccard_ether ep0 start -link0 814596Snate# 914596Snate 1067221Sjoestop_dhcp() { 1170349Stoshi if [ -s /var/run/dhclient.${interface}.pid ]; then 1267221Sjoe pidfile="/var/run/dhclient.${interface}.pid" 1370349Stoshi elif [ -s /var/run/dhcpc.${interface}.pid ]; then 1467221Sjoe pidfile="/var/run/dhcpc.${interface}.pid" 1570349Stoshi else 1670349Stoshi return 1767221Sjoe fi 1870349Stoshi kill `cat ${pidfile}` 1970349Stoshi rm -f ${pidfile} 2067221Sjoe} 2167221Sjoe 2267221Sjoestart_dhcp() { 2367221Sjoe stop_dhcp 24107761Simp case ${pccard_ether_delay} in 25107761Simp [Nn][Oo]) 26107761Simp ;; 27107761Simp [0-9]) 28107761Simp sleep ${pccard_ether_delay} 29107761Simp ;; 30107761Simp esac 3170349Stoshi if [ -x "${dhcp_program}" ]; then 3270349Stoshi if [ `basename ${dhcp_program}` = "dhclient" ]; then 3370349Stoshi pidfile="/var/run/dhclient.${interface}.pid" 3470349Stoshi dhcp_flags="${dhcp_flags} -pf ${pidfile}" 3570349Stoshi fi 3670349Stoshi ${dhcp_program} ${dhcp_flags} ${interface} 3767221Sjoe else 3870349Stoshi echo "${dhcp_program}: DHCP client software not available" 3967221Sjoe fi 4067221Sjoe} 4167221Sjoe 4243849Sjkh# Suck in the configuration variables 4351231Ssheldonh# 4451231Ssheldonhif [ -r /etc/defaults/rc.conf ]; then 4543849Sjkh . /etc/defaults/rc.conf 4659674Ssheldonh source_rc_confs 4751231Ssheldonhelif [ -r /etc/rc.conf ]; then 4827117Sjkh . /etc/rc.conf 4914596Snatefi 5014596Snate 5157144Snsayerinterface=$1 5257144Snsayershift 5367795Sjoestartstop=$1 5467221Sjoeshift 5557144Snsayer 5670349Stoshicase ${pccard_ifconfig} in 5770349Stoshi[Nn][Oo] | '') 5870349Stoshi expr "${removable_interfaces}" : ".*${interface}" > /dev/null || exit 0 5970349Stoshi ;; 6070349Stoshi*) 6170349Stoshi # Backward compatible 6270349Stoshi eval ifconfig_${interface}=\${pccard_ifconfig} 6370349Stoshi ;; 6470349Stoshiesac 6570349Stoshi 6667221Sjoecase ${startstop} in 6767221Sjoe[Ss][Tt][Aa][Rr][Tt] | '') 68107761Simp if ifconfig ${interface} | grep -s UP,; then 69107761Simp # Interface is already up, so ignore it. 70107761Simp exit 0 71107761Simp fi 72107761Simp 7370349Stoshi if [ -r /etc/start_if.${interface} ]; then 7470349Stoshi . /etc/start_if.${interface} 7570349Stoshi fi 7670349Stoshi 7770349Stoshi eval ifconfig_args=\$ifconfig_${interface} 7870349Stoshi case ${ifconfig_args} in 7967221Sjoe [Nn][Oo] | '') 8067221Sjoe ;; 8167221Sjoe [Dd][Hh][Cc][Pp]) 8270349Stoshi # Start up the DHCP client program 8367221Sjoe start_dhcp 8467221Sjoe ;; 8567221Sjoe *) 8670349Stoshi # Do the primary ifconfig if specified 8770349Stoshi ifconfig ${interface} ${ifconfig_args} $* 8831297Snate 8970349Stoshi # Check to see if aliases need to be added 9070349Stoshi alias=0 9170349Stoshi while : 9270349Stoshi do 9370349Stoshi eval ifx_args=\$ifconfig_${interface}_alias${alias} 9470349Stoshi if [ -n "${ifx_args}" ]; then 9570349Stoshi ifconfig ${interface} ${ifx_args} alias 9670349Stoshi alias=`expr ${alias} + 1` 9770349Stoshi else 9870349Stoshi break; 9970349Stoshi fi 10070349Stoshi done 10170349Stoshi 10270349Stoshi # Do ipx address if specified 10370349Stoshi eval ifx_args=\$ifconfig_${interface}_ipx 10470349Stoshi if [ -n "${ifx_args}" ]; then 10570349Stoshi ifconfig ${interface} ${ifx_args} 10670349Stoshi fi 10770349Stoshi 10870349Stoshi # Add default route into $static_routes 10970349Stoshi case ${defaultrouter} in 11070349Stoshi [Nn][Oo] | '') 11170349Stoshi ;; 11270349Stoshi *) 11370349Stoshi static_routes="default ${static_routes}" 11470349Stoshi route_default="default ${defaultrouter}" 11570349Stoshi ;; 11670349Stoshi esac 11770349Stoshi 11870349Stoshi # Add private route for this interface into $static_routes 11970349Stoshi eval ifx_routes=\$static_routes_${interface} 12070349Stoshi if [ -n "${ifx_routes}" ]; then 12170349Stoshi static_routes="${ifx_routes} ${static_routes}" 12270349Stoshi fi 12370349Stoshi 12470349Stoshi # Set up any static routes if specified 12570349Stoshi if [ -n "${static_routes}" ]; then 12670349Stoshi for i in ${static_routes}; do 12770349Stoshi eval route_args=\$route_${i} 12870349Stoshi route add ${route_args} 12970349Stoshi done 13070349Stoshi fi 13167221Sjoe ;; 13267221Sjoe esac 13351231Ssheldonh 13467221Sjoe # IPv6 setup 13567221Sjoe case ${ipv6_enable} in 13663308Sume [Yy][Ee][Ss]) 13776045Sume if [ -r /etc/rc.network6 ]; then 13876045Sume . /etc/rc.network6 13976045Sume network6_interface_setup ${interface} 14076045Sume fi 14163308Sume ;; 14263308Sume esac 14363308Sume ;; 14467221Sjoe# Stop the interface 14567221Sjoe*) 14670349Stoshi if [ -r /etc/stop_if.${interface} ]; then 14770349Stoshi . /etc/stop_if.${interface} 14870349Stoshi fi 14970349Stoshi 15070349Stoshi eval ifconfig_args=\$ifconfig_${interface} 15170349Stoshi case ${ifconfig_args} in 15270349Stoshi [Nn][Oo] | '') 15370349Stoshi ;; 15470349Stoshi [Dd][Hh][Cc][Pp]) 15570349Stoshi # Stop the DHCP client for this interface 15670349Stoshi stop_dhcp 15770349Stoshi ;; 15870349Stoshi *) 15970349Stoshi # Delelte static route if specified 16070349Stoshi eval ifx_routes=\$static_routes_${interface} 16170349Stoshi if [ -n "${ifx_routes}" ]; then 16270349Stoshi for i in ${ifx_routes}; do 16370349Stoshi eval route_args=\$route_${i} 16470349Stoshi route delete ${route_args} 16570349Stoshi done 16670349Stoshi fi 16770349Stoshi 16870349Stoshi # Delete aliases if exist 16970349Stoshi alias=0 17070349Stoshi while : 17170349Stoshi do 17270349Stoshi eval ifx_args=\$ifconfig_${interface}_alias${alias} 17370349Stoshi if [ -n "${ifx_args}" ]; then 17470349Stoshi ifconfig ${interface} ${ifx_args} alias delete 17570349Stoshi alias=`expr ${alias} + 1` 17670349Stoshi else 17770349Stoshi break; 17870349Stoshi fi 17970349Stoshi done 18070349Stoshi ;; 18170349Stoshi esac 18270349Stoshi 18370349Stoshi # Remove the network interface and cleaning ARP table 18470349Stoshi ifconfig ${interface} delete 18570349Stoshi arp -d -a 18670349Stoshi 18770349Stoshi # Clean the routing table 18870349Stoshi case ${removable_route_flush} in 18970349Stoshi [Nn][Oo]) 19070349Stoshi ;; 19170349Stoshi *) 19270349Stoshi # flush beforehand, just in case.... 19376415Sume route -n flush -inet 19470349Stoshi ;; 19570349Stoshi esac 19667221Sjoe ;; 19763308Sumeesac 198