pccard_ether revision 83389
1#!/bin/sh - 2# 3# $FreeBSD: head/etc/pccard_ether 83389 2001-09-13 06:18:07Z imp $ 4# 5# pccard_ether interfacename [start|stop] [ifconfig option] 6# 7# example: pccard_ether ep0 start -link0 8# 9 10stop_dhcp() { 11 if [ -s /var/run/dhclient.${interface}.pid ]; then 12 pidfile="/var/run/dhclient.${interface}.pid" 13 elif [ -s /var/run/dhcpc.${interface}.pid ]; then 14 pidfile="/var/run/dhcpc.${interface}.pid" 15 else 16 return 17 fi 18 kill `cat ${pidfile}` 19 rm -f ${pidfile} 20} 21 22start_dhcp() { 23 stop_dhcp 24 if [ -x "${dhcp_program}" ]; then 25 if [ `basename ${dhcp_program}` = "dhclient" ]; then 26 pidfile="/var/run/dhclient.${interface}.pid" 27 dhcp_flags="${dhcp_flags} -pf ${pidfile}" 28 fi 29 ${dhcp_program} ${dhcp_flags} ${interface} 30 else 31 echo "${dhcp_program}: DHCP client software not available" 32 fi 33} 34 35# Suck in the configuration variables 36# 37if [ -r /etc/defaults/rc.conf ]; then 38 . /etc/defaults/rc.conf 39 source_rc_confs 40elif [ -r /etc/rc.conf ]; then 41 . /etc/rc.conf 42fi 43 44interface=$1 45shift 46startstop=$1 47shift 48 49case ${pccard_ether_delay} in 50[Nn][Oo]) 51 ;; 52[0-9]) 53 sleep ${pccard_ether_delay} 54 ;; 55*) # Default until it has had a chance to make it to /etc/defaults/rc.conf 56 sleep 5 57 ;; 58esac 59 60case ${pccard_ifconfig} in 61[Nn][Oo] | '') 62 expr "${removable_interfaces}" : ".*${interface}" > /dev/null || exit 0 63 ;; 64*) 65 # Backward compatible 66 eval ifconfig_${interface}=\${pccard_ifconfig} 67 ;; 68esac 69 70case ${startstop} in 71[Ss][Tt][Aa][Rr][Tt] | '') 72 if [ -r /etc/start_if.${interface} ]; then 73 . /etc/start_if.${interface} 74 fi 75 76 eval ifconfig_args=\$ifconfig_${interface} 77 case ${ifconfig_args} in 78 [Nn][Oo] | '') 79 ;; 80 [Dd][Hh][Cc][Pp]) 81 # Start up the DHCP client program 82 start_dhcp 83 ;; 84 *) 85 # Do the primary ifconfig if specified 86 ifconfig ${interface} ${ifconfig_args} $* 87 88 # Check to see if aliases need to be added 89 alias=0 90 while : 91 do 92 eval ifx_args=\$ifconfig_${interface}_alias${alias} 93 if [ -n "${ifx_args}" ]; then 94 ifconfig ${interface} ${ifx_args} alias 95 alias=`expr ${alias} + 1` 96 else 97 break; 98 fi 99 done 100 101 # Do ipx address if specified 102 eval ifx_args=\$ifconfig_${interface}_ipx 103 if [ -n "${ifx_args}" ]; then 104 ifconfig ${interface} ${ifx_args} 105 fi 106 107 # Add default route into $static_routes 108 case ${defaultrouter} in 109 [Nn][Oo] | '') 110 ;; 111 *) 112 static_routes="default ${static_routes}" 113 route_default="default ${defaultrouter}" 114 ;; 115 esac 116 117 # Add private route for this interface into $static_routes 118 eval ifx_routes=\$static_routes_${interface} 119 if [ -n "${ifx_routes}" ]; then 120 static_routes="${ifx_routes} ${static_routes}" 121 fi 122 123 # Set up any static routes if specified 124 if [ -n "${static_routes}" ]; then 125 for i in ${static_routes}; do 126 eval route_args=\$route_${i} 127 route add ${route_args} 128 done 129 fi 130 ;; 131 esac 132 133 # IPv6 setup 134 case ${ipv6_enable} in 135 [Yy][Ee][Ss]) 136 if [ -r /etc/rc.network6 ]; then 137 . /etc/rc.network6 138 network6_interface_setup ${interface} 139 fi 140 ;; 141 esac 142 ;; 143# Stop the interface 144*) 145 if [ -r /etc/stop_if.${interface} ]; then 146 . /etc/stop_if.${interface} 147 fi 148 149 eval ifconfig_args=\$ifconfig_${interface} 150 case ${ifconfig_args} in 151 [Nn][Oo] | '') 152 ;; 153 [Dd][Hh][Cc][Pp]) 154 # Stop the DHCP client for this interface 155 stop_dhcp 156 ;; 157 *) 158 # Delelte static route if specified 159 eval ifx_routes=\$static_routes_${interface} 160 if [ -n "${ifx_routes}" ]; then 161 for i in ${ifx_routes}; do 162 eval route_args=\$route_${i} 163 route delete ${route_args} 164 done 165 fi 166 167 # Delete aliases if exist 168 alias=0 169 while : 170 do 171 eval ifx_args=\$ifconfig_${interface}_alias${alias} 172 if [ -n "${ifx_args}" ]; then 173 ifconfig ${interface} ${ifx_args} alias delete 174 alias=`expr ${alias} + 1` 175 else 176 break; 177 fi 178 done 179 ;; 180 esac 181 182 # Remove the network interface and cleaning ARP table 183 ifconfig ${interface} delete 184 arp -d -a 185 186 # Clean the routing table 187 case ${removable_route_flush} in 188 [Nn][Oo]) 189 ;; 190 *) 191 # flush beforehand, just in case.... 192 route -n flush -inet 193 ;; 194 esac 195 ;; 196esac 197