1 |
If these patch suggestions look good, could a developer forward these |
2 |
patch ideas for the net.eth0 rc-scripts to the right person. |
3 |
|
4 |
|
5 |
I just got a new 802.11g base station. I could not see a good way to |
6 |
get the iwconfig commands executed as part of the /ete/init.d/net.eth1 |
7 |
scripts. Maybe I missed a good tool somewhere, but it makes a lot of |
8 |
sense to do this stuff in the net.eth0 rc-scripts. These scripts are |
9 |
part of the baselayout ebuild. |
10 |
|
11 |
I don't know if the mail-list takes attachments, so I'm putting the |
12 |
stuff in-line. There are sections of two files following. |
13 |
|
14 |
First: Changes to the /etc/conf.d/net configuration file -- new options |
15 |
there. Sample file follows. |
16 |
|
17 |
======================================================================= |
18 |
======================================================================= |
19 |
|
20 |
# /etc/conf.d/net: |
21 |
# $Header: /home/cvsroot/gentoo-src/rc-scripts/etc/conf.d/net,v 1.7 |
22 |
2002/11/18 19:39:22 azarah Exp $ |
23 |
|
24 |
# Global config file for net.* rc-scripts |
25 |
|
26 |
# This is basically the ifconfig argument without the ifconfig $iface |
27 |
# |
28 |
iface_eth0="192.168.0.107 broadcast 192.168.0.255 netmask 255.255.255.0" |
29 |
#iface_eth1="207.170.82.202 broadcast 207.0.255.255 netmask 255.255.0.0" |
30 |
|
31 |
# For DHCP set iface_eth? to "dhcp" |
32 |
# For passing options to dhcpcd use dhcpcd_eth? |
33 |
# |
34 |
#iface_eth0="dhcp" |
35 |
iface_eth1="dhcp" |
36 |
#dhcpcd_eth0="..." |
37 |
|
38 |
# For adding aliases to a interface |
39 |
# |
40 |
alias_eth0="192.168.0.108 192.168.0.109" |
41 |
|
42 |
# NB: The next is only used for aliases. |
43 |
# |
44 |
# To add a custom netmask/broadcast address to created aliases, |
45 |
# uncomment and change accordingly. Leave commented to assign |
46 |
# defaults for that interface. |
47 |
# |
48 |
#broadcast_eth0="192.168.0.255 192.168.0.255" |
49 |
#netmask_eth0="255.255.255.0 255.255.255.0" |
50 |
|
51 |
|
52 |
# For setting the default gateway |
53 |
# |
54 |
#gateway="eth0/192.168.0.1" |
55 |
gateway="eth0/192.168.0.1" |
56 |
|
57 |
# For setting up a wireless connection with iwconfig fill in |
58 |
# the following fields. To get dhcpcd with WEP encryption |
59 |
# normally need essid and a key. For dhcpcd usually only |
60 |
# need essid set. Other fields are usually optional. |
61 |
# Remember to set dhcp or the ifconfig argument for the |
62 |
# interface being used (see previous statements in file). |
63 |
wireless_eth1="yes" |
64 |
wirelessessid_eth1="CTI" |
65 |
wirelesskey_eth1="???????????????????" |
66 |
#wirelessnwid_eth1="" |
67 |
#wirelessfreq_eth1="" |
68 |
#wirelesschannel_eth1="" |
69 |
#wirelesssens_eth1="" |
70 |
#wirelessmode_eth1="" |
71 |
#wirelessap_eth1="" |
72 |
#wirelessnick_eth1="" |
73 |
#wirelessrate_eth1="" |
74 |
#wirelessrts_eth1="" |
75 |
#wirelessfrag_eth1="" |
76 |
#wirelesstxpower_eth1="" |
77 |
#wirelessenc_eth1="" |
78 |
#wirelesspower_eth1="" |
79 |
#wirelessretry_eth1="" |
80 |
|
81 |
===================================================================== |
82 |
===================================================================== |
83 |
|
84 |
Next is the /etc/init.d/net.eth0 modifications. I did not include |
85 |
the entire file. The file was unmodified after what I appended. |
86 |
|
87 |
|
88 |
===================================================================== |
89 |
===================================================================== |
90 |
|
91 |
#!/sbin/runscript |
92 |
# Copyright 1999-2003 Gentoo Technologies, Inc. |
93 |
# Distributed under the terms of the GNU General Public License v2 |
94 |
# $Header: /home/cvsroot/gentoo-src/rc-scripts/init.d/net.eth0,v 1.31 |
95 |
2003/09/08 00:11:54 azarah Exp $ |
96 |
|
97 |
#NB: Config is in /etc/conf.d/net |
98 |
|
99 |
|
100 |
# For pcmcia users. note that pcmcia must be added to the same |
101 |
# runlevel as the net.* script that needs it. |
102 |
depend() { |
103 |
use hotplug pcmcia |
104 |
} |
105 |
|
106 |
checkconfig() { |
107 |
if [ -z "${iface_IFACE}" ] |
108 |
then |
109 |
eerror "Please make sure that /etc/conf.d/net has \$iface_$IFACE set" |
110 |
return 1 |
111 |
fi |
112 |
if [ -n "${vlans}" -a \! -x /sbin/vconfig ] |
113 |
then |
114 |
eerror "For VLAN (802.1q) support, emerge net-misc/vconfig" |
115 |
return 1 |
116 |
fi |
117 |
|
118 |
} |
119 |
|
120 |
setup_env() { |
121 |
# No reason to check these multiple times in the file |
122 |
iface="${1/\./_}" |
123 |
iface_IFACE="$(eval echo \$\{iface_${iface}\})" |
124 |
dhcpcd_IFACE="$(eval echo \$\{dhcpcd_${iface}\})" |
125 |
inet6_IFACE="$(eval echo \$\{inet6_${iface}\})" |
126 |
alias_IFACE="$(eval echo \$\{alias_${iface}\})" |
127 |
status_IFACE="$(ifconfig | gawk -v IFACE="${iface}" '/Link/ { if ($1 == |
128 |
IFACE) print "up" }')" |
129 |
vlans="$(eval echo \$\{iface_${IFACE}_vlans\})" |
130 |
wireless_IFACE="$(eval echo \$\{wireless_${iface}\})" |
131 |
wirelessessid_IFACE="$(eval echo \$\{wirelessessid_${iface}\})" |
132 |
wirelessnwid_IFACE="$(eval echo \$\{wirelessnwid_${iface}\})" |
133 |
wirelessfreq_IFACE="$(eval echo \$\{wirelessfreq_${iface}\})" |
134 |
wirelesschannel_IFACE="$(eval echo \$\{wirelesschannel_${iface}\})" |
135 |
wirelesssens_IFACE="$(eval echo \$\{wirelesssens_${iface}\})" |
136 |
wirelessmode_IFACE="$(eval echo \$\{wirelessmode_${iface}\})" |
137 |
wirelessap_IFACE="$(eval echo \$\{wirelessap_${iface}\})" |
138 |
wirelessnick_IFACE="$(eval echo \$\{wirelessnick_${iface}\})" |
139 |
wirelessrate_IFACE="$(eval echo \$\{wirelessrate_${iface}\})" |
140 |
wirelessrts_IFACE="$(eval echo \$\{wirelessrts_${iface}\})" |
141 |
wirelessfrag_IFACE="$(eval echo \$\{wirelessfrag_${iface}\})" |
142 |
wirelesstxpower_IFACE="$(eval echo \$\{wirelesstxpower_${iface}\})" |
143 |
wirelessenc_IFACE="$(eval echo \$\{wirelessenc_${iface}\})" |
144 |
wirelesskey_IFACE="$(eval echo \$\{wirelesskey_${iface}\})" |
145 |
wirelesspower_IFACE="$(eval echo \$\{wirelesspower_${iface}\})" |
146 |
wirelessretry_IFACE="$(eval echo \$\{wirelessretry_${iface}\})" |
147 |
} |
148 |
|
149 |
iface_start() { |
150 |
local retval=0 |
151 |
|
152 |
setup_env ${1} |
153 |
checkconfig || return 1 |
154 |
|
155 |
local IFACE="${1}" |
156 |
ebegin "Bringing ${IFACE} up" |
157 |
|
158 |
if [ "${wireless_IFACE}" = "yes" ] |
159 |
then |
160 |
if [ -n "${wirelessessid_IFACE}" ] |
161 |
then |
162 |
iwconfig="${iwconfig} essid ${wirelessessid_IFACE}" |
163 |
fi |
164 |
|
165 |
if [ -n "${wirelesskey_IFACE}" ] |
166 |
then |
167 |
iwconfig="${iwconfig} key ${wirelesskey_IFACE}" |
168 |
fi |
169 |
|
170 |
if [ -n "${wirelessnwid_IFACE}" ] |
171 |
then |
172 |
iwconfig="${iwconfig} nwid ${wirelessnwid_IFACE}" |
173 |
fi |
174 |
|
175 |
if [ -n "${wirelessfreq_IFACE}" ] |
176 |
then |
177 |
iwconfig="${iwconfig} freq ${wirelessfreq_IFACE}" |
178 |
fi |
179 |
|
180 |
if [ -n "${wirelesschannel_IFACE}" ] |
181 |
then |
182 |
iwconfig="${iwconfig} channel ${wirelesschannel_IFACE}" |
183 |
fi |
184 |
|
185 |
if [ -n "${wirelesssens_IFACE}" ] |
186 |
then |
187 |
iwconfig="${iwconfig} sens ${wirelesssens_IFACE}" |
188 |
fi |
189 |
|
190 |
if [ -n "${wirelessmode_IFACE}" ] |
191 |
then |
192 |
iwconfig="${iwconfig} mode ${wirelessmode_IFACE}" |
193 |
fi |
194 |
|
195 |
if [ -n "${wirelessap_IFACE}" ] |
196 |
then |
197 |
iwconfig="${iwconfig} ap ${wirelessap_IFACE}" |
198 |
fi |
199 |
|
200 |
if [ -n "${wirelessnick_IFACE}" ] |
201 |
then |
202 |
iwconfig="${iwconfig} nick ${wirelessnick_IFACE}" |
203 |
fi |
204 |
|
205 |
if [ -n "${wirelessrate_IFACE}" ] |
206 |
then |
207 |
iwconfig="${iwconfig} rate ${wirelessrate_IFACE}" |
208 |
fi |
209 |
|
210 |
if [ -n "${wirelessrts_IFACE}" ] |
211 |
then |
212 |
iwconfig="${iwconfig} rts ${wirelessrts_IFACE}" |
213 |
fi |
214 |
|
215 |
if [ -n "${wirelessfrag_IFACE}" ] |
216 |
then |
217 |
iwconfig="${iwconfig} frag ${wirelessfrag_IFACE}" |
218 |
fi |
219 |
|
220 |
if [ -n "${wirelesstxpower_IFACE}" ] |
221 |
then |
222 |
iwconfig="${iwconfig} txpower ${wirelesstxpower_IFACE}" |
223 |
fi |
224 |
|
225 |
if [ -n "${wirelessenc_IFACE}" ] |
226 |
then |
227 |
iwconfig="${iwconfig} enc ${wirelessenc_IFACE}" |
228 |
fi |
229 |
|
230 |
if [ -n "${wirelesspower_IFACE}" ] |
231 |
then |
232 |
iwconfig="${iwconfig} power ${wirelesspower_IFACE}" |
233 |
fi |
234 |
|
235 |
if [ -n "${wirelessretry_IFACE}" ] |
236 |
then |
237 |
iwconfig="${iwconfig} retry ${wirelessretry_IFACE}" |
238 |
fi |
239 |
|
240 |
/usr/sbin/iwconfig ${IFACE} ${iwconfig} >/dev/null || { |
241 |
retval=$? |
242 |
eend ${retval} "Failed to execute iwconfig on ${IFACE}" |
243 |
} |
244 |
fi |
245 |
|
246 |
|
247 |
======================================================================== |
248 |
======================================================================== |
249 |
|
250 |
A better shell programmer might put all my [ -n "${wireless???}" ] |
251 |
statements in a loop. |
252 |
|
253 |
|
254 |
-- |
255 |
Wendell Thomas Duncan <wendell@××××××××.com> |
256 |
|
257 |
-- |
258 |
gentoo-ppc-dev@g.o mailing list |