/[baselayout]/branches/rc-scripts-1_6/net-scripts/net.modules.d/essidnet
Gentoo

Contents of /branches/rc-scripts-1_6/net-scripts/net.modules.d/essidnet

Parent Directory Parent Directory | Revision Log Revision Log


Revision 799 - (show annotations) (download)
Thu Dec 16 17:13:45 2004 UTC (9 years, 11 months ago) by uberlord
File size: 3389 byte(s)
fixed searcdomains being set for essid

1 # essidnet module for net-scripts
2 # Version 1.0.3
3 # Copyright (c) 2004 Gentoo Foundation
4 # Distributed under the terms of the GNU General Public License V2
5 # Contributed by Roy Marples (uberlord@gentoo.org)
6 # Many thanks to all the people in the Gentoo forums for their ideas and
7 # motivation for me to make this and keep on improving it
8
9 # Load our config if it exists
10 [[ -f /etc/conf.d/wireless ]] && source /etc/conf.d/wireless
11
12 # void essidnet_depend(void)
13 #
14 # Sets up the dependancies for the module
15 essidnet_depend() {
16 before interface
17 after wireless
18 installed wireless
19 }
20
21 # bool essidnet_check_installed(void)
22 #
23 # Always returns 0 as we are "installed" by wireless in the depend function
24 essidnet_check_installed() {
25 return 0
26 }
27
28 # char* essidnet_provides(void)
29 #
30 # Returns a string to change module definition for starting up
31 essidnet_provides() {
32 echo "essidnet"
33 }
34
35 # bool essidnet_check_depends(void)
36 #
37 # Checks to see if we have the needed functions
38 essidnet_check_depends() {
39 local f
40
41 for f in interface_variable wireless_check_extensions wireless_get_essid wireless_get_ap_mac_address; do
42 [[ $( type -t ${f} ) == function ]] && continue
43 eerror "essidnet: missing required function ${f}\n"
44 return 1
45 done
46
47 return 0
48 }
49
50 # bool essidnet_start(char *iface)
51 #
52 # All interfaces and module scripts expose modulename_get_vars
53 # which returns a space seperated list of user configuration variables
54 # We can override each variable here from a given ESSID or the MAC
55 # of the AP connected to. MAC configuration takes precedence
56 # Always returns 0
57 essidnet_pre_start() {
58 local iface=${1} ifvar=$( interface_variable ${1} )
59
60 wireless_check_extensions ${iface} || return 0
61
62 local mod func evars evar vars x i mvars mac=$( wireless_get_ap_mac_address ${iface} )
63 local ESSID=$( wireless_get_essid ${iface} )
64 local essid=${ESSID//[![:word:]]/_}
65 mac=${mac//:/}
66
67 vebegin "Configuring ${iface} for \"${ESSID//\\\\/\\\\}\"" 2>/dev/null
68
69 for mod in ${MODULES[@]}; do
70 func="${mod}_get_vars"
71 if [[ $(type -t ${func}) == function ]]; then
72 evars=( $( ${func} ${essid} ) )
73 mvars=( $( ${func} ${mac} ) )
74 vars=( $( ${func} ${ifvar} ) )
75 for ((i = 0; i<${#mvars[@]}; i++)); do
76 eval x=( \"\$\{mac_${mvars[i]}\[@\]\}\" )
77 [[ -z ${x} ]] && eval x=( \"\$\{${evars[i]}\[@\]\}\" )
78 [[ -n ${x} ]] && eval "${vars[i]}=( "\"\$\{x\[@\]\}\"" )"
79 done
80 fi
81 done
82
83 # Nameserver setup for the essid if required
84 local -a nameservers=( \"\$\{mac_nameservers_${mac}\[@\]\}\" )
85 [[ -z ${nameservers} ]] && eval nameservers=( \"\$\{nameservers_${essid}\[@\]\}\" )
86 if [[ -n ${nameservers} ]]; then
87 # Make a backup of the origional file if necessary
88 [[ -f /etc/resolv.conf ]] && mv /etc/resolv.conf /etc/resolv.conf.sv
89
90 echo "# Generated by net-scripts essidnet module" > /etc/resolv.conf
91 chmod 644 /etc/resolv.conf
92
93 eval x=\"\$\{mac_domain_${mac}\}\"
94 [[ -z ${x} ]] && eval x=\"\$\{domain_${essid}\}\"
95 [[ -n ${x} ]] && echo "domain ${x}" >> /etc/resolv.conf
96
97 for x in ${nameservers[@]}; do
98 echo "nameserver ${x}" >> /etc/resolv.conf
99 done
100
101 eval x=\"\$\{mac_searchdomains_${mac}\}\"
102 [[ -z ${x} ]] && eval x=\"\$\{searchdomains_${essid}\}\"
103 [[ -n ${x} ]] && echo "search ${x}" >> /etc/resolv.conf
104 fi
105
106 # Backwards compat for old gateway var
107 eval x=\"\$\{gateway_${essid}\}\"
108 [[ -n ${x} ]] && gateway="${iface}/${x}"
109
110 veend 0 2>/dev/null
111 return 0
112 }

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.20