* [gentoo-ppc-dev] Suggestions for net rc scripts
@ 2003-10-03 15:04 Wendell Thomas Duncan
0 siblings, 0 replies; 4+ messages in thread
From: Wendell Thomas Duncan @ 2003-10-03 15:04 UTC (permalink / raw
To: gentoo-ppc-dev; +Cc: Wendell Duncan
If these patch suggestions look good, could a developer forward these
patch ideas for the net.eth0 rc-scripts to the right person.
I just got a new 802.11g base station. I could not see a good way to
get the iwconfig commands executed as part of the /ete/init.d/net.eth1
scripts. Maybe I missed a good tool somewhere, but it makes a lot of
sense to do this stuff in the net.eth0 rc-scripts. These scripts are
part of the baselayout ebuild.
I don't know if the mail-list takes attachments, so I'm putting the
stuff in-line. There are sections of two files following.
First: Changes to the /etc/conf.d/net configuration file -- new options
there. Sample file follows.
=======================================================================
=======================================================================
# /etc/conf.d/net:
# $Header: /home/cvsroot/gentoo-src/rc-scripts/etc/conf.d/net,v 1.7
2002/11/18 19:39:22 azarah Exp $
# Global config file for net.* rc-scripts
# This is basically the ifconfig argument without the ifconfig $iface
#
iface_eth0="192.168.0.107 broadcast 192.168.0.255 netmask 255.255.255.0"
#iface_eth1="207.170.82.202 broadcast 207.0.255.255 netmask 255.255.0.0"
# For DHCP set iface_eth? to "dhcp"
# For passing options to dhcpcd use dhcpcd_eth?
#
#iface_eth0="dhcp"
iface_eth1="dhcp"
#dhcpcd_eth0="..."
# For adding aliases to a interface
#
alias_eth0="192.168.0.108 192.168.0.109"
# NB: The next is only used for aliases.
#
# To add a custom netmask/broadcast address to created aliases,
# uncomment and change accordingly. Leave commented to assign
# defaults for that interface.
#
#broadcast_eth0="192.168.0.255 192.168.0.255"
#netmask_eth0="255.255.255.0 255.255.255.0"
# For setting the default gateway
#
#gateway="eth0/192.168.0.1"
gateway="eth0/192.168.0.1"
# For setting up a wireless connection with iwconfig fill in
# the following fields. To get dhcpcd with WEP encryption
# normally need essid and a key. For dhcpcd usually only
# need essid set. Other fields are usually optional.
# Remember to set dhcp or the ifconfig argument for the
# interface being used (see previous statements in file).
wireless_eth1="yes"
wirelessessid_eth1="CTI"
wirelesskey_eth1="???????????????????"
#wirelessnwid_eth1=""
#wirelessfreq_eth1=""
#wirelesschannel_eth1=""
#wirelesssens_eth1=""
#wirelessmode_eth1=""
#wirelessap_eth1=""
#wirelessnick_eth1=""
#wirelessrate_eth1=""
#wirelessrts_eth1=""
#wirelessfrag_eth1=""
#wirelesstxpower_eth1=""
#wirelessenc_eth1=""
#wirelesspower_eth1=""
#wirelessretry_eth1=""
=====================================================================
=====================================================================
Next is the /etc/init.d/net.eth0 modifications. I did not include
the entire file. The file was unmodified after what I appended.
=====================================================================
=====================================================================
#!/sbin/runscript
# Copyright 1999-2003 Gentoo Technologies, Inc.
# Distributed under the terms of the GNU General Public License v2
# $Header: /home/cvsroot/gentoo-src/rc-scripts/init.d/net.eth0,v 1.31
2003/09/08 00:11:54 azarah Exp $
#NB: Config is in /etc/conf.d/net
# For pcmcia users. note that pcmcia must be added to the same
# runlevel as the net.* script that needs it.
depend() {
use hotplug pcmcia
}
checkconfig() {
if [ -z "${iface_IFACE}" ]
then
eerror "Please make sure that /etc/conf.d/net has \$iface_$IFACE set"
return 1
fi
if [ -n "${vlans}" -a \! -x /sbin/vconfig ]
then
eerror "For VLAN (802.1q) support, emerge net-misc/vconfig"
return 1
fi
}
setup_env() {
# No reason to check these multiple times in the file
iface="${1/\./_}"
iface_IFACE="$(eval echo \$\{iface_${iface}\})"
dhcpcd_IFACE="$(eval echo \$\{dhcpcd_${iface}\})"
inet6_IFACE="$(eval echo \$\{inet6_${iface}\})"
alias_IFACE="$(eval echo \$\{alias_${iface}\})"
status_IFACE="$(ifconfig | gawk -v IFACE="${iface}" '/Link/ { if ($1 ==
IFACE) print "up" }')"
vlans="$(eval echo \$\{iface_${IFACE}_vlans\})"
wireless_IFACE="$(eval echo \$\{wireless_${iface}\})"
wirelessessid_IFACE="$(eval echo \$\{wirelessessid_${iface}\})"
wirelessnwid_IFACE="$(eval echo \$\{wirelessnwid_${iface}\})"
wirelessfreq_IFACE="$(eval echo \$\{wirelessfreq_${iface}\})"
wirelesschannel_IFACE="$(eval echo \$\{wirelesschannel_${iface}\})"
wirelesssens_IFACE="$(eval echo \$\{wirelesssens_${iface}\})"
wirelessmode_IFACE="$(eval echo \$\{wirelessmode_${iface}\})"
wirelessap_IFACE="$(eval echo \$\{wirelessap_${iface}\})"
wirelessnick_IFACE="$(eval echo \$\{wirelessnick_${iface}\})"
wirelessrate_IFACE="$(eval echo \$\{wirelessrate_${iface}\})"
wirelessrts_IFACE="$(eval echo \$\{wirelessrts_${iface}\})"
wirelessfrag_IFACE="$(eval echo \$\{wirelessfrag_${iface}\})"
wirelesstxpower_IFACE="$(eval echo \$\{wirelesstxpower_${iface}\})"
wirelessenc_IFACE="$(eval echo \$\{wirelessenc_${iface}\})"
wirelesskey_IFACE="$(eval echo \$\{wirelesskey_${iface}\})"
wirelesspower_IFACE="$(eval echo \$\{wirelesspower_${iface}\})"
wirelessretry_IFACE="$(eval echo \$\{wirelessretry_${iface}\})"
}
iface_start() {
local retval=0
setup_env ${1}
checkconfig || return 1
local IFACE="${1}"
ebegin "Bringing ${IFACE} up"
if [ "${wireless_IFACE}" = "yes" ]
then
if [ -n "${wirelessessid_IFACE}" ]
then
iwconfig="${iwconfig} essid ${wirelessessid_IFACE}"
fi
if [ -n "${wirelesskey_IFACE}" ]
then
iwconfig="${iwconfig} key ${wirelesskey_IFACE}"
fi
if [ -n "${wirelessnwid_IFACE}" ]
then
iwconfig="${iwconfig} nwid ${wirelessnwid_IFACE}"
fi
if [ -n "${wirelessfreq_IFACE}" ]
then
iwconfig="${iwconfig} freq ${wirelessfreq_IFACE}"
fi
if [ -n "${wirelesschannel_IFACE}" ]
then
iwconfig="${iwconfig} channel ${wirelesschannel_IFACE}"
fi
if [ -n "${wirelesssens_IFACE}" ]
then
iwconfig="${iwconfig} sens ${wirelesssens_IFACE}"
fi
if [ -n "${wirelessmode_IFACE}" ]
then
iwconfig="${iwconfig} mode ${wirelessmode_IFACE}"
fi
if [ -n "${wirelessap_IFACE}" ]
then
iwconfig="${iwconfig} ap ${wirelessap_IFACE}"
fi
if [ -n "${wirelessnick_IFACE}" ]
then
iwconfig="${iwconfig} nick ${wirelessnick_IFACE}"
fi
if [ -n "${wirelessrate_IFACE}" ]
then
iwconfig="${iwconfig} rate ${wirelessrate_IFACE}"
fi
if [ -n "${wirelessrts_IFACE}" ]
then
iwconfig="${iwconfig} rts ${wirelessrts_IFACE}"
fi
if [ -n "${wirelessfrag_IFACE}" ]
then
iwconfig="${iwconfig} frag ${wirelessfrag_IFACE}"
fi
if [ -n "${wirelesstxpower_IFACE}" ]
then
iwconfig="${iwconfig} txpower ${wirelesstxpower_IFACE}"
fi
if [ -n "${wirelessenc_IFACE}" ]
then
iwconfig="${iwconfig} enc ${wirelessenc_IFACE}"
fi
if [ -n "${wirelesspower_IFACE}" ]
then
iwconfig="${iwconfig} power ${wirelesspower_IFACE}"
fi
if [ -n "${wirelessretry_IFACE}" ]
then
iwconfig="${iwconfig} retry ${wirelessretry_IFACE}"
fi
/usr/sbin/iwconfig ${IFACE} ${iwconfig} >/dev/null || {
retval=$?
eend ${retval} "Failed to execute iwconfig on ${IFACE}"
}
fi
========================================================================
========================================================================
A better shell programmer might put all my [ -n "${wireless???}" ]
statements in a loop.
--
Wendell Thomas Duncan <wendell@xmission.com>
--
gentoo-ppc-dev@gentoo.org mailing list
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [gentoo-ppc-dev] Suggestions for net rc scripts
@ 2003-10-06 20:54 Marc Ozon
2003-10-07 1:35 ` Luca Barbato
0 siblings, 1 reply; 4+ messages in thread
From: Marc Ozon @ 2003-10-06 20:54 UTC (permalink / raw
To: gentoo-ppc-dev
Re. Wendell's suggested modifications for the net startup scripts: This is
a good idea, and the suggested script is a bit more complete than the one
suggested here:
http://bugs.gentoo.org/show_bug.cgi?id=25742
(earlier version at http://bugs.gentoo.org/show_bug.cgi?id=16649)
That being done, the Gentoo net configuration still lacks something I wish
it had: a way to handle multiple sets of networking settings, as the
'location' setting in OS X does. As it is, I use multiple runlevels
(similar to what's described at http://www.desertsol.com/~kevin/ppc/#network),
and a simple shell script to switch locations. Doing this, I have a way to
issue the appropriate iwconfig commands for each location: I put them in my
runlevel-switching shell script.
This makes me wonder: since we're thinking about messing with the net.ethX
script, could multiple locations be included somehow? If so, how might this
be done?
In thinking about this, it seems it's still best to use multiple runlevels
for different 'locations', but it would be nice if I didn't need a separate
script to handle it. What I have in mind is something like this: in
/etc/conf.d/net, there could be, e.g., 'multiple_locations=yes', which would
trigger multiple location support in net.ethX. If there are multiple
locations, /etc/conf.d/net could include settings like
'wirelessessid_eth1_home="abc"' and 'wirelessessid_eth1_work="def"', etc.;
then, the net.ethX script might parse that, and apply the appropriate
settings for whatever runlevel (i.e., location) is active, which it could
read from /var/lib/init.d/softlevel. The result would be that switching
runlevels would result in switching network settings, too. This would add
significantly to the complexity of net.ethX, but enough of us might need
multiple location support that the added complexity would be worth it.
What do you think? Would this be a good idea? Is there a better way?
Cheers,
Marc
--- Wendell Thomas Duncan <wendell@xmission.com> [2003-10-03, 11:04]:
> If these patch suggestions look good, could a developer forward these
>patch ideas for the net.eth0 rc-scripts to the right person.
>
> I just got a new 802.11g base station. I could not see a good way to
>get the iwconfig commands executed as part of the /ete/init.d/net.eth1
>scripts. Maybe I missed a good tool somewhere, but it makes a lot of
>sense to do this stuff in the net.eth0 rc-scripts. These scripts are
>part of the baselayout ebuild.
[script stuff snipped]
--
Marc Ozon Toronto, Ontario, Canada
--
gentoo-ppc-dev@gentoo.org mailing list
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [gentoo-ppc-dev] Suggestions for net rc scripts
2003-10-06 20:54 [gentoo-ppc-dev] Suggestions for net rc scripts Marc Ozon
@ 2003-10-07 1:35 ` Luca Barbato
2003-10-07 1:51 ` Erik R. Jensen
0 siblings, 1 reply; 4+ messages in thread
From: Luca Barbato @ 2003-10-07 1:35 UTC (permalink / raw
To: Marc Ozon; +Cc: gentoo-ppc-dev
emerge quickswitch may be useful.
lu
Marc Ozon wrote:
> Re. Wendell's suggested modifications for the net startup scripts: This is
> a good idea, and the suggested script is a bit more complete than the one
> suggested here:
>
> http://bugs.gentoo.org/show_bug.cgi?id=25742
> (earlier version at http://bugs.gentoo.org/show_bug.cgi?id=16649)
>
> That being done, the Gentoo net configuration still lacks something I wish
> it had: a way to handle multiple sets of networking settings, as the
> 'location' setting in OS X does. As it is, I use multiple runlevels
> (similar to what's described at http://www.desertsol.com/~kevin/ppc/#network),
> and a simple shell script to switch locations. Doing this, I have a way to
> issue the appropriate iwconfig commands for each location: I put them in my
> runlevel-switching shell script.
>
> This makes me wonder: since we're thinking about messing with the net.ethX
> script, could multiple locations be included somehow? If so, how might this
> be done?
>
> In thinking about this, it seems it's still best to use multiple runlevels
> for different 'locations', but it would be nice if I didn't need a separate
> script to handle it. What I have in mind is something like this: in
> /etc/conf.d/net, there could be, e.g., 'multiple_locations=yes', which would
> trigger multiple location support in net.ethX. If there are multiple
> locations, /etc/conf.d/net could include settings like
> 'wirelessessid_eth1_home="abc"' and 'wirelessessid_eth1_work="def"', etc.;
> then, the net.ethX script might parse that, and apply the appropriate
> settings for whatever runlevel (i.e., location) is active, which it could
> read from /var/lib/init.d/softlevel. The result would be that switching
> runlevels would result in switching network settings, too. This would add
> significantly to the complexity of net.ethX, but enough of us might need
> multiple location support that the added complexity would be worth it.
>
> What do you think? Would this be a good idea? Is there a better way?
>
> Cheers,
> Marc
>
>
> --- Wendell Thomas Duncan <wendell@xmission.com> [2003-10-03, 11:04]:
>
>> If these patch suggestions look good, could a developer forward these
>>patch ideas for the net.eth0 rc-scripts to the right person.
>>
>> I just got a new 802.11g base station. I could not see a good way to
>>get the iwconfig commands executed as part of the /ete/init.d/net.eth1
>>scripts. Maybe I missed a good tool somewhere, but it makes a lot of
>>sense to do this stuff in the net.eth0 rc-scripts. These scripts are
>>part of the baselayout ebuild.
>
>
> [script stuff snipped]
>
--
Luca Barbato
Developer
Gentoo Linux http://www.gentoo.org/~lu_zero
--
gentoo-ppc-dev@gentoo.org mailing list
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [gentoo-ppc-dev] Suggestions for net rc scripts
2003-10-07 1:35 ` Luca Barbato
@ 2003-10-07 1:51 ` Erik R. Jensen
0 siblings, 0 replies; 4+ messages in thread
From: Erik R. Jensen @ 2003-10-07 1:51 UTC (permalink / raw
To: gentoo-ppc-dev
>> That being done, the Gentoo net configuration still lacks something I
>> wish
>> it had: a way to handle multiple sets of networking settings, as the
>> 'location' setting in OS X does. As it is, I use multiple runlevels
>> (similar to what's described at
>> http://www.desertsol.com/~kevin/ppc/#network),
>> and a simple shell script to switch locations. Doing this, I have a way
>> to
>> issue the appropriate iwconfig commands for each location: I put them
>> in my
>> runlevel-switching shell script.
>>
>> This makes me wonder: since we're thinking about messing with the
>> net.ethX
>> script, could multiple locations be included somehow? If so, how might
>> this
>> be done?
I just wanted to interject I have written a small python application that
handles multiple sets of network settings called NetMonkey. It acts as a
wrapper around the distribution's network tools and configuration files.
It can also interact with the wireless-tools, namely iwconfig to setup
wirless card settings. It currently works on gentoo and I was going to add
debian support later next week.
I created it because I needed a fast way to switch networks without
editing /etc/conf.d/net and messing with iwconfig trying to remeber wep
keys. I was also really bored. If anyone is intersted I have it in cvs and
can it can be downloaded via viewcvs at:
https://dev.netradius.com/0xf00/viewcvs.cgi/NetMonkey/
It works for what I need right now, but I it may not be robust enough for
others. I am always up for ideas and new features to add.
Erik R. Jensen
--
gentoo-ppc-dev@gentoo.org mailing list
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2003-10-07 1:51 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-10-06 20:54 [gentoo-ppc-dev] Suggestions for net rc scripts Marc Ozon
2003-10-07 1:35 ` Luca Barbato
2003-10-07 1:51 ` Erik R. Jensen
-- strict thread matches above, loose matches on Subject: below --
2003-10-03 15:04 Wendell Thomas Duncan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox