/[gentoo]/xml/htdocs/doc/en/handbook/hb-net-functions.xml
Gentoo

Diff of /xml/htdocs/doc/en/handbook/hb-net-functions.xml

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.3 Revision 1.4
38<c>${IFVAR}</c> is <c>${IFACE}</c> converted to variable name bash allows 38<c>${IFVAR}</c> is <c>${IFACE}</c> converted to variable name bash allows
39</p> 39</p>
40 40
41<pre caption="pre/post up/down function examples"> 41<pre caption="pre/post up/down function examples">
42preup() { 42preup() {
43 <comment># Test for link on the interface prior to bringing it up. This 43 <comment># Test for link on the interface prior to bringing it up. This
44 # only works on some network adapters and requires the mii-diag 44 # only works on some network adapters and requires the mii-diag
45 # package to be installed.</comment> 45 # package to be installed.</comment>
46 if mii-tool ${IFACE} 2> /dev/null | grep -q 'no link'; then 46 if mii-tool ${IFACE} 2> /dev/null | grep -q 'no link'; then
47 ewarn "No link on ${IFACE}, aborting configuration" 47 ewarn "No link on ${IFACE}, aborting configuration"
48 return 1 48 return 1
49 fi 49 fi
50 50
51 <comment># Test for link on the interface prior to bringing it up. This 51 <comment># Test for link on the interface prior to bringing it up. This
52 # only works on some network adapters and requires the ethtool 52 # only works on some network adapters and requires the ethtool
53 # package to be installed.</comment> 53 # package to be installed.</comment>
54 if ethtool ${IFACE} | grep -q 'Link detected: no'; then 54 if ethtool ${IFACE} | grep -q 'Link detected: no'; then
55 ewarn "No link on ${IFACE}, aborting configuration" 55 ewarn "No link on ${IFACE}, aborting configuration"
56 return 1 56 return 1
57 fi 57 fi
58 58
59 <comment># Remember to return 0 on success</comment> 59 <comment># Remember to return 0 on success</comment>
60 return 0 60 return 0
61} 61}
62 62
63predown() { 63predown() {
64 <comment># The default in the script is to test for NFS root and disallow 64 <comment># The default in the script is to test for NFS root and disallow
65 # downing interfaces in that case. Note that if you specify a 65 # downing interfaces in that case. Note that if you specify a
66 # predown() function you will override that logic. Here it is, in 66 # predown() function you will override that logic. Here it is, in
67 # case you still want it...</comment> 67 # case you still want it...</comment>
68 if is_net_fs /; then 68 if is_net_fs /; then
69 eerror "root filesystem is network mounted -- can't stop ${IFACE}" 69 eerror "root filesystem is network mounted -- can't stop ${IFACE}"
70 return 1 70 return 1
71 fi 71 fi
72 72
73 <comment># Remember to return 0 on success</comment> 73 <comment># Remember to return 0 on success</comment>
74 return 0 74 return 0
75} 75}
76 76
77postup() { 77postup() {
78 <comment># This function could be used, for example, to register with a 78 <comment># This function could be used, for example, to register with a
79 # dynamic DNS service. Another possibility would be to 79 # dynamic DNS service. Another possibility would be to
80 # send/receive mail once the interface is brought up.</comment> 80 # send/receive mail once the interface is brought up.</comment>
81 return 0 81 return 0
82} 82}
83 83
84postdown() { 84postdown() {
85 <comment># This function is mostly here for completeness... I haven't 85 <comment># This function is mostly here for completeness... I haven't
86 # thought of anything nifty to do with it yet ;-)</comment> 86 # thought of anything nifty to do with it yet ;-)</comment>
87 return 0 87 return 0
88} 88}
89</pre> 89</pre>
90 90
91</body> 91</body>
92</section> 92</section>
122<c>${ESSIDVAR}</c> is <c>${ESSID}</c> converted to variable name bash allows 122<c>${ESSIDVAR}</c> is <c>${ESSID}</c> converted to variable name bash allows
123</p> 123</p>
124 124
125<pre caption="pre/post association functions"> 125<pre caption="pre/post association functions">
126preassociate() { 126preassociate() {
127 <comment># The below adds two configuration variables leap_user_ESSID 127 <comment># The below adds two configuration variables leap_user_ESSID
128 # and leap_pass_ESSID. When they are both configured for the ESSID 128 # and leap_pass_ESSID. When they are both configured for the ESSID
129 # being connected to then we run the CISCO LEAP script</comment> 129 # being connected to then we run the CISCO LEAP script</comment>
130 130
131 local user pass 131 local user pass
132 eval user=\"\$\{leap_user_${ESSIDVAR}\}\" 132 eval user=\"\$\{leap_user_${ESSIDVAR}\}\"
133 eval pass=\"\$\{leap_pass_${ESSIDVAR}\}\" 133 eval pass=\"\$\{leap_pass_${ESSIDVAR}\}\"
134 134
135 if [[ -n ${user} &amp;&amp; -n ${pass} ]]; then 135 if [[ -n ${user} &amp;&amp; -n ${pass} ]]; then
136 if [[ ! -x /opt/cisco/bin/leapscript ]]; then 136 if [[ ! -x /opt/cisco/bin/leapscript ]]; then
137 eend "For LEAP support, please emerge net-misc/cisco-aironet-client-utils" 137 eend "For LEAP support, please emerge net-misc/cisco-aironet-client-utils"
138 return 1 138 return 1
139 fi 139 fi
140 einfo "Waiting for LEAP Authentication on \"${ESSID//\\\\//}\"" 140 einfo "Waiting for LEAP Authentication on \"${ESSID//\\\\//}\""
141 if /opt/cisco/bin/leapscript ${user} ${pass} | grep -q 'Login incorrect'; then 141 if /opt/cisco/bin/leapscript ${user} ${pass} | grep -q 'Login incorrect'; then
142 ewarn "Login Failed for ${user}" 142 ewarn "Login Failed for ${user}"
143 return 1 143 return 1
144 fi 144 fi
145 fi 145 fi
146 146
147 return 0 147 return 0
148} 148}
149 149
150postassociate() { 150postassociate() {
151 <comment># This function is mostly here for completeness... I haven't 151 <comment># This function is mostly here for completeness... I haven't
152 # thought of anything nifty to do with it yet ;-)</comment> 152 # thought of anything nifty to do with it yet ;-)</comment>
153 153
154 return 0 154 return 0
155} 155}
156</pre> 156</pre>
157 157
158<note> 158<note>
159<c>${ESSID}</c> and <c>${ESSIDVAR}</c> are unavailable in predown() and 159<c>${ESSID}</c> and <c>${ESSIDVAR}</c> are unavailable in predown() and

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

  ViewVC Help
Powered by ViewVC 1.1.20