Subversion Repositories configs

Rev

Rev 9 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
4 - 1
#!/bin/bash
2
# Network Interface Configuration System
3
# Copyright (c) 1996-2009 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
9 - 36
#    WOWLAN: Enable wowlan (any, disconnect, magic-packet,...)
4 - 37
 
38
# Only meant to be called from ifup.
39
 
40
# Mode need to be first : some settings apply only in a specific mode !
40 - 41
cd /etc/sysconfig/network-scripts
42
. ./network-functions
43
 
4 - 44
if [ -n "$MODE" ] ; then
45
    iwconfig $DEVICE mode $MODE
46
fi
47
 
48
# Set link up (some cards require this.)
49
/sbin/ip link set dev ${DEVICE} up
50
 
51
# This is a bit hackish, but should do the job right...
52
if [ -n "$ESSID" -o -n "$MODE" ] ; then
53
    NICKNAME=$(/bin/hostname)
54
    iwconfig $DEVICE nick "$NICKNAME" >/dev/null 2>&1
55
fi
56
# Regular stuff...
57
if [ -n "$NWID" ] ; then
58
    iwconfig $DEVICE nwid $NWID
59
fi
60
if [ -n "$FREQ" -a "$MODE" != "Managed" ] ; then
61
    iwconfig $DEVICE freq $FREQ
62
elif [ -n "$CHANNEL" -a "$MODE" != "Managed" ] ; then
63
    iwconfig $DEVICE channel $CHANNEL
64
fi
65
if [ -n "$SENS" ] ; then
66
    iwconfig $DEVICE sens $SENS
67
fi
68
if [ -n "$RATE" ] ; then
69
    iwconfig $DEVICE rate "$RATE"
70
fi
71
if [ -n "$KEY" -o -n "$KEY1" -o -n "$KEY2" -o -n "$KEY3" -o -n "$KEY4" ] ; then
72
    [ -n "$KEY1" ] && iwconfig $DEVICE key "[1]" $KEY1
73
    [ -n "$KEY2" ] && iwconfig $DEVICE key "[2]" $KEY2
74
    [ -n "$KEY3" ] && iwconfig $DEVICE key "[3]" $KEY3
75
    [ -n "$KEY4" ] && iwconfig $DEVICE key "[4]" $KEY4
76
    [ -n "$DEFAULTKEY" ] && iwconfig $DEVICE key "[${DEFAULTKEY}]"
77
    [ -n "$KEY" ] && iwconfig $DEVICE key $KEY
78
else
79
    iwconfig $DEVICE key off
80
fi
81
if [ -n "$SECURITYMODE" ]; then
82
    iwconfig $DEVICE enc $SECURITYMODE
83
fi
84
if [ -n "$RTS" ] ; then
85
    iwconfig $DEVICE rts $RTS
86
fi
87
if [ -n "$FRAG" ] ; then
88
    iwconfig $DEVICE frag $FRAG
89
fi
90
 
91
# More specific parameters passed directly to IWCONFIG
92
if [ -n "$IWCONFIG" ] ; then
93
    iwconfig $DEVICE $IWCONFIG
94
fi
95
 
96
if [ -n "$SPYIPS" ] ; then
97
    for IP in $SPYIPS; do
98
	iwspy $DEVICE + $IP
99
    done
100
fi
101
if [ -n "$IWPRIV" ] ; then
102
    iwpriv $DEVICE $IWPRIV
103
fi
9 - 104
if [ -n "$WOWLAN" ] ; then
40 - 105
    PHYDEVICE=$(phy_wireless_device $DEVICE)
9 - 106
    iw phy $PHYDEVICE wowlan enable ${WOWLAN}
107
fi
4 - 108
 
109
# ESSID need to be last : most device re-perform the scanning/discovery
110
# when this is set, and things like encryption keys are better be
111
# defined if we want to discover the right set of APs/nodes.
112
if [ -n "$ESSID" ] ; then
113
    iwconfig $DEVICE essid "$ESSID"
114
else
115
    # use any essid
116
    iwconfig $DEVICE essid any >/dev/null 2>&1
117
fi