pccard_ether revision 70349
1#!/bin/sh - 2# 3# $FreeBSD: head/etc/pccard_ether 70349 2000-12-25 09:21:18Z toshi $ 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 case ${ipv6_gateway_enable} in 126 [Yy][Ee][Ss]) 127 ;; 128 *) 129 sysctl -w net.inet6.ip6.forwarding=0 130 sysctl -w net.inet6.ip6.accept_rtadv=1 131 ifconfig ${interface} up 132 rtsol ${interface} 133 ;; 134 esac 135 ;; 136 esac 137 ;; 138# Stop the interface 139*) 140 if [ -r /etc/stop_if.${interface} ]; then 141 . /etc/stop_if.${interface} 142 fi 143 144 eval ifconfig_args=\$ifconfig_${interface} 145 case ${ifconfig_args} in 146 [Nn][Oo] | '') 147 ;; 148 [Dd][Hh][Cc][Pp]) 149 # Stop the DHCP client for this interface 150 stop_dhcp 151 ;; 152 *) 153 # Delelte static route if specified 154 eval ifx_routes=\$static_routes_${interface} 155 if [ -n "${ifx_routes}" ]; then 156 for i in ${ifx_routes}; do 157 eval route_args=\$route_${i} 158 route delete ${route_args} 159 done 160 fi 161 162 # Delete aliases if exist 163 alias=0 164 while : 165 do 166 eval ifx_args=\$ifconfig_${interface}_alias${alias} 167 if [ -n "${ifx_args}" ]; then 168 ifconfig ${interface} ${ifx_args} alias delete 169 alias=`expr ${alias} + 1` 170 else 171 break; 172 fi 173 done 174 ;; 175 esac 176 177 # Remove the network interface and cleaning ARP table 178 ifconfig ${interface} delete 179 arp -d -a 180 181 # Clean the routing table 182 case ${removable_route_flush} in 183 [Nn][Oo]) 184 ;; 185 *) 186 # flush beforehand, just in case.... 187 route -n flush 188 ;; 189 esac 190 ;; 191esac 192