Slackware: Custom script on ifup? (Was: Re: [vox-tech] notebook
wireless refinement question)
Shwaine
shwaine at shwaine.com
Thu Mar 24 16:07:31 PST 2005
On Thu, 24 Mar 2005, Ryan wrote:
> On Saturday 19 March 2005 09:03 pm, Donald Greg McGahan
> dgmcgahan-at-yahoo.com |lugod| wrote:
>> New to Linux so pardon if this is not not clearly asked......but here
>> goes....
>> I have Slackware running on a Toshiba notebook.
>> It has a miniPCI wireless card.
>> I've figured out how to connect to my home wireless router by running a
>> script
>>
>> #!/bin/bash
>> iwconfig eth1 essid name key [1] XXXX-XXXX-XXXX-XXXX-XXXX-XXXX-XX
>> dhcpcd eth1
>>
>> Now when I turn on the notebook at home I'd like to have the start up
>> recognize the essid name and run this script and just connect or is
>> there a better way such as the rc.wireless.conf? Seems like I should be
>> able to look for this essid first then if it does not exist go to say
>> Moobilenet then look for an unsecured access point.
>
> Most distros are able to run a script when an interface is brought up. I'm
> not familiar with slackware, but I know it can be done in debian. Each distro
> tends to handle network initialization in a diffrent way, so you'll need to
> talk to a slackware person. I have changed he subject to get someone who
> knows how to do this to respond ;)
>
Nice thing about Slackware is you can pretty easily edit the scripts in
/etc/rc.d to put whatever you want. I've not messed with wireless yet, but
the eth interfaces are usually configured by /etc/rc.d/rc.inet1. I usually
leave this script alone out of old habit (on pre 10.x boxes, that script
was overwritten by the network configuration binary, although I'm pretty
sure that on 10.x only /etc/rc.d/rc.inet1.conf is overwritten).
/etc/rc.d/rc.inet2 is run immediately afterwards to configure network
related services such as the firewall and daemons. Calling your script at
the start of this file is one way to go for getting the interface
configured properly at boot.
As you already seemed to have guessed, the more accepted method is to put
it in /etc/rc.d/rc.wireless.conf as that is called by /etc/rc.d/rc.inet1
during the eth_up process. Note that this when rc.wireless.conf is called,
it is passed the eth${1} variable from /etc/rc.d/rc.inet1 so you have the
interface name. It also calls it for all initialized interfaces, so if you
also have an eth0 for example, it will also call rc.wireless.conf eth0.
You will want to check this parameter in rc.wireless.conf so you only run
your script when the wireless interface is reached. The advantage of a
properly configured rc.wireless.conf is that you can run
/etc/rc.d/rc.inet1 eth1_start or /etc/rc.d/rc.inet1 eth1_restart after the
machine has booted and your script will be called.
So this might be a sample rc.wireless.conf script that would allow adding
more interfaces later:
#!/bin/bash
config_eth1() {
iwconfig eth1 essid name key [1] XXXX-XXXX-XXXX-XXXX-XXXX-XXXX-XX
}
case "$1" in
'eth1')
config_eth1
;;
esac
Note that I did not put the DHCP call in here. This can actually be
handled in /etc/rc.d/rc.inet1 by editting /etc/rc.d/rc.inet1.conf and
putting USE_DHCP[1]="yes". /etc/rc.d/rc.wireless.conf is called just
before DHCP in rc.inet1. And if you're only going to have the one wireless
interface, instead of the case statement and function, you could just do
an if statement with string compare on the $1 parameter.
More information about the vox-tech
mailing list