diff options
Diffstat (limited to 'net-scripts/net.modules.d/macnet')
-rw-r--r-- | net-scripts/net.modules.d/macnet | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/net-scripts/net.modules.d/macnet b/net-scripts/net.modules.d/macnet new file mode 100644 index 0000000..3ab8cd1 --- /dev/null +++ b/net-scripts/net.modules.d/macnet @@ -0,0 +1,72 @@ +#!/bin/bash +# Copyright (c) 2005 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +# Contributed by Roy Marples (uberlord@gentoo.org) +# Many thanks to all the people in the Gentoo forums for their ideas and +# motivation for me to make this and keep on improving it + +# void macnet_depend(void) +# +# Sets up the dependancies for the module +macnet_depend() { + before interface wireless + after macchanger +} + +# bool macnet_check_installed(void) +# +# Always returns 0 as we are "installed" by wireless in the depend function +macnet_check_installed() { + return 0 +} + +# char* macnet_provides(void) +# +# Returns a string to change module definition for starting up +macnet_provides() { + echo "macnet" +} + +# bool macnet_check_depends(void) +# +# Checks to see if we have the needed functions +macnet_check_depends() { + local f + + for f in interface_get_mac_address; do + [[ $( type -t "${f}" ) == "function" ]] && continue + eerror "macnet: missing required function ${f}\n" + return 1 + done + + return 0 +} + +# bool macnet_start(char *iface) +# +# All interfaces and module scripts expose modulename_get_vars +# which returns a space seperated list of user configuration variables +# We can override each variable here from a given MAC address of the interface +# Always returns 0 +macnet_pre_start() { + local iface="$1" + + interface_exists "${iface}" || return 0 + + # We need to bring the interface up for some interfaces, otherwise the MAC + # address isn't consistent - mainly wireless cards with firmware uploading. + interface_up "${iface}" + + local mac=$( interface_get_mac_address "${iface}" ) + [[ -z ${mac} ]] && return 0 + + vebegin "Configuring ${iface} for MAC address ${mac}" 2>/dev/null + mac="${mac//:}" + configure_variables "${iface}" "${mac}" + veend 0 2>/dev/null + + return 0 +} + +# vim:ts=4 |