Preliminary syscall messaging work. Adjust all <syscall>_args structures
[dragonfly.git] / etc / pccard_ether
CommitLineData
984263bc
MD
1#!/bin/sh -
2#
3# $FreeBSD: src/etc/pccard_ether,v 1.15.2.10 2001/09/14 17:28:11 imp Exp $
1de703da 4# $DragonFly: src/etc/pccard_ether,v 1.2 2003/06/17 04:24:45 dillon Exp $
984263bc
MD
5#
6# pccard_ether interfacename [start|stop] [ifconfig option]
7#
8# example: pccard_ether ep0 start -link0
9#
10
11stop_dhcp() {
12 if [ -s /var/run/dhclient.${interface}.pid ]; then
13 pidfile="/var/run/dhclient.${interface}.pid"
14 elif [ -s /var/run/dhcpc.${interface}.pid ]; then
15 pidfile="/var/run/dhcpc.${interface}.pid"
16 else
17 return
18 fi
19 kill `cat ${pidfile}`
20 rm -f ${pidfile}
21}
22
23start_dhcp() {
24 stop_dhcp
25 if [ -x "${dhcp_program}" ]; then
26 if [ `basename ${dhcp_program}` = "dhclient" ]; then
27 pidfile="/var/run/dhclient.${interface}.pid"
28 dhcp_flags="${dhcp_flags} -pf ${pidfile}"
29 fi
30 ${dhcp_program} ${dhcp_flags} ${interface}
31 else
32 echo "${dhcp_program}: DHCP client software not available"
33 fi
34}
35
36# Suck in the configuration variables
37#
38if [ -r /etc/defaults/rc.conf ]; then
39 . /etc/defaults/rc.conf
40 source_rc_confs
41elif [ -r /etc/rc.conf ]; then
42 . /etc/rc.conf
43fi
44
45interface=$1
46shift
47startstop=$1
48shift
49
50case ${pccard_ether_delay} in
51[Nn][Oo])
52 ;;
53[0-9])
54 sleep ${pccard_ether_delay}
55 ;;
56*) # Default until it has had a chance to make it to /etc/defaults/rc.conf
57 sleep 5
58 ;;
59esac
60
61case ${pccard_ifconfig} in
62[Nn][Oo] | '')
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 clean the ARP table
183 ifconfig ${interface} delete
184 arp -d -a
185 ;;
186esac