pccard_ether revision 76045
1#!/bin/sh - 2# 3# $FreeBSD: head/etc/pccard_ether 76045 2001-04-26 17:33:37Z ume $ 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_ifconfig} in 50[Nn][Oo] | '') 51 expr "${removable_interfaces}" : ".*${interface}" > /dev/null || exit 0 52 ;; 53*) 54 # Backward compatible 55 eval ifconfig_${interface}=\${pccard_ifconfig} 56 ;; 57esac 58 59case ${startstop} in 60[Ss][Tt][Aa][Rr][Tt] | '') 61 if [ -r /etc/start_if.${interface} ]; then 62 . /etc/start_if.${interface} 63 fi 64 65 eval ifconfig_args=\$ifconfig_${interface} 66 case ${ifconfig_args} in 67 [Nn][Oo] | '') 68 ;; 69 [Dd][Hh][Cc][Pp]) 70 # Start up the DHCP client program 71 start_dhcp 72 ;; 73 *) 74 # Do the primary ifconfig if specified 75 ifconfig ${interface} ${ifconfig_args} $* 76 77 # Check to see if aliases need to be added 78 alias=0 79 while : 80 do 81 eval ifx_args=\$ifconfig_${interface}_alias${alias} 82 if [ -n "${ifx_args}" ]; then 83 ifconfig ${interface} ${ifx_args} alias 84 alias=`expr ${alias} + 1` 85 else 86 break; 87 fi 88 done 89 90 # Do ipx address if specified 91 eval ifx_args=\$ifconfig_${interface}_ipx 92 if [ -n "${ifx_args}" ]; then 93 ifconfig ${interface} ${ifx_args} 94 fi 95 96 # Add default route into $static_routes 97 case ${defaultrouter} in 98 [Nn][Oo] | '') 99 ;; 100 *) 101 static_routes="default ${static_routes}" 102 route_default="default ${defaultrouter}" 103 ;; 104 esac 105 106 # Add private route for this interface into $static_routes 107 eval ifx_routes=\$static_routes_${interface} 108 if [ -n "${ifx_routes}" ]; then 109 static_routes="${ifx_routes} ${static_routes}" 110 fi 111 112 # Set up any static routes if specified 113 if [ -n "${static_routes}" ]; then 114 for i in ${static_routes}; do 115 eval route_args=\$route_${i} 116 route add ${route_args} 117 done 118 fi 119 ;; 120 esac 121 122 # IPv6 setup 123 case ${ipv6_enable} in 124 [Yy][Ee][Ss]) 125 if [ -r /etc/rc.network6 ]; then 126 . /etc/rc.network6 127 network6_interface_setup ${interface} 128 fi 129 ;; 130 esac 131 ;; 132# Stop the interface 133*) 134 if [ -r /etc/stop_if.${interface} ]; then 135 . /etc/stop_if.${interface} 136 fi 137 138 eval ifconfig_args=\$ifconfig_${interface} 139 case ${ifconfig_args} in 140 [Nn][Oo] | '') 141 ;; 142 [Dd][Hh][Cc][Pp]) 143 # Stop the DHCP client for this interface 144 stop_dhcp 145 ;; 146 *) 147 # Delelte static route if specified 148 eval ifx_routes=\$static_routes_${interface} 149 if [ -n "${ifx_routes}" ]; then 150 for i in ${ifx_routes}; do 151 eval route_args=\$route_${i} 152 route delete ${route_args} 153 done 154 fi 155 156 # Delete aliases if exist 157 alias=0 158 while : 159 do 160 eval ifx_args=\$ifconfig_${interface}_alias${alias} 161 if [ -n "${ifx_args}" ]; then 162 ifconfig ${interface} ${ifx_args} alias delete 163 alias=`expr ${alias} + 1` 164 else 165 break; 166 fi 167 done 168 ;; 169 esac 170 171 # Remove the network interface and cleaning ARP table 172 ifconfig ${interface} delete 173 arp -d -a 174 175 # Clean the routing table 176 case ${removable_route_flush} in 177 [Nn][Oo]) 178 ;; 179 *) 180 # flush beforehand, just in case.... 181 route -n flush 182 ;; 183 esac 184 ;; 185esac 186