pccard_ether revision 70349
114596Snate#!/bin/sh - 214596Snate# 350472Speter# $FreeBSD: head/etc/pccard_ether 70349 2000-12-25 09:21:18Z toshi $ 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 2470349Stoshi if [ -x "${dhcp_program}" ]; then 2570349Stoshi if [ `basename ${dhcp_program}` = "dhclient" ]; then 2670349Stoshi pidfile="/var/run/dhclient.${interface}.pid" 2770349Stoshi dhcp_flags="${dhcp_flags} -pf ${pidfile}" 2870349Stoshi fi 2970349Stoshi ${dhcp_program} ${dhcp_flags} ${interface} 3067221Sjoe else 3170349Stoshi echo "${dhcp_program}: DHCP client software not available" 3267221Sjoe fi 3367221Sjoe} 3467221Sjoe 3543849Sjkh# Suck in the configuration variables 3651231Ssheldonh# 3751231Ssheldonhif [ -r /etc/defaults/rc.conf ]; then 3843849Sjkh . /etc/defaults/rc.conf 3959674Ssheldonh source_rc_confs 4051231Ssheldonhelif [ -r /etc/rc.conf ]; then 4127117Sjkh . /etc/rc.conf 4214596Snatefi 4314596Snate 4457144Snsayerinterface=$1 4557144Snsayershift 4667795Sjoestartstop=$1 4767221Sjoeshift 4857144Snsayer 4970349Stoshicase ${pccard_ifconfig} in 5070349Stoshi[Nn][Oo] | '') 5170349Stoshi expr "${removable_interfaces}" : ".*${interface}" > /dev/null || exit 0 5270349Stoshi ;; 5370349Stoshi*) 5470349Stoshi # Backward compatible 5570349Stoshi eval ifconfig_${interface}=\${pccard_ifconfig} 5670349Stoshi ;; 5770349Stoshiesac 5870349Stoshi 5967221Sjoecase ${startstop} in 6067221Sjoe[Ss][Tt][Aa][Rr][Tt] | '') 6170349Stoshi if [ -r /etc/start_if.${interface} ]; then 6270349Stoshi . /etc/start_if.${interface} 6370349Stoshi fi 6470349Stoshi 6570349Stoshi eval ifconfig_args=\$ifconfig_${interface} 6670349Stoshi case ${ifconfig_args} in 6767221Sjoe [Nn][Oo] | '') 6867221Sjoe ;; 6967221Sjoe [Dd][Hh][Cc][Pp]) 7070349Stoshi # Start up the DHCP client program 7167221Sjoe start_dhcp 7267221Sjoe ;; 7367221Sjoe *) 7470349Stoshi # Do the primary ifconfig if specified 7570349Stoshi ifconfig ${interface} ${ifconfig_args} $* 7631297Snate 7770349Stoshi # Check to see if aliases need to be added 7870349Stoshi alias=0 7970349Stoshi while : 8070349Stoshi do 8170349Stoshi eval ifx_args=\$ifconfig_${interface}_alias${alias} 8270349Stoshi if [ -n "${ifx_args}" ]; then 8370349Stoshi ifconfig ${interface} ${ifx_args} alias 8470349Stoshi alias=`expr ${alias} + 1` 8570349Stoshi else 8670349Stoshi break; 8770349Stoshi fi 8870349Stoshi done 8970349Stoshi 9070349Stoshi # Do ipx address if specified 9170349Stoshi eval ifx_args=\$ifconfig_${interface}_ipx 9270349Stoshi if [ -n "${ifx_args}" ]; then 9370349Stoshi ifconfig ${interface} ${ifx_args} 9470349Stoshi fi 9570349Stoshi 9670349Stoshi # Add default route into $static_routes 9770349Stoshi case ${defaultrouter} in 9870349Stoshi [Nn][Oo] | '') 9970349Stoshi ;; 10070349Stoshi *) 10170349Stoshi static_routes="default ${static_routes}" 10270349Stoshi route_default="default ${defaultrouter}" 10370349Stoshi ;; 10470349Stoshi esac 10570349Stoshi 10670349Stoshi # Add private route for this interface into $static_routes 10770349Stoshi eval ifx_routes=\$static_routes_${interface} 10870349Stoshi if [ -n "${ifx_routes}" ]; then 10970349Stoshi static_routes="${ifx_routes} ${static_routes}" 11070349Stoshi fi 11170349Stoshi 11270349Stoshi # Set up any static routes if specified 11370349Stoshi if [ -n "${static_routes}" ]; then 11470349Stoshi for i in ${static_routes}; do 11570349Stoshi eval route_args=\$route_${i} 11670349Stoshi route add ${route_args} 11770349Stoshi done 11870349Stoshi fi 11967221Sjoe ;; 12067221Sjoe esac 12151231Ssheldonh 12267221Sjoe # IPv6 setup 12367221Sjoe case ${ipv6_enable} in 12463308Sume [Yy][Ee][Ss]) 12567221Sjoe case ${ipv6_gateway_enable} in 12667221Sjoe [Yy][Ee][Ss]) 12767221Sjoe ;; 12867221Sjoe *) 12967221Sjoe sysctl -w net.inet6.ip6.forwarding=0 13067221Sjoe sysctl -w net.inet6.ip6.accept_rtadv=1 13167221Sjoe ifconfig ${interface} up 13267221Sjoe rtsol ${interface} 13367221Sjoe ;; 13467221Sjoe esac 13563308Sume ;; 13663308Sume esac 13763308Sume ;; 13867221Sjoe# Stop the interface 13967221Sjoe*) 14070349Stoshi if [ -r /etc/stop_if.${interface} ]; then 14170349Stoshi . /etc/stop_if.${interface} 14270349Stoshi fi 14370349Stoshi 14470349Stoshi eval ifconfig_args=\$ifconfig_${interface} 14570349Stoshi case ${ifconfig_args} in 14670349Stoshi [Nn][Oo] | '') 14770349Stoshi ;; 14870349Stoshi [Dd][Hh][Cc][Pp]) 14970349Stoshi # Stop the DHCP client for this interface 15070349Stoshi stop_dhcp 15170349Stoshi ;; 15270349Stoshi *) 15370349Stoshi # Delelte static route if specified 15470349Stoshi eval ifx_routes=\$static_routes_${interface} 15570349Stoshi if [ -n "${ifx_routes}" ]; then 15670349Stoshi for i in ${ifx_routes}; do 15770349Stoshi eval route_args=\$route_${i} 15870349Stoshi route delete ${route_args} 15970349Stoshi done 16070349Stoshi fi 16170349Stoshi 16270349Stoshi # Delete aliases if exist 16370349Stoshi alias=0 16470349Stoshi while : 16570349Stoshi do 16670349Stoshi eval ifx_args=\$ifconfig_${interface}_alias${alias} 16770349Stoshi if [ -n "${ifx_args}" ]; then 16870349Stoshi ifconfig ${interface} ${ifx_args} alias delete 16970349Stoshi alias=`expr ${alias} + 1` 17070349Stoshi else 17170349Stoshi break; 17270349Stoshi fi 17370349Stoshi done 17470349Stoshi ;; 17570349Stoshi esac 17670349Stoshi 17770349Stoshi # Remove the network interface and cleaning ARP table 17870349Stoshi ifconfig ${interface} delete 17970349Stoshi arp -d -a 18070349Stoshi 18170349Stoshi # Clean the routing table 18270349Stoshi case ${removable_route_flush} in 18370349Stoshi [Nn][Oo]) 18470349Stoshi ;; 18570349Stoshi *) 18670349Stoshi # flush beforehand, just in case.... 18770349Stoshi route -n flush 18870349Stoshi ;; 18970349Stoshi esac 19067221Sjoe ;; 19163308Sumeesac 192