Gentoo wireless - My way
I have just finished a little script, which runs on top of the gentoo net.* initscripts. It gives you the opportunity to configure your wifi device using a folder filled with different small configfiles instead of a complicated big one, which is hard to manage.
You may ask, why should somebody change the gentoo way of initializing the wifi device. The main reason for changing the standard behaviour was my need to execute different programs after establishing connections to different accesspoints. At first I used one postup function combined with a case statement in the monolithic wireless conf to associate a special ap with some commands to be executed after the defined ap has been found.
This solution to the problem seemed quite useful, but as the number of accesspoints started growing it got really hard to keep track of all the different commands and configurations. Because of this I splitted the configfiles. I did not want to reinvent the wheel, therefore I wrote a little wrapper to read the defined values into the gentoo net initscripts instead of doing the whole initializiation on my own.
For using this in your system just do the following:
Create a directory called wireless.d in /etc/conf.d.
Create a configfile for every accesspoint in this directory. The file has to be called exactly like the essid of the accesspoint. You can use every configparameter the gentoo net initscript supports in combination with the essid, eg. config_YOUR_ESSID=( "dhcp" ) could be used. Hence the wrapper gets the essid out of the filename you can omit this part of the variablename.
Another nice feature is the opportunity to define a postup function in every "configfile". There you could execute any shell command you need. For example you could initialize a vpn client here or establish any connection you always need after the netinit.
Here is a simple essid configfile:
key="YOUR WEPKEY HERE" config=( "10.0.3.4 netmask 255.255.255.0" ) routes=( "default via 10.0.3.1" ) dns_servers=( "10.0.1.1" ) postup() { ebegin "Running Racoon to initialize the vpn" source /etc/conf.d/racoon /usr/sbin/setkey -f ${SETKEY_CONF} /usr/sbin/racoon -f ${RACOON_CONF} ${RACOON_OPTS} eend $? }This is the config I am using for my wifi connection at home. The file is saved as /etc/conf.d/wireless.d/Exiel
The essid of my accesspoint is, as you have already discovered, "Exiel".
As you can see it is really easy to use this wifi wrapper.
You have to install the configwrapper script. Just download the script and save it as as /etc/conf.d/net
Change the WIRELESSDEVICE variable to the name of your wifi device and add net.ath0 (or whatever your card is called) to your default bootlevel.
$ rc-update add net.ath0 default
Now you are ready to enjoy your new essid file based wlan configuration.
I am not sure if this script works on every system with every gentoo baselayout. I have tested it on my system, where it works great. If it's not doing what it's supposed to, send me an email or comment on this entry.
Trackbacks
Comments
-
Toby on Sun, 16 Jul 2006 17:09:00 +0200
Nice script!
Link to comment
Anyway, there is a bug. One of my ESSIDs is named 'FRITZ!Box WLAN 3030'. The '!' seems to bork the script, since it is not escaped. The output shows:
* Running preup function
/etc/conf.d/net: line 44: key_FRITZ!Box: command not found
* Configuring wireless network for eth1
This happens everytime I start the script. Actually it works anyway.
Find a patch here:
http://schlitt.info/misc/net.patch
Gentoo wireless my way - Updated on Fri, 30 Jan 2009 02:39:19 +0100 in Westhoffswelt - Welcome to the real world
Just some bugfixes to my gentoo based wireless script.