5 # pccard_ether interfacename [start|stop] [ifconfig option]
7 # example: pccard_ether fxp0 start link0
13 # If dhclient is already running, record
15 if [ -x /usr/bin/grep ]; then
16 eval _active_list=\"`/bin/ps -axwww | \
17 /usr/bin/grep dhclient | \
18 /usr/bin/grep -v grep | \
19 /usr/bin/sed -e 's|^.*dhclient||' | \
20 /usr/bin/awk '{for (i=1;i<=NF;i++) \
21 { if ($i~/[a-zA-Z].[0-9]$/) \
22 { printf(" %s",$i) } }}'` \
26 # Get the rc.conf list of dhcp configured interfaces
27 static_dhcp_list="`list_net_interfaces dhcp`"
29 # Get the current ifconfig list of interfaces
32 for _if in ${_active_list} ; do
33 _test_if=`ifconfig ${_if} 2>&1`
35 "ifconfig: interface $_if does not exist")
38 # Don't record the same device twice.
42 # Catch devices which were specified before,
43 # but have not been part of the rc. We need
44 # them again for the restart.
46 for _cif in ${static_dhcp_list} ; do
52 # Found interface beside rc.conf
53 _nlist="${_nlist}${_aprefix}${_if}"
57 _dhcplist="${_dhcplist}${_aprefix}${_if}"
58 [ -z "$_aprefix" ] && _aprefix=' '
63 if [ -s /var/run/dhclient.pid ]; then
64 pidfile="/var/run/dhclient.pid"
68 /sbin/dhclient -r ${interface}
72 if [ -z "${_nlist}" ]; then
73 sh `/etc/rc.d/dhclient start`
75 start_dhcp_keep_current
85 case ${pccard_ether_delay} in
89 sleep ${pccard_ether_delay}
92 [ -n "$dhcp_program" ] && dhclient_program="$dhcp_program"
93 [ -n "$dhcp_flags" ] && dhclient_flags="$dhcp_flags"
94 if [ -x "${dhclient_program}" ]; then
95 interfaces=`echo $_dhcplist ${interface} | xargs -n 1 echo | sort -u`
96 ${dhclient_program} ${dhclient_flags} ${interfaces}
98 echo "${dhclient_program}: DHCP client software not available"
102 # Called after detaching a card, if dhclient has been
103 # used for more than one interface.
104 start_dhcp_keep_current() {
105 [ -n "$dhcp_program" ] && dhclient_program="$dhcp_program"
106 [ -n "$dhcp_flags" ] && dhclient_flags="$dhcp_flags"
107 if [ -x "${dhclient_program}" ]; then
108 ${dhclient_program} ${dhclient_flags} \
111 echo "${dhclient_program}: DHCP client software not available"
115 # Suck in the configuration variables
117 if [ -r /etc/defaults/rc.conf ]; then
118 . /etc/defaults/rc.conf
120 elif [ -r /etc/rc.conf ]; then
129 case ${pccard_ifconfig} in
131 expr "${removable_interfaces}" : ".*${interface}" > /dev/null || exit 0
134 # Backward compatible
135 eval ifconfig_${interface}=\${pccard_ifconfig}
140 [Ss][Tt][Aa][Rr][Tt] | '')
141 if [ -x /usr/bin/grep ]; then
142 if ifconfig ${interface} | grep -s netmask > /dev/null 2>&1; then
143 # Interface is already up, so ignore it.
148 if [ -r /etc/start_if.${interface} ]; then
149 . /etc/start_if.${interface}
152 eval ifconfig_args=\$ifconfig_${interface}
153 case ${ifconfig_args} in
157 # Start up the DHCP client program
161 # Do the primary ifconfig if specified
162 ifconfig ${interface} ${ifconfig_args} $*
164 # Check to see if aliases need to be added
168 eval ifx_args=\$ifconfig_${interface}_alias${alias}
169 if [ -n "${ifx_args}" ]; then
170 ifconfig ${interface} ${ifx_args} alias
171 alias=`expr ${alias} + 1`
177 # Do ipx address if specified
178 eval ifx_args=\$ifconfig_${interface}_ipx
179 if [ -n "${ifx_args}" ]; then
180 ifconfig ${interface} ${ifx_args}
183 # Add default route into $static_routes
184 case ${defaultrouter} in
188 static_routes="default ${static_routes}"
189 route_default="default ${defaultrouter}"
193 # Add private route for this interface into $static_routes
194 eval ifx_routes=\$static_routes_${interface}
195 if [ -n "${ifx_routes}" ]; then
196 static_routes="${ifx_routes} ${static_routes}"
199 # Set up any static routes if specified
200 if [ -n "${static_routes}" ]; then
201 for i in ${static_routes}; do
202 eval route_args=\$route_${i}
203 route add ${route_args}
210 case ${ipv6_enable} in
212 if [ -r /etc/network.subr ]; then
214 network6_interface_setup ${interface}
221 if [ -r /etc/stop_if.${interface} ]; then
222 . /etc/stop_if.${interface}
225 eval ifconfig_args=\$ifconfig_${interface}
226 case ${ifconfig_args} in
230 # Stop the DHCP client for this interface
234 # Delete static route if specified
235 eval ifx_routes=\$static_routes_${interface}
236 if [ -n "${ifx_routes}" ]; then
237 for i in ${ifx_routes}; do
238 eval route_args=\$route_${i}
239 route delete ${route_args}
243 # Delete aliases if exist
247 eval ifx_args=\$ifconfig_${interface}_alias${alias}
248 if [ -n "${ifx_args}" ]; then
249 ifconfig ${interface} ${ifx_args} alias delete
250 alias=`expr ${alias} + 1`
258 # Remove the network interface and cleaning ARP table
259 ifconfig ${interface} delete
262 # Clean the routing table
263 case ${removable_route_flush} in
267 # flush beforehand, just in case....