pccard_ether revision 107761
111891Speter#!/bin/sh - 211891Speter# 311891Speter# $FreeBSD: head/etc/pccard_ether 107761 2002-12-11 23:30:34Z imp $ 411891Speter# 511891Speter# pccard_ether interfacename [start|stop] [ifconfig option] 611891Speter# 711891Speter# example: pccard_ether ep0 start -link0 811891Speter# 911891Speter 1011891Speterstop_dhcp() { 1111891Speter if [ -s /var/run/dhclient.${interface}.pid ]; then 1211891Speter pidfile="/var/run/dhclient.${interface}.pid" 1311891Speter elif [ -s /var/run/dhcpc.${interface}.pid ]; then 1411891Speter pidfile="/var/run/dhcpc.${interface}.pid" 1511891Speter else 1611891Speter return 1711891Speter fi 1811891Speter kill `cat ${pidfile}` 1911891Speter rm -f ${pidfile} 2011891Speter} 2111891Speter 2211891Speterstart_dhcp() { 2311891Speter stop_dhcp 2411891Speter case ${pccard_ether_delay} in 2511891Speter [Nn][Oo]) 2611891Speter ;; 2711891Speter [0-9]) 2811891Speter sleep ${pccard_ether_delay} 2911891Speter ;; 3011891Speter esac 3111891Speter if [ -x "${dhcp_program}" ]; then 3211891Speter if [ `basename ${dhcp_program}` = "dhclient" ]; then 3311891Speter pidfile="/var/run/dhclient.${interface}.pid" 3411891Speter dhcp_flags="${dhcp_flags} -pf ${pidfile}" 3511891Speter fi 3611891Speter ${dhcp_program} ${dhcp_flags} ${interface} 3711891Speter else 3811891Speter echo "${dhcp_program}: DHCP client software not available" 3911891Speter fi 4011891Speter} 4111891Speter 4211891Speter# Suck in the configuration variables 4311891Speter# 4411891Speterif [ -r /etc/defaults/rc.conf ]; then 4511891Speter . /etc/defaults/rc.conf 4611891Speter source_rc_confs 4711891Speterelif [ -r /etc/rc.conf ]; then 4811891Speter . /etc/rc.conf 4911891Speterfi 5011891Speter 5111891Speterinterface=$1 5211891Spetershift 5311891Speterstartstop=$1 5411891Spetershift 5511891Speter 5611891Spetercase ${pccard_ifconfig} in 5711891Speter[Nn][Oo] | '') 5811891Speter expr "${removable_interfaces}" : ".*${interface}" > /dev/null || exit 0 5911891Speter ;; 6011891Speter*) 6111891Speter # Backward compatible 6211891Speter eval ifconfig_${interface}=\${pccard_ifconfig} 6311891Speter ;; 6411891Speteresac 6511891Speter 6611891Spetercase ${startstop} in 6711891Speter[Ss][Tt][Aa][Rr][Tt] | '') 6811891Speter if ifconfig ${interface} | grep -s UP,; then 6911891Speter # Interface is already up, so ignore it. 7011891Speter exit 0 7111891Speter fi 72 73 if [ -r /etc/start_if.${interface} ]; then 74 . /etc/start_if.${interface} 75 fi 76 77 eval ifconfig_args=\$ifconfig_${interface} 78 case ${ifconfig_args} in 79 [Nn][Oo] | '') 80 ;; 81 [Dd][Hh][Cc][Pp]) 82 # Start up the DHCP client program 83 start_dhcp 84 ;; 85 *) 86 # Do the primary ifconfig if specified 87 ifconfig ${interface} ${ifconfig_args} $* 88 89 # Check to see if aliases need to be added 90 alias=0 91 while : 92 do 93 eval ifx_args=\$ifconfig_${interface}_alias${alias} 94 if [ -n "${ifx_args}" ]; then 95 ifconfig ${interface} ${ifx_args} alias 96 alias=`expr ${alias} + 1` 97 else 98 break; 99 fi 100 done 101 102 # Do ipx address if specified 103 eval ifx_args=\$ifconfig_${interface}_ipx 104 if [ -n "${ifx_args}" ]; then 105 ifconfig ${interface} ${ifx_args} 106 fi 107 108 # Add default route into $static_routes 109 case ${defaultrouter} in 110 [Nn][Oo] | '') 111 ;; 112 *) 113 static_routes="default ${static_routes}" 114 route_default="default ${defaultrouter}" 115 ;; 116 esac 117 118 # Add private route for this interface into $static_routes 119 eval ifx_routes=\$static_routes_${interface} 120 if [ -n "${ifx_routes}" ]; then 121 static_routes="${ifx_routes} ${static_routes}" 122 fi 123 124 # Set up any static routes if specified 125 if [ -n "${static_routes}" ]; then 126 for i in ${static_routes}; do 127 eval route_args=\$route_${i} 128 route add ${route_args} 129 done 130 fi 131 ;; 132 esac 133 134 # IPv6 setup 135 case ${ipv6_enable} in 136 [Yy][Ee][Ss]) 137 if [ -r /etc/rc.network6 ]; then 138 . /etc/rc.network6 139 network6_interface_setup ${interface} 140 fi 141 ;; 142 esac 143 ;; 144# Stop the interface 145*) 146 if [ -r /etc/stop_if.${interface} ]; then 147 . /etc/stop_if.${interface} 148 fi 149 150 eval ifconfig_args=\$ifconfig_${interface} 151 case ${ifconfig_args} in 152 [Nn][Oo] | '') 153 ;; 154 [Dd][Hh][Cc][Pp]) 155 # Stop the DHCP client for this interface 156 stop_dhcp 157 ;; 158 *) 159 # Delelte static route if specified 160 eval ifx_routes=\$static_routes_${interface} 161 if [ -n "${ifx_routes}" ]; then 162 for i in ${ifx_routes}; do 163 eval route_args=\$route_${i} 164 route delete ${route_args} 165 done 166 fi 167 168 # Delete aliases if exist 169 alias=0 170 while : 171 do 172 eval ifx_args=\$ifconfig_${interface}_alias${alias} 173 if [ -n "${ifx_args}" ]; then 174 ifconfig ${interface} ${ifx_args} alias delete 175 alias=`expr ${alias} + 1` 176 else 177 break; 178 fi 179 done 180 ;; 181 esac 182 183 # Remove the network interface and cleaning ARP table 184 ifconfig ${interface} delete 185 arp -d -a 186 187 # Clean the routing table 188 case ${removable_route_flush} in 189 [Nn][Oo]) 190 ;; 191 *) 192 # flush beforehand, just in case.... 193 route -n flush -inet 194 ;; 195 esac 196 ;; 197esac 198