conf/72964: rc.d script needed to create wireless associations before dhclient runs

Vlad Manilici (izna at gzbx.pbz) rot13 at FreeBSD.org
Thu Oct 21 07:40:28 PDT 2004


>Number:         72964
>Category:       conf
>Synopsis:       rc.d script needed to create wireless associations before dhclient runs
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Thu Oct 21 14:40:27 GMT 2004
>Closed-Date:
>Last-Modified:
>Originator:     Vlad Manilici
>Release:        FreeBSD 5.2.1
>Organization:
>Environment:
FreeBSD XXX 5.2.1-RELEASE-p11 FreeBSD 5.2.1-RELEASE-p11 #21: Fri Oct  8 14:12:55 CEST 2004 XXX at XXX:/usr/obj/usr/src/sys/FX  i386
>Description:
it would be nice to have the possibility to automatically configure wireless connections when booting. some services need an internet connection in order to start (like ntpdate). if you start wireless later, you loose the opportunity to initialize these.

unfortunately, dhclient is of no use with a non-associated wireless card. the possibility to associate early with an access point is missing. i would like to thave somethink like this in rc.conf.local:

wireless_enable="YES"
wiereless_flags="wi0 SSID0 0xKEY0 wi1 SSID1 0xKEY1"

the following script (to be installed in /etc/rc.d) does the job:


#!/bin/sh

# $Id: wireless,v 1.2 2004/10/21 14:10:27 root Exp $

# PROVIDE: wireless
# REQUIRE: mountcritlocal
# BEFORE: dhclient
# KEYWORD: FreeBSD

. /etc/rc.subr

name="wireless"
rcvar=`set_rcvar`
start_cmd="wireless_start"

wireless_start(){
        for item in ${wireless_flags}
        do
                # read items
                if [ -z "$if" ]; then
                        if=$item
                elif [ -z "$ssid" ]; then
                        ssid=$item
                elif [ -z "$key" ]; then
                        key=$item
                fi

                # configure
                if [ -n "$if" -a -n "$ssid" -a -n "$key" ]; then
                        echo -n configuring interface $if / $ssid ...
                        if ifconfig $if 2>&1|grep -q 'does not exist'; then
                                echo ' does not exist'
                        elif ifconfig $if | grep -q 'status: associated'; then
                                echo ' already configured'
                        else
                                ifconfig $if inet 0.0.0.0 powersave wepmode on\
                                        station wlan ssid $ssid wepkey $key
                                if ifconfig $if | grep -q 'status: associated'; then
                                        echo ' ok'
                                else
                                        echo ' no association'
                                        ifconfig $if down
                                fi
                        fi
                        if=''
                        ssid=''
                        key=''
                fi
        done
}

load_rc_config $name
run_rc_command "$1"

>How-To-Repeat:
---
>Fix:
---
>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-bugs mailing list