From owner-freebsd-bugs@FreeBSD.ORG Sat Oct 23 14:10:25 2004 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 17EAB16A4CE for ; Sat, 23 Oct 2004 14:10:25 +0000 (GMT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id DFBD943D1D for ; Sat, 23 Oct 2004 14:10:24 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.11/8.12.11) with ESMTP id i9NEAOjE028388 for ; Sat, 23 Oct 2004 14:10:24 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.11/8.12.11/Submit) id i9NEAOYU028387; Sat, 23 Oct 2004 14:10:24 GMT (envelope-from gnats) Date: Sat, 23 Oct 2004 14:10:24 GMT Message-Id: <200410231410.i9NEAOYU028387@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org From: Vlad Manilici Subject: Re: conf/72964 X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Vlad Manilici List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 23 Oct 2004 14:10:25 -0000 The following reply was made to PR conf/72964; it has been noted by GNATS. From: Vlad Manilici To: freebsd-gnats-submit@FreeBSD.org Cc: Subject: Re: conf/72964 Date: Sat, 23 Oct 2004 16:01:08 +0200 hi, an updated version of the script: - code rearrange - allow for non-WEP setup (keyword: "none") - shutdown the interfaces ================================================================================ #!/bin/sh # $Id: wireless,v 1.10 2004/10/23 14:00:21 root Exp $ # PROVIDE: wireless # REQUIRE: mountcritlocal # BEFORE: dhclient # KEYWORD: FreeBSD . /etc/rc.subr name="wireless" rcvar=`set_rcvar` start_cmd="wireless_start" stop_cmd="wireless_stop" # global: list of processed interfaces ifs='' # if_start $if $ssid $key if_start(){ if=$1 ssid=$2 key=$3 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 if [ "$key" = "none" ]; then ifconfig $if inet 0.0.0.0 powersave\ station wlan ssid $ssid else ifconfig $if inet 0.0.0.0 powersave wepmode on\ station wlan ssid $ssid wepkey $key fi # delay sleep 1; wicontrol -L >&- if ifconfig $if | grep -q 'status: associated'; then echo ' ok' else echo ' no association' ifconfig $if down fi fi } # if_stop $if if_stop(){ if=$1 # skip if already processed if echo $ifs|grep -qv $if; then echo -n stopping interface $if ... # remember this interface ifs="$ifs $if" if ifconfig $if 2>&1|grep -q 'does not exist'; then echo ' does not exist' elif ifconfig $if | grep -q 'status: associated'; then ifconfig $if down if ifconfig $if | grep -q 'status: associated'; then echo ' error' else echo ' down' fi else echo ' no association' fi fi } # cycle start|stop cycle(){ action=$1 # read configuration 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 if [ "$action" = "start" ]; then # start if_start $if $ssid $key elif [ "$action" = "stop" ]; then # stop if_stop $if fi # clean items if='' ssid='' key='' fi done } wireless_start(){ cycle start } wireless_stop(){ cycle stop } load_rc_config $name run_rc_command "$1" ================================================================================ vlad