|
1.
Standard function hooks
Four functions can be defined in /etc/conf.d/net which will be
called surrounding the start/stop operations. The functions are
called with the interface name first so that one function can control multiple
adapters.
The return values for the preup() and predown() functions should
be 0 (success) to indicate that configuration or deconfiguration of the
interface can continue. If preup() returns a non-zero value, then
interface configuration will be aborted. If predown() returns a non-zero
value, then the interface will not be allowed to continue deconfiguration.
The return values for the postup() and postdown() functions are
ignored since there's nothing to do if they indicate failure.
${IFACE} is set to the interface being brought up/down. ${IFVAR}
is ${IFACE} converted to variable name bash allows.
Code Listing 1.1: pre/post up/down function examples in /etc/conf.d/net |
preup() {
if ethtool ${IFACE} | grep -q 'Link detected: no'; then
ewarn "No link on ${IFACE}, aborting configuration"
return 1
fi
return 0
}
predown() {
if is_net_fs /; then
eerror "root filesystem is network mounted -- can't stop ${IFACE}"
return 1
fi
return 0
}
postup() {
return 0
}
postdown() {
return 0
}
|
Note:
For more information on writing your own functions, please read
/usr/share/doc/openrc-*/net.example.bz2.
|
1.
Wireless Tools function hooks
Note:
This will not work with WPA Supplicant - but the ${ESSID} and
${ESSIDVAR} variables are available in the postup() function.
|
Two functions can be defined in /etc/conf.d/net which will be
called surrounding the associate function. The functions are called with the
interface name first so that one function can control multiple adapters.
The return values for the preassociate() function should be 0 (success)
to indicate that configuration or deconfiguration of the interface can continue.
If preassociate() returns a non-zero value, then interface configuration
will be aborted.
The return value for the postassociate() function is ignored since
there's nothing to do if it indicates failure.
${ESSID} is set to the exact ESSID of the AP you're connecting to.
${ESSIDVAR} is ${ESSID} converted to a variable name bash allows.
Code Listing 1.1: pre/post association functions in /etc/conf.d/net |
preassociate() {
local user pass
eval user=\"\$\{leap_user_${ESSIDVAR}\}\"
eval pass=\"\$\{leap_pass_${ESSIDVAR}\}\"
if [[ -n ${user} && -n ${pass} ]]; then
if [[ ! -x /opt/cisco/bin/leapscript ]]; then
eend "For LEAP support, please emerge net-misc/cisco-aironet-client-utils"
return 1
fi
einfo "Waiting for LEAP Authentication on \"${ESSID//\\\\//}\""
if /opt/cisco/bin/leapscript ${user} ${pass} | grep -q 'Login incorrect'; then
ewarn "Login Failed for ${user}"
return 1
fi
fi
return 0
}
postassociate() {
return 0
}
|
Note:
${ESSID} and ${ESSIDVAR} are unavailable in predown() and
postdown() functions.
|
Note:
For more information on writing your own functions, please read
/usr/share/doc/openrc-*/net.example.bz2.
|
|