source: projects/initscripts/tags/initscripts-8.91.0/sysconfig/network-scripts/ifup-wireless @ 1108

Revision 1108, 3.7 KB checked in by daisuke, 14 years ago (diff)

import initscripts-8.90.6 from internal cvs repository

Line 
1#!/bin/bash
2# Network Interface Configuration System
3# Copyright (c) 1996-2002 Red Hat, Inc. all rights reserved.
4#
5# Based on PCMCIA wireless script by (David Hinds/Jean Tourrilhes)
6#
7# This program is free software; you can redistribute it and/or modify
8# it under the terms of the GNU General Public License, version 2,
9# as published by the Free Software Foundation.
10#
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14# GNU General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License
17# along with this program; if not, write to the Free Software
18# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
19#
20# Configure wireless network device options.  See iwconfig(8) for more info.
21# Valid variables:
22#    MODE: Ad-Hoc, Managed, etc.
23#    ESSID: Name of the wireless network
24#    NWID: Name of this machine on the network.  Hostname is default
25#    FREQ: Frequency to operate on.  See CHANNEL
26#    CHANNEL: Numbered frequency to operate on.  See FREQ
27#    SENS: Sensitivity threshold for packet rejection.
28#    RATE: Transfer rate.  Usually one of Auto, 11, 5, 2, or 1.
29#    KEY: Encryption key for WEP.
30#    RTS: Explicit RTS handshake.  Usually not specified (auto)
31#    FRAG: Fragmentation threshold to split packets.  Usually not specified.
32#    SPYIPS: List of IP addresses to "spy" on for link performance stats.
33#    IWCONFIG: Extra parameters to pass directly to IWCONFIG
34#    SECURITYMODE: Security mode, e.g: 'open' or 'restricted'
35#    IWPRIV: Extra parameters to pass directly to IWPRIV
36
37# Only meant to be called from ifup.
38
39# Mode need to be first : some settings apply only in a specific mode !
40if [ -n "$MODE" ] ; then
41    iwconfig $DEVICE mode $MODE
42fi
43
44# Set link up (some cards require this.)
45/sbin/ip link set dev ${DEVICE} up
46
47# This is a bit hackish, but should do the job right...
48if [ -n "$ESSID" -o -n "$MODE" ] ; then
49    NICKNAME=`/bin/hostname`
50    iwconfig $DEVICE nick "$NICKNAME" >/dev/null 2>&1
51fi
52# Regular stuff...
53if [ -n "$NWID" ] ; then
54    iwconfig $DEVICE nwid $NWID
55fi
56if [ -n "$FREQ" -a "$MODE" != "Managed" ] ; then
57    iwconfig $DEVICE freq $FREQ
58elif [ -n "$CHANNEL" -a "$MODE" != "Managed" ] ; then
59    iwconfig $DEVICE channel $CHANNEL
60fi
61if [ -n "$SENS" ] ; then
62    iwconfig $DEVICE sens $SENS
63fi
64if [ -n "$RATE" ] ; then
65    iwconfig $DEVICE rate "$RATE"
66fi
67if [ -n "$KEY" -o -n "$KEY1" -o -n "$KEY2" -o -n "$KEY3" -o -n "$KEY4" ] ; then
68    [ -n "$KEY1" ] && iwconfig $DEVICE key "[1]" $KEY1
69    [ -n "$KEY2" ] && iwconfig $DEVICE key "[2]" $KEY2
70    [ -n "$KEY3" ] && iwconfig $DEVICE key "[3]" $KEY3
71    [ -n "$KEY4" ] && iwconfig $DEVICE key "[4]" $KEY4
72    [ -n "$DEFAULTKEY" ] && iwconfig $DEVICE key "[${DEFAULTKEY}]"
73    [ -n "$KEY" ] && iwconfig $DEVICE key $KEY
74else
75    iwconfig $DEVICE key off
76fi
77if [ -n "$SECURITYMODE" ]; then
78    iwconfig $DEVICE enc $SECURITYMODE
79fi
80if [ -n "$RTS" ] ; then
81    iwconfig $DEVICE rts $RTS
82fi
83if [ -n "$FRAG" ] ; then
84    iwconfig $DEVICE frag $FRAG
85fi
86
87# More specific parameters passed directly to IWCONFIG
88if [ -n "$IWCONFIG" ] ; then
89    iwconfig $DEVICE $IWCONFIG
90fi
91
92if [ -n "$SPYIPS" ] ; then
93    for IP in $SPYIPS; do
94        iwspy $DEVICE + $IP
95    done
96fi
97if [ -n "$IWPRIV" ] ; then
98    iwpriv $DEVICE $IWPRIV
99fi
100
101# ESSID need to be last : most device re-perform the scanning/discovery
102# when this is set, and things like encryption keys are better be
103# defined if we want to discover the right set of APs/nodes.
104if [ -n "$ESSID" ] ; then
105    iwconfig $DEVICE essid "$ESSID"
106else
107    # use any essid
108    iwconfig $DEVICE essid any >/dev/null 2>&1
109fi
Note: See TracBrowser for help on using the repository browser.