Adopt a more C style for scripts and remove vim settings.
This commit is contained in:
		| @@ -1,33 +1,14 @@ | ||||
| # Copyright 2007 Roy Marples | ||||
| # Copyright 2007-2008 Roy Marples | ||||
| # All rights reserved | ||||
|  | ||||
| # Redistribution and use in source and binary forms, with or without | ||||
| # modification, are permitted provided that the following conditions | ||||
| # are met: | ||||
| # 1. Redistributions of source code must retain the above copyright | ||||
| #    notice, this list of conditions and the following disclaimer. | ||||
| # 2. Redistributions in binary form must reproduce the above copyright | ||||
| #    notice, this list of conditions and the following disclaimer in the | ||||
| #    documentation and/or other materials provided with the distribution. | ||||
| # | ||||
| # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND | ||||
| # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||||
| # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||||
| # ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||||
| # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||||
| # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||||
| # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||||
| # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||||
| # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||||
| # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||||
| # SUCH DAMAGE. | ||||
|  | ||||
| ifconfig_depend() { | ||||
| ifconfig_depend() | ||||
| { | ||||
| 	program /sbin/ifconfig | ||||
| 	provide interface | ||||
| } | ||||
|  | ||||
| _exists() { | ||||
| _exists() | ||||
| { | ||||
| 	# Only FreeBSD sees to have /dev/net .... is there something | ||||
| 	# other than ifconfig we can use for the others? | ||||
| 	if [ -d /dev/net ]; then | ||||
| @@ -37,7 +18,8 @@ _exists() { | ||||
| 	fi | ||||
| } | ||||
|  | ||||
| _get_mac_address() { | ||||
| _get_mac_address() | ||||
| { | ||||
| 	local proto= address= foo= | ||||
| 	LC_ALL=C ifconfig "${IFACE}" | while read proto address foo; do | ||||
| 		case "${proto}" in | ||||
| @@ -54,15 +36,18 @@ _get_mac_address() { | ||||
| 	done | ||||
| } | ||||
|  | ||||
| _up () { | ||||
| _up() | ||||
| { | ||||
| 	ifconfig "${IFACE}" up | ||||
| } | ||||
|  | ||||
| _down () { | ||||
| _down() | ||||
| { | ||||
| 	ifconfig "${IFACE}" down | ||||
| } | ||||
|  | ||||
| _ifindex() { | ||||
| _ifindex() | ||||
| { | ||||
| 	local x= i=1 | ||||
| 	case "${RC_UNAME}" in | ||||
| 		FreeBSD|DragonFly) | ||||
| @@ -90,7 +75,8 @@ _ifindex() { | ||||
| 	return 1 | ||||
| } | ||||
|  | ||||
| _ifconfig_ent() { | ||||
| _ifconfig_ent() | ||||
| { | ||||
| 	LC_ALL=C ifconfig "${IFACE}" 2>/dev/null | while read ent rest; do | ||||
|    		case "${ent}" in | ||||
| 			"$1") echo "${rest}";; | ||||
| @@ -98,14 +84,16 @@ _ifconfig_ent() { | ||||
| 	done | ||||
| } | ||||
|  | ||||
| _is_wireless() { | ||||
| _is_wireless() | ||||
| { | ||||
| 	case "$(_ifconfig_ent "media:")" in | ||||
| 		"IEEE 802.11 Wireless"*) return 0;; | ||||
| 		*) return 1;; | ||||
| 	esac | ||||
| } | ||||
|  | ||||
| _get_inet_address() { | ||||
| _get_inet_address() | ||||
| { | ||||
| 	local inet= address= n= netmask= rest= | ||||
| 	LC_ALL=C ifconfig "${IFACE}" | while read inet address n netmask rest; do | ||||
| 		if [ "${inet}" = "inet" ]; then | ||||
| @@ -115,7 +103,8 @@ _get_inet_address() { | ||||
| 	done | ||||
| } | ||||
|  | ||||
| _add_address() { | ||||
| _add_address() | ||||
| { | ||||
| 	local inet6= | ||||
|  | ||||
| 	case "$@" in | ||||
| @@ -141,7 +130,8 @@ _add_address() { | ||||
| 	ifconfig "${IFACE}" ${inet6} "$@" alias | ||||
| } | ||||
|  | ||||
| _add_route() { | ||||
| _add_route() | ||||
| { | ||||
| 	if [ $# -gt 3 ]; then | ||||
| 		if [ "$3" = "gw" -o "$3" = "via" ]; then | ||||
| 			local one=$1 two=$2 | ||||
| @@ -156,7 +146,8 @@ _add_route() { | ||||
| 	esac | ||||
| } | ||||
|  | ||||
| _delete_addresses() { | ||||
| _delete_addresses() | ||||
| { | ||||
| 	einfo "Removing addresses" | ||||
| 	eindent | ||||
| 	LC_ALL=C ifconfig "${IFACE}" | while read inet address rest; do | ||||
| @@ -176,18 +167,21 @@ _delete_addresses() { | ||||
| 	return 0 | ||||
| } | ||||
|  | ||||
| _show_address() { | ||||
| _show_address() | ||||
| { | ||||
| 	einfo "received address $(_get_inet_address "${IFACE}")" | ||||
| } | ||||
|  | ||||
| _has_carrier() { | ||||
| _has_carrier() | ||||
| { | ||||
| 	case "$(_ifconfig_ent "status:")" in | ||||
| 		""|active|associated) return 0;; | ||||
| 		*) return 1;; | ||||
| 	esac | ||||
| } | ||||
|  | ||||
| ifconfig_pre_start() { | ||||
| ifconfig_pre_start() | ||||
| { | ||||
| 	local config="$(_get_array "ifconfig_${IFVAR}")" conf= arg= args= | ||||
| 	local IFS="$__IFS" | ||||
|  | ||||
| @@ -219,7 +213,8 @@ ifconfig_pre_start() { | ||||
| 	return 0 | ||||
| } | ||||
|  | ||||
| _ifconfig_ipv6_tentative() { | ||||
| _ifconfig_ipv6_tentative() | ||||
| { | ||||
| 	local inet= address= rest= | ||||
| 	LC_ALL=C ifconfig "${IFACE}" | while read inet address rest; do | ||||
| 	 	case "${inet}" in | ||||
| @@ -233,7 +228,8 @@ _ifconfig_ipv6_tentative() { | ||||
| 	[ $? = 2 ] | ||||
| } | ||||
|  | ||||
| ifconfig_post_start() { | ||||
| ifconfig_post_start() | ||||
| { | ||||
| 	if _ifconfig_ipv6_tentative; then | ||||
| 		ebegin "Waiting for IPv6 addresses" | ||||
| 		while true; do | ||||
| @@ -242,5 +238,3 @@ ifconfig_post_start() { | ||||
| 		eend 0 | ||||
| 	fi | ||||
| } | ||||
|  | ||||
| # vim: set ts=4 : | ||||
|   | ||||
| @@ -1,37 +1,19 @@ | ||||
| # Copyright 2007 Roy Marples | ||||
| # Copyright 2007-2008 Roy Marples | ||||
| # All rights reserved | ||||
|  | ||||
| # Redistribution and use in source and binary forms, with or without | ||||
| # modification, are permitted provided that the following conditions | ||||
| # are met: | ||||
| # 1. Redistributions of source code must retain the above copyright | ||||
| #    notice, this list of conditions and the following disclaimer. | ||||
| # 2. Redistributions in binary form must reproduce the above copyright | ||||
| #    notice, this list of conditions and the following disclaimer in the | ||||
| #    documentation and/or other materials provided with the distribution. | ||||
| # | ||||
| # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND | ||||
| # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||||
| # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||||
| # ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||||
| # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||||
| # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||||
| # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||||
| # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||||
| # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||||
| # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||||
| # SUCH DAMAGE. | ||||
| _config_vars="$_config_vars ssid mode associate_timeout preferred_aps" | ||||
| _config_vars="$_config_vars blacklist_aps" | ||||
|  | ||||
| _config_vars="$_config_vars ssid mode associate_timeout preferred_aps blacklist_aps" | ||||
|  | ||||
| iwconfig_depend() { | ||||
| iwconfig_depend() | ||||
| { | ||||
| 	program /sbin/ifconfig | ||||
| 	after plug | ||||
| 	before interface | ||||
| 	provide wireless | ||||
| } | ||||
|  | ||||
| iwconfig_get_wep_status() { | ||||
| iwconfig_get_wep_status() | ||||
| { | ||||
| 	local status="disabled" | ||||
| 	local mode=$(LC_ALL=C ifconfig "${IFACE}" \ | ||||
| 	| sed -n -e 's/^[[:space:]]*authmode \([^ ]*\) privacy ON .*/\1/p') | ||||
| @@ -42,29 +24,34 @@ iwconfig_get_wep_status() { | ||||
| 	echo "(WEP ${status})" | ||||
| } | ||||
|  | ||||
| _iwconfig_get() { | ||||
| _iwconfig_get() | ||||
| { | ||||
| 	LC_ALL=C ifconfig "${IFACE}" | \ | ||||
| 	sed -n -e "s/^[[:space:]]*ssid \(.*\) channel \([0-9]*\).* bssid \(..:..:..:..:..:..\)\$/\\$1/p" | ||||
| } | ||||
|  | ||||
| _get_ssid() { | ||||
| _get_ssid() | ||||
| { | ||||
| 	local ssid="$(_iwconfig_get 1)" | ||||
| 	# If the ssid has a space then it's wrapped in quotes. | ||||
| 	# This is a problem if the real ssid has a quote at the start or the end :/ | ||||
| 	# If the ssid has a space then it's wrapped in quotes. This is a | ||||
| 	# problem if the real ssid has a quote at the start or the end :/ | ||||
| 	ssid=${ssid#\"} | ||||
| 	ssid=${ssid%\"} | ||||
| 	echo "${ssid}" | ||||
| } | ||||
|  | ||||
| _get_ap_mac_address() { | ||||
| _get_ap_mac_address() | ||||
| { | ||||
| 	_iwconfig_get 3 | ||||
| } | ||||
|  | ||||
| _get_channel() { | ||||
| _get_channel() | ||||
| { | ||||
| 	_iwconfig_get 2 | ||||
| } | ||||
|  | ||||
| iwconfig_report() { | ||||
| iwconfig_report() | ||||
| { | ||||
| 	local m="connected to" | ||||
| 	local ssid="$(_get_ssid)" | ||||
| 	local mac="$(_get_ap_mac_address "${iface}")" | ||||
| @@ -79,7 +66,8 @@ iwconfig_report() { | ||||
| 	eoutdent | ||||
| } | ||||
|  | ||||
| iwconfig_get_wep_key() { | ||||
| iwconfig_get_wep_key() | ||||
| { | ||||
| 	local mac="$1" key= | ||||
| 	[ -n "${mac}" ] && mac="$(echo "${mac}" | sed -e 's/://g')" | ||||
| 	eval key=\$mac_key_${mac} | ||||
| @@ -87,7 +75,8 @@ iwconfig_get_wep_key() { | ||||
| 	echo "${key:--}" | ||||
| } | ||||
|  | ||||
| iwconfig_user_config() { | ||||
| iwconfig_user_config() | ||||
| { | ||||
| 	local conf= | ||||
| 	eval set -- \$ifconfig_${SSIDVAR} | ||||
| 	for conf in "$@" ; do | ||||
| @@ -95,7 +84,8 @@ iwconfig_user_config() { | ||||
| 	done | ||||
| } | ||||
|  | ||||
| iwconfig_set_mode() { | ||||
| iwconfig_set_mode() | ||||
| { | ||||
| 	local x= opt= unopt="hostap adhoc" | ||||
| 	case "$1" in | ||||
| 		master|hostap) unopt="adhoc" opt="hostap" ;; | ||||
| @@ -109,7 +99,8 @@ iwconfig_set_mode() { | ||||
| 	done | ||||
| } | ||||
|  | ||||
| iwconfig_setup_specific() { | ||||
| iwconfig_setup_specific() | ||||
| { | ||||
| 	local mode="${1:-master}" channel= | ||||
| 	if [ -z "${SSID}" ]; then | ||||
| 		eerror "${IFACE} requires an SSID to be set to operate in ${mode} mode" | ||||
| @@ -136,7 +127,8 @@ iwconfig_setup_specific() { | ||||
| 	return 0 | ||||
| } | ||||
|  | ||||
| iwconfig_associate() { | ||||
| iwconfig_associate() | ||||
| { | ||||
| 	local mac="$1" channel="$2" caps="$3" | ||||
| 	local mode= w="(WEP Disabled)" key= | ||||
|  | ||||
| @@ -251,7 +243,8 @@ iwconfig_associate() { | ||||
| 	return 0 | ||||
| } | ||||
|  | ||||
| iwconfig_scan() { | ||||
| iwconfig_scan() | ||||
| { | ||||
| 	local x= i=0 scan= quality= | ||||
| 	einfo "Scanning for access points" | ||||
| 	eindent | ||||
| @@ -387,7 +380,8 @@ iwconfig_scan() { | ||||
| 	return 0 | ||||
| } | ||||
|  | ||||
| iwconfig_force_preferred() { | ||||
| iwconfig_force_preferred() | ||||
| { | ||||
| 	eval set -- $(_flatten_array "preferred_aps_${IFVAR}") | ||||
| 	[ $# = 0 ] && eval set -- $(_flatten_array "preferred_aps") | ||||
| 	[ $# = 0 ] && return 1 | ||||
| @@ -414,7 +408,8 @@ iwconfig_force_preferred() { | ||||
| 	return 1 | ||||
| } | ||||
|  | ||||
| iwconfig_connect_preferred() { | ||||
| iwconfig_connect_preferred() | ||||
| { | ||||
| 	eval set -- $(_flatten_array "preferred_aps_${IFVAR}") | ||||
| 	[ $# = 0 ] && eval set -- $(_flatten_array "preferred_aps") | ||||
| 	[ $# = 0 ] && return 1 | ||||
| @@ -439,7 +434,8 @@ iwconfig_connect_preferred() { | ||||
| 	return 1 | ||||
| } | ||||
|  | ||||
| iwconfig_connect_not_preferred() { | ||||
| iwconfig_connect_not_preferred() | ||||
| { | ||||
| 	local ssid= i=0 mode= mac= caps= freq= chan= pref= | ||||
|  | ||||
| 	while [ ${i} -le ${APS} ] ; do | ||||
| @@ -474,7 +470,8 @@ iwconfig_connect_not_preferred() { | ||||
| 	return 1 | ||||
| } | ||||
|  | ||||
| iwconfig_defaults() { | ||||
| iwconfig_defaults() | ||||
| { | ||||
| 	# Set some defaults | ||||
| 	#ifconfig "${iface}" txpower 100 2>/dev/null | ||||
| 	ifconfig "${IFACE}" bssid - | ||||
| @@ -485,7 +482,8 @@ iwconfig_defaults() { | ||||
| 	ifconfig "${IFACE}" -mediaopt hostap | ||||
| } | ||||
|  | ||||
| iwconfig_configure() { | ||||
| iwconfig_configure() | ||||
| { | ||||
| 	local x APS | ||||
| 	eval SSID=\$ssid_${IFVAR} | ||||
|  | ||||
| @@ -550,7 +548,8 @@ iwconfig_configure() { | ||||
| 	return 1 | ||||
| } | ||||
|  | ||||
| iwconfig_pre_start() { | ||||
| iwconfig_pre_start() | ||||
| { | ||||
| 	# We don't configure wireless if we're being called from | ||||
| 	# the background | ||||
| 	yesno ${IN_BACKGROUND} && return 0 | ||||
| @@ -584,11 +583,10 @@ iwconfig_pre_start() { | ||||
| 	return 1 | ||||
| } | ||||
|  | ||||
| iwconfig_post_stop() { | ||||
| iwconfig_post_stop() | ||||
| { | ||||
| 	yesno ${IN_BACKGROUND} && return 0 | ||||
| 	_is_wireless || return 0 | ||||
| 	iwconfig_defaults | ||||
| 	#iwconfig "${IFACE}" txpower 0 2>/dev/null | ||||
| } | ||||
|  | ||||
| # vim: set ts=4 : | ||||
|   | ||||
| @@ -2,33 +2,14 @@ | ||||
| # Copyright 2007 Roy Marples | ||||
| # All rights reserved | ||||
|  | ||||
| # Redistribution and use in source and binary forms, with or without | ||||
| # modification, are permitted provided that the following conditions | ||||
| # are met: | ||||
| # 1. Redistributions of source code must retain the above copyright | ||||
| #    notice, this list of conditions and the following disclaimer. | ||||
| # 2. Redistributions in binary form must reproduce the above copyright | ||||
| #    notice, this list of conditions and the following disclaimer in the | ||||
| #    documentation and/or other materials provided with the distribution. | ||||
| # | ||||
| # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND | ||||
| # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||||
| # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||||
| # ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||||
| # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||||
| # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||||
| # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||||
| # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||||
| # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||||
| # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||||
| # SUCH DAMAGE. | ||||
|  | ||||
| adsl_depend() { | ||||
| adsl_depend() | ||||
| { | ||||
| 	program /usr/sbin/adsl-start /usr/sbin/pppoe-start | ||||
| 	before dhcp | ||||
| } | ||||
|  | ||||
| adsl_setup_vars() { | ||||
| adsl_setup_vars() | ||||
| { | ||||
| 	local startstop="$1" cfgexe= | ||||
|  | ||||
| 	if [ -x /usr/sbin/pppoe-start ]; then | ||||
| @@ -53,7 +34,8 @@ adsl_setup_vars() { | ||||
| 	return 0 | ||||
| } | ||||
|  | ||||
| adsl_start() { | ||||
| adsl_start() | ||||
| { | ||||
| 	local exe= cfgfile= user= | ||||
|  | ||||
| 	adsl_setup_vars start || return 1 | ||||
| @@ -72,7 +54,8 @@ adsl_start() { | ||||
| 	eend $? | ||||
| } | ||||
|  | ||||
| adsl_stop() { | ||||
| adsl_stop() | ||||
| { | ||||
| 	local exe= cfgfile= | ||||
|  | ||||
| 	[ ! -f /var/run/rp-pppoe-"${IFACE}".pid ] && return 0 | ||||
| @@ -89,5 +72,3 @@ adsl_stop() { | ||||
|  | ||||
| 	return 0 | ||||
| } | ||||
|  | ||||
| # vim: set ts=4 : | ||||
|   | ||||
| @@ -1,32 +1,13 @@ | ||||
| # Copyright 2007 Roy Marples | ||||
| # Copyright 2007-2008 Roy Marples | ||||
| # All rights reserved | ||||
|  | ||||
| # Redistribution and use in source and binary forms, with or without | ||||
| # modification, are permitted provided that the following conditions | ||||
| # are met: | ||||
| # 1. Redistributions of source code must retain the above copyright | ||||
| #    notice, this list of conditions and the following disclaimer. | ||||
| # 2. Redistributions in binary form must reproduce the above copyright | ||||
| #    notice, this list of conditions and the following disclaimer in the | ||||
| #    documentation and/or other materials provided with the distribution. | ||||
| # | ||||
| # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND | ||||
| # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||||
| # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||||
| # ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||||
| # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||||
| # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||||
| # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||||
| # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||||
| # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||||
| # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||||
| # SUCH DAMAGE. | ||||
|  | ||||
| apipa_depend() { | ||||
| apipa_depend() | ||||
| { | ||||
| 	program /sbin/arping | ||||
| } | ||||
|  | ||||
| _random() { | ||||
| _random() | ||||
| { | ||||
| 	local r=${RANDOM} | ||||
| 	if [ -n "${r}" ]; then | ||||
| 		echo "${r}" | ||||
| @@ -35,7 +16,8 @@ _random() { | ||||
| 	fi | ||||
| } | ||||
|  | ||||
| apipa_start() { | ||||
| apipa_start() | ||||
| { | ||||
| 	local iface="$1" i1= i2= addr= i=0 | ||||
|  | ||||
| 	_exists true || return 1 | ||||
| @@ -64,5 +46,3 @@ apipa_start() { | ||||
| 	eoutdent | ||||
| 	return 1 | ||||
| } | ||||
|  | ||||
| # vim: set ts=4 : | ||||
|   | ||||
| @@ -1,33 +1,14 @@ | ||||
| # Copyright 2007 Roy Marples | ||||
| # Copyright 2007-2008 Roy Marples | ||||
| # All rights reserved | ||||
|  | ||||
| # Redistribution and use in source and binary forms, with or without | ||||
| # modification, are permitted provided that the following conditions | ||||
| # are met: | ||||
| # 1. Redistributions of source code must retain the above copyright | ||||
| #    notice, this list of conditions and the following disclaimer. | ||||
| # 2. Redistributions in binary form must reproduce the above copyright | ||||
| #    notice, this list of conditions and the following disclaimer in the | ||||
| #    documentation and/or other materials provided with the distribution. | ||||
| # | ||||
| # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND | ||||
| # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||||
| # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||||
| # ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||||
| # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||||
| # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||||
| # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||||
| # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||||
| # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||||
| # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||||
| # SUCH DAMAGE. | ||||
|  | ||||
| arping_depend() { | ||||
| arping_depend() | ||||
| { | ||||
| 	program /sbin/arping /usr/sbin/arping2 | ||||
| 	before interface | ||||
| } | ||||
|  | ||||
| arping_address() { | ||||
| arping_address() | ||||
| { | ||||
| 	local ip=${1%%/*} mac="$2" spoof="$3" foundmac= i= w= opts= | ||||
|  | ||||
| 	# We only handle IPv4 addresses | ||||
| @@ -73,14 +54,16 @@ arping_address() { | ||||
| 	return 0 | ||||
| } | ||||
|  | ||||
| _arping_in_config() { | ||||
| _arping_in_config() | ||||
| { | ||||
| 	_get_array "config_${IFVAR}" | while read i; do | ||||
| 		[ "${i}" = "arping" ] && return 1 | ||||
| 	done | ||||
| 	return 1 | ||||
| } | ||||
|  | ||||
| arping_start() { | ||||
| arping_start() | ||||
| { | ||||
| 	local gateways= x= conf= i= | ||||
| 	einfo "Pinging gateways on ${IFACE} for configuration" | ||||
|  | ||||
| @@ -146,5 +129,3 @@ arping_start() { | ||||
| 	eoutdent | ||||
| 	return 1 | ||||
| } | ||||
|  | ||||
| # vim: set ts=4 : | ||||
|   | ||||
| @@ -1,39 +1,21 @@ | ||||
| # Copyright 2007 Roy Marples | ||||
| # Copyright 2007-2008 Roy Marples | ||||
| # All rights reserved | ||||
|  | ||||
| # Redistribution and use in source and binary forms, with or without | ||||
| # modification, are permitted provided that the following conditions | ||||
| # are met: | ||||
| # 1. Redistributions of source code must retain the above copyright | ||||
| #    notice, this list of conditions and the following disclaimer. | ||||
| # 2. Redistributions in binary form must reproduce the above copyright | ||||
| #    notice, this list of conditions and the following disclaimer in the | ||||
| #    documentation and/or other materials provided with the distribution. | ||||
| # | ||||
| # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND | ||||
| # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||||
| # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||||
| # ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||||
| # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||||
| # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||||
| # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||||
| # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||||
| # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||||
| # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||||
| # SUCH DAMAGE. | ||||
|  | ||||
| bonding_depend() { | ||||
| bonding_depend() | ||||
| { | ||||
| 	before interface macchanger | ||||
| 	program /sbin/ifenslave | ||||
| } | ||||
|  | ||||
| _config_vars="$_config_vars slaves" | ||||
|  | ||||
| _is_bond() { | ||||
| _is_bond() | ||||
| { | ||||
| 	[ -f "/proc/net/bonding/${IFACE}" ] | ||||
| } | ||||
|  | ||||
| bonding_pre_start() { | ||||
| bonding_pre_start() | ||||
| { | ||||
| 	local s= slaves="$(_get_array "slaves_${IFVAR}")"  | ||||
|  | ||||
| 	[ -z "${slaves}" ] && return 0 | ||||
| @@ -86,7 +68,8 @@ bonding_pre_start() { | ||||
| 	return 0 #important | ||||
| } | ||||
|  | ||||
| bonding_stop() { | ||||
| bonding_stop() | ||||
| { | ||||
| 	_is_bond || return 0	 | ||||
|  | ||||
| 	local slaves= s= | ||||
| @@ -116,5 +99,3 @@ bonding_stop() { | ||||
| 	eend 0 | ||||
| 	return 0 | ||||
| } | ||||
|  | ||||
| # vim: set ts=4 : | ||||
|   | ||||
| @@ -1,28 +1,8 @@ | ||||
| # Copyright 2007 Roy Marples | ||||
| # Copyright 2007-2008 Roy Marples | ||||
| # All rights reserved | ||||
|  | ||||
| # Redistribution and use in source and binary forms, with or without | ||||
| # modification, are permitted provided that the following conditions | ||||
| # are met: | ||||
| # 1. Redistributions of source code must retain the above copyright | ||||
| #    notice, this list of conditions and the following disclaimer. | ||||
| # 2. Redistributions in binary form must reproduce the above copyright | ||||
| #    notice, this list of conditions and the following disclaimer in the | ||||
| #    documentation and/or other materials provided with the distribution. | ||||
| # | ||||
| # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND | ||||
| # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||||
| # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||||
| # ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||||
| # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||||
| # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||||
| # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||||
| # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||||
| # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||||
| # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||||
| # SUCH DAMAGE. | ||||
|  | ||||
| _br2684ctl() { | ||||
| _br2684ctl() | ||||
| { | ||||
| 	if [ -x /usr/sbin/br2684ctl ]; then | ||||
| 		echo /usr/sbin/br2684ctl | ||||
| 	else | ||||
| @@ -30,14 +10,16 @@ _br2684ctl() { | ||||
| 	fi | ||||
| } | ||||
|  | ||||
| br2684ctl_depend() { | ||||
| br2684ctl_depend() | ||||
| { | ||||
| 	before ppp | ||||
| 	program start $(_br2684ctl) | ||||
| } | ||||
|  | ||||
| _config_vars="$_config_vars bridge bridge_add brctl" | ||||
| 	 | ||||
| br2684ctl_pre_start() { | ||||
| br2684ctl_pre_start() | ||||
| { | ||||
| 	local opts= | ||||
| 	eval opts=\$br2684ctl_${IFVAR} | ||||
| 	[ -z "${opts}" ] && return 0 | ||||
| @@ -66,7 +48,8 @@ br2684ctl_pre_start() { | ||||
| 	eend $? | ||||
| } | ||||
|  | ||||
| br2684ctl_post_stop() { | ||||
| br2684ctl_post_stop() | ||||
| { | ||||
| 	local pidfile="/var/run/br2684ctl-${IFACE}.pid" | ||||
| 	[ -e "${pidfile}" ] || return 0 | ||||
| 	 | ||||
| @@ -74,5 +57,3 @@ br2684ctl_post_stop() { | ||||
| 	start-stop-daemon --stop --quiet --pidfile "${pidfile}" | ||||
| 	eend $? | ||||
| } | ||||
|  | ||||
| # vim: set ts=4 : | ||||
|   | ||||
| @@ -1,39 +1,21 @@ | ||||
| # Copyright 2007 Roy Marples | ||||
| # Copyright 2007-2008 Roy Marples | ||||
| # All rights reserved | ||||
|  | ||||
| # Redistribution and use in source and binary forms, with or without | ||||
| # modification, are permitted provided that the following conditions | ||||
| # are met: | ||||
| # 1. Redistributions of source code must retain the above copyright | ||||
| #    notice, this list of conditions and the following disclaimer. | ||||
| # 2. Redistributions in binary form must reproduce the above copyright | ||||
| #    notice, this list of conditions and the following disclaimer in the | ||||
| #    documentation and/or other materials provided with the distribution. | ||||
| # | ||||
| # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND | ||||
| # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||||
| # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||||
| # ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||||
| # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||||
| # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||||
| # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||||
| # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||||
| # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||||
| # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||||
| # SUCH DAMAGE. | ||||
|  | ||||
| bridge_depend() { | ||||
| bridge_depend() | ||||
| { | ||||
| 	before interface macnet | ||||
| 	program /sbin/brctl | ||||
| } | ||||
|  | ||||
| _config_vars="$_config_vars bridge bridge_add brctl" | ||||
|  | ||||
| _is_bridge() { | ||||
| _is_bridge() | ||||
| { | ||||
| 	brctl show 2>/dev/null | grep -q "^${IFACE}[[:space:]]" | ||||
| } | ||||
|  | ||||
| bridge_pre_start() { | ||||
| bridge_pre_start() | ||||
| { | ||||
| 	local ports= brif= iface="${IFACE}" e= x= | ||||
| 	local ports="$(_get_array "bridge_${IFVAR}")" | ||||
| 	local opts="$(_get_array "brctl_${IFVAR}")" | ||||
| @@ -96,7 +78,8 @@ bridge_pre_start() { | ||||
| 	_up | ||||
| } | ||||
|  | ||||
| bridge_post_stop() { | ||||
| bridge_post_stop() | ||||
| { | ||||
| 	local port= ports= delete=false extra= | ||||
|  | ||||
| 	if _is_bridge; then | ||||
| @@ -138,5 +121,3 @@ bridge_post_stop() { | ||||
| 	 | ||||
| 	return 0 | ||||
| } | ||||
|  | ||||
| # vim: set ts=4 : | ||||
|   | ||||
| @@ -1,34 +1,15 @@ | ||||
| # Copyright 2007 Roy Marples | ||||
| # Copyright 2007-2008 Roy Marples | ||||
| # All rights reserved | ||||
|  | ||||
| # Redistribution and use in source and binary forms, with or without | ||||
| # modification, are permitted provided that the following conditions | ||||
| # are met: | ||||
| # 1. Redistributions of source code must retain the above copyright | ||||
| #    notice, this list of conditions and the following disclaimer. | ||||
| # 2. Redistributions in binary form must reproduce the above copyright | ||||
| #    notice, this list of conditions and the following disclaimer in the | ||||
| #    documentation and/or other materials provided with the distribution. | ||||
| # | ||||
| # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND | ||||
| # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||||
| # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||||
| # ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||||
| # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||||
| # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||||
| # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||||
| # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||||
| # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||||
| # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||||
| # SUCH DAMAGE. | ||||
|  | ||||
| _config_vars="$_config_vars ccwgroup" | ||||
|  | ||||
| ccwgroup_depend() { | ||||
| ccwgroup_depend() | ||||
| { | ||||
| 	before interface  | ||||
| } | ||||
|  | ||||
| ccwgroup_pre_start() { | ||||
| ccwgroup_pre_start() | ||||
| { | ||||
| 	local ccwgroup="$(_get_array "ccwgroup_${IFVAR}")" | ||||
| 	[ -z "${ccwgroup}" ] && return 0 | ||||
|  | ||||
| @@ -57,7 +38,8 @@ ccwgroup_pre_start() { | ||||
| 	eend $? | ||||
| } | ||||
|  | ||||
| ccwgroup_pre_stop() { | ||||
| ccwgroup_pre_stop() | ||||
| { | ||||
| 	# Erase any existing ccwgroup to be safe | ||||
| 	service_set_value ccwgroup_device "" | ||||
| 	 | ||||
| @@ -73,7 +55,8 @@ ccwgroup_pre_stop() { | ||||
| 	service_set_value ccwgroup_device "${device}" | ||||
| } | ||||
|  | ||||
| ccwgroup_post_stop() { | ||||
| ccwgroup_post_stop() | ||||
| { | ||||
| 	local device="$(service_get_value ccwgroup_device)" | ||||
| 	[ -z "${device}" ] && return 0 | ||||
| 	 | ||||
| @@ -82,5 +65,3 @@ ccwgroup_post_stop() { | ||||
| 	echo "1" >/sys/devices/qeth/"${device}"/ungroup | ||||
| 	eend $? | ||||
| } | ||||
|  | ||||
| # vim: set ts=4 : | ||||
|   | ||||
| @@ -1,7 +1,8 @@ | ||||
| # Copyright 2005-2007 Gentoo Foundation | ||||
| # Distributed under the terms of the GNU General Public License v2 | ||||
|  | ||||
| clip_depend() { | ||||
| clip_depend() | ||||
| { | ||||
| 	program /usr/sbin/atmsigd | ||||
|     before interface | ||||
| } | ||||
| @@ -15,7 +16,8 @@ _config_vars="$_config_vars clip" | ||||
| # themself from the controlling terminal when backgrounding... The only way I | ||||
| # see to overcame this is to use the --background option in start-stop-daemon, | ||||
| # which is reported as a "last resort" method, but it acts correctly about this. | ||||
| atmclip_svc_start() { | ||||
| atmclip_svc_start() | ||||
| { | ||||
|     ebegin "Starting $2 Daemon ($1)" | ||||
|     start-stop-daemon --start \ | ||||
| 		--background \ | ||||
| @@ -24,7 +26,8 @@ atmclip_svc_start() { | ||||
|     eend $? | ||||
| } | ||||
|  | ||||
| atmclip_svcs_start() { | ||||
| atmclip_svcs_start() | ||||
| { | ||||
|     einfo "First CLIP instance: starting ATM CLIP daemons" | ||||
|     eindent | ||||
|  | ||||
| @@ -42,7 +45,8 @@ atmclip_svcs_start() { | ||||
|     return ${r} | ||||
| } | ||||
|  | ||||
| atmclip_svc_stop() { | ||||
| atmclip_svc_stop() | ||||
| { | ||||
|     ebegin "Stopping $2 Daemon ($1)" | ||||
|     start-stop-daemon --stop --quiet \ | ||||
| 		--pidfile "/var/run/$1.pid" \ | ||||
| @@ -50,7 +54,8 @@ atmclip_svc_stop() { | ||||
|     eend $? | ||||
| } | ||||
|  | ||||
| atmclip_svcs_stop() { | ||||
| atmclip_svcs_stop() | ||||
| { | ||||
|     einfo "Last CLIP instance: stopping ATM CLIP daemons" | ||||
|     eindent | ||||
|  | ||||
| @@ -66,7 +71,8 @@ atmclip_svcs_stop() { | ||||
|     eoutdent | ||||
| } | ||||
|  | ||||
| are_atmclip_svcs_running() { | ||||
| are_atmclip_svcs_running() | ||||
| { | ||||
|  | ||||
| 	start-stop-daemon --quiet --test --stop --pidfile /var/run/atmarpd.pid || return 1 | ||||
|  | ||||
| @@ -78,7 +84,8 @@ are_atmclip_svcs_running() { | ||||
|     return 0 | ||||
| } | ||||
|  | ||||
| clip_pre_start() { | ||||
| clip_pre_start() | ||||
| { | ||||
| 	local clip= | ||||
| 	eval clip=\$clip_${IFVAR} | ||||
| 	[ -z "${clip}" ] && return 0 | ||||
| @@ -109,7 +116,8 @@ clip_pre_start() { | ||||
|     return 0 | ||||
| } | ||||
|  | ||||
| clip_post_start() { | ||||
| clip_post_start() | ||||
| { | ||||
| 	local clip="$(_get_array "clip_${IFVAR}")" | ||||
| 	[ -z "${clip}" ] && return 0 | ||||
|  | ||||
| @@ -161,7 +169,8 @@ clip_post_start() { | ||||
|     fi | ||||
| } | ||||
|  | ||||
| clip_pre_stop() { | ||||
| clip_pre_stop() | ||||
| { | ||||
|     are_atmclip_svcs_running || return 0 | ||||
|  | ||||
| 	# We remove all the PVCs which may have been created by | ||||
| @@ -191,7 +200,8 @@ clip_pre_stop() { | ||||
| # We can just leave the interface down. "ifconfig -a" will still list it... | ||||
| # Also, here we can stop the ATM CLIP daemons if there is no other CLIP PVC | ||||
| # outstanding. We check this condition by inspecting the /proc/net/atm/arp file. | ||||
| clip_post_stop() { | ||||
| clip_post_stop() | ||||
| { | ||||
|     are_atmclip_svcs_running || return 0 | ||||
|  | ||||
|     local itf= left= hasothers= | ||||
| @@ -209,5 +219,3 @@ clip_post_stop() { | ||||
| 		atmclip_svcs_stop || return 1 | ||||
|     fi | ||||
| } | ||||
|  | ||||
| # vim: set ts=4 : | ||||
|   | ||||
| @@ -1,45 +1,29 @@ | ||||
| # Copyright 2007 Roy Marples | ||||
| # Copyright 2007-2008 Roy Marples | ||||
| # All rights reserved | ||||
|  | ||||
| # Redistribution and use in source and binary forms, with or without | ||||
| # modification, are permitted provided that the following conditions | ||||
| # are met: | ||||
| # 1. Redistributions of source code must retain the above copyright | ||||
| #    notice, this list of conditions and the following disclaimer. | ||||
| # 2. Redistributions in binary form must reproduce the above copyright | ||||
| #    notice, this list of conditions and the following disclaimer in the | ||||
| #    documentation and/or other materials provided with the distribution. | ||||
| # | ||||
| # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND | ||||
| # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||||
| # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||||
| # ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||||
| # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||||
| # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||||
| # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||||
| # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||||
| # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||||
| # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||||
| # SUCH DAMAGE. | ||||
|  | ||||
| ifconfig_depend() { | ||||
| ifconfig_depend() | ||||
| { | ||||
| 	program /sbin/ifconfig | ||||
| 	provide interface | ||||
| } | ||||
|  | ||||
| _up() { | ||||
| _up() | ||||
| { | ||||
| 	ifconfig "${IFACE}" up | ||||
| } | ||||
|  | ||||
| _down() { | ||||
| _down() | ||||
| { | ||||
| 	ifconfig "${IFACE}" down | ||||
| } | ||||
|  | ||||
| _exists() { | ||||
| _exists() | ||||
| { | ||||
| 	grep -Eq "^[[:space:]]*${IFACE}:" /proc/net/dev | ||||
| } | ||||
|  | ||||
| _ifindex() { | ||||
| _ifindex() | ||||
| { | ||||
| 	local line= i=-2 | ||||
| 	while read line; do | ||||
| 		i=$((${i} + 1)) | ||||
| @@ -55,7 +39,8 @@ _ifindex() { | ||||
| 	return 1 | ||||
| } | ||||
|  | ||||
| _is_wireless() { | ||||
| _is_wireless() | ||||
| { | ||||
| 	# Support new sysfs layout | ||||
| 	[ -d /sys/class/net/"${IFACE}"/wireless ] && return 0 | ||||
|  | ||||
| @@ -63,15 +48,16 @@ _is_wireless() { | ||||
| 	grep -Eq "^[[:space:]]*${IFACE}:" /proc/net/wireless | ||||
| } | ||||
|  | ||||
| _set_flag() { | ||||
| _set_flag() | ||||
| { | ||||
| 	ifconfig "${IFACE}" "$1" | ||||
| } | ||||
|  | ||||
| _get_mac_address() { | ||||
| _get_mac_address() | ||||
| { | ||||
| 	local mac=$(LC_ALL=C ifconfig "${IFACE}" | \ | ||||
| 	sed -n -e 's/.* HWaddr \(..:..:..:..:..:..\).*/\1/p') | ||||
|  | ||||
|  | ||||
| 	case "${mac}" in | ||||
| 		00:00:00:00:00:00);; | ||||
| 		44:44:44:44:44:44);; | ||||
| @@ -83,11 +69,13 @@ _get_mac_address() { | ||||
| 	return 1 | ||||
| } | ||||
|  | ||||
| _set_mac_address() { | ||||
| _set_mac_address() | ||||
| { | ||||
| 	ifconfig "${IFACE}" hw ether "$1" | ||||
| } | ||||
|  | ||||
| _get_inet_address() { | ||||
| _get_inet_address() | ||||
| { | ||||
| 	set -- $(LC_ALL=C ifconfig "${IFACE}" | | ||||
| 	sed -n -e 's/.*inet addr:\([^ ]*\).*Mask:\([^ ]*\).*/\1 \2/p') | ||||
| 	[ -z "$1" ] && return 1 | ||||
| @@ -97,7 +85,8 @@ _get_inet_address() { | ||||
| 	echo "/$(_netmask2cidr "$1")" | ||||
| } | ||||
|  | ||||
| _get_inet_addresses() { | ||||
| _get_inet_addresses() | ||||
| { | ||||
| 	local iface=${IFACE} i=0 | ||||
| 	local addrs="$(_get_inet_address)" | ||||
|  | ||||
| @@ -111,7 +100,8 @@ _get_inet_addresses() { | ||||
| 	echo "${addrs}" | ||||
| } | ||||
|  | ||||
| _cidr2netmask() { | ||||
| _cidr2netmask() | ||||
| { | ||||
| 	local cidr="$1" netmask="" done=0 i=0 sum=0 cur=128 | ||||
| 	local octets= frac= | ||||
|  | ||||
| @@ -141,7 +131,8 @@ _cidr2netmask() { | ||||
| 	echo "${netmask#.*}" | ||||
| } | ||||
|  | ||||
| _add_address() { | ||||
| _add_address() | ||||
| { | ||||
| 	if [ "$1" = "127.0.0.1/8" -a "${IFACE}" = "lo" ]; then | ||||
| 		ifconfig "${IFACE}" "$@" 2>/dev/null | ||||
| 		return 0 | ||||
| @@ -189,7 +180,8 @@ _add_address() { | ||||
| 	ifconfig "${iface}" ${cmd} | ||||
| } | ||||
|  | ||||
| _add_route() { | ||||
| _add_route() | ||||
| { | ||||
| 	local inet6= | ||||
|  | ||||
| 	if [ -n "${metric}" ]; then | ||||
| @@ -214,7 +206,8 @@ _add_route() { | ||||
| 	route ${inet6} add "$@" dev "${IFACE}" | ||||
| } | ||||
|  | ||||
| _delete_addresses() { | ||||
| _delete_addresses() | ||||
| { | ||||
| 	# We don't remove addresses from aliases | ||||
| 	case "${IFACE}" in | ||||
| 		*:*) return 0;; | ||||
| @@ -250,15 +243,18 @@ _delete_addresses() { | ||||
| 	return 0 | ||||
| } | ||||
|  | ||||
| _has_carrier() { | ||||
| _has_carrier() | ||||
| { | ||||
| 	return 0 | ||||
| } | ||||
|  | ||||
| _tunnel() { | ||||
| _tunnel() | ||||
| { | ||||
| 	iptunnel "$@" | ||||
| } | ||||
|  | ||||
| ifconfig_pre_start() { | ||||
| ifconfig_pre_start() | ||||
| { | ||||
| 	# MTU support | ||||
| 	local mtu= | ||||
| 	eval mtu=\$mtu_${IFVAR} | ||||
| @@ -282,7 +278,8 @@ ifconfig_pre_start() { | ||||
| 	eend $? | ||||
| } | ||||
|  | ||||
| ifconfig_post_stop() { | ||||
| ifconfig_post_stop() | ||||
| { | ||||
| 	# Don't delete sit0 as it's a special tunnel | ||||
| 	[ "${IFACE}" = "sit0" ] && return 0 | ||||
|  | ||||
| @@ -292,5 +289,3 @@ ifconfig_post_stop() { | ||||
| 	iptunnel del "${IFACE}" | ||||
| 	eend $? | ||||
| } | ||||
|  | ||||
| # vim: set ts=4 : | ||||
|   | ||||
| @@ -1,37 +1,18 @@ | ||||
| # Copyright 2007 Roy Marples | ||||
| # Copyright 2007-2008 Roy Marples | ||||
| # All rights reserved | ||||
|  | ||||
| # Redistribution and use in source and binary forms, with or without | ||||
| # modification, are permitted provided that the following conditions | ||||
| # are met: | ||||
| # 1. Redistributions of source code must retain the above copyright | ||||
| #    notice, this list of conditions and the following disclaimer. | ||||
| # 2. Redistributions in binary form must reproduce the above copyright | ||||
| #    notice, this list of conditions and the following disclaimer in the | ||||
| #    documentation and/or other materials provided with the distribution. | ||||
| # | ||||
| # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND | ||||
| # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||||
| # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||||
| # ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||||
| # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||||
| # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||||
| # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||||
| # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||||
| # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||||
| # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||||
| # SUCH DAMAGE. | ||||
|  | ||||
| _config_vars="$_config_vars plug_timeout" | ||||
|  | ||||
| ifplugd_depend() { | ||||
| ifplugd_depend() | ||||
| { | ||||
| 	program start /usr/sbin/ifplugd | ||||
| 	after macnet rename | ||||
| 	before interface | ||||
| 	provide plug | ||||
| } | ||||
|  | ||||
| ifplugd_pre_start() { | ||||
| ifplugd_pre_start() | ||||
| { | ||||
| 	local pidfile="/var/run/ifplugd.${IFACE}.pid" timeout= args= | ||||
|  | ||||
| 	# We don't start ifplugd if we're being called from the background | ||||
| @@ -97,7 +78,8 @@ ifplugd_pre_start() { | ||||
| 	exit 1 | ||||
| } | ||||
|  | ||||
| ifplugd_stop() { | ||||
| ifplugd_stop() | ||||
| { | ||||
| 	yesno ${IN_BACKGROUND} && return 0 | ||||
|  | ||||
| 	local pidfile="/var/run/ifplugd.${IFACE}.pid" | ||||
| @@ -108,5 +90,3 @@ ifplugd_stop() { | ||||
| 		--pidfile "${pidfile}" --signal QUIT | ||||
| 	eend $? | ||||
| } | ||||
|  | ||||
| # vim: set ts=4 : | ||||
|   | ||||
| @@ -1,34 +1,15 @@ | ||||
| # Copyright 2007 Roy Marples | ||||
| # Copyright 2007-2008 Roy Marples | ||||
| # All rights reserved | ||||
|  | ||||
| # Redistribution and use in source and binary forms, with or without | ||||
| # modification, are permitted provided that the following conditions | ||||
| # are met: | ||||
| # 1. Redistributions of source code must retain the above copyright | ||||
| #    notice, this list of conditions and the following disclaimer. | ||||
| # 2. Redistributions in binary form must reproduce the above copyright | ||||
| #    notice, this list of conditions and the following disclaimer in the | ||||
| #    documentation and/or other materials provided with the distribution. | ||||
| # | ||||
| # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND | ||||
| # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||||
| # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||||
| # ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||||
| # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||||
| # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||||
| # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||||
| # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||||
| # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||||
| # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||||
| # SUCH DAMAGE. | ||||
|  | ||||
| _config_vars="$_config_vars link suffix relay" | ||||
|  | ||||
| ip6to4_depend() { | ||||
| ip6to4_depend() | ||||
| { | ||||
| 	after interface | ||||
| } | ||||
|  | ||||
| ip6to4_start() { | ||||
| ip6to4_start() | ||||
| { | ||||
| 	case " ${MODULES} " in | ||||
| 		*" ifconfig "*) | ||||
| 			if [ "${IFACE}" != "sit0" ]; then | ||||
| @@ -116,5 +97,3 @@ ip6to4_start() { | ||||
| 2003::/3 via ::${relay} metric 2147483647" | ||||
| 	eval routes_${IFVAR}=\$routes | ||||
| } | ||||
| 	 | ||||
| # vim: set ts=4 : | ||||
|   | ||||
| @@ -1,28 +1,8 @@ | ||||
| # Copyright 2007 Roy Marples | ||||
| # Copyright 2007-2008 Roy Marples | ||||
| # All rights reserved | ||||
|  | ||||
| # Redistribution and use in source and binary forms, with or without | ||||
| # modification, are permitted provided that the following conditions | ||||
| # are met: | ||||
| # 1. Redistributions of source code must retain the above copyright | ||||
| #    notice, this list of conditions and the following disclaimer. | ||||
| # 2. Redistributions in binary form must reproduce the above copyright | ||||
| #    notice, this list of conditions and the following disclaimer in the | ||||
| #    documentation and/or other materials provided with the distribution. | ||||
| # | ||||
| # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND | ||||
| # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||||
| # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||||
| # ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||||
| # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||||
| # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||||
| # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||||
| # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||||
| # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||||
| # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||||
| # SUCH DAMAGE. | ||||
|  | ||||
| ipppd_depend() { | ||||
| ipppd_depend() | ||||
| { | ||||
| 	program start /usr/sbin/ipppd | ||||
| 	after macnet | ||||
| 	before interface | ||||
| @@ -31,7 +11,8 @@ ipppd_depend() { | ||||
|  | ||||
| _config_vars="$_config_vars ipppd" | ||||
|  | ||||
| ipppd_pre_start() { | ||||
| ipppd_pre_start() | ||||
| { | ||||
| 	local opts= pidfile="/var/run/ipppd-${IFACE}.pid" | ||||
|  | ||||
| 	# Check that we are a valid ippp interface | ||||
| @@ -54,7 +35,8 @@ ipppd_pre_start() { | ||||
| 	eend $? | ||||
| } | ||||
|  | ||||
| ipppd_post_stop() { | ||||
| ipppd_post_stop() | ||||
| { | ||||
| 	local pidfile="/var/run/ipppd-${IFACE}.pid" | ||||
|  | ||||
| 	[ ! -f "${pidfile}" ] && return 0 | ||||
| @@ -64,5 +46,3 @@ ipppd_post_stop() { | ||||
| 		--pidfile "${pidfile}" | ||||
| 	eend $? | ||||
| } | ||||
|  | ||||
| # vim: set ts=4 : | ||||
|   | ||||
| @@ -1,46 +1,30 @@ | ||||
| # Copyright 2007 Roy Marples | ||||
| # Copyright 2007-2008 Roy Marples | ||||
| # All rights reserved | ||||
|  | ||||
| # Redistribution and use in source and binary forms, with or without | ||||
| # modification, are permitted provided that the following conditions | ||||
| # are met: | ||||
| # 1. Redistributions of source code must retain the above copyright | ||||
| #    notice, this list of conditions and the following disclaimer. | ||||
| # 2. Redistributions in binary form must reproduce the above copyright | ||||
| #    notice, this list of conditions and the following disclaimer in the | ||||
| #    documentation and/or other materials provided with the distribution. | ||||
| # | ||||
| # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND | ||||
| # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||||
| # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||||
| # ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||||
| # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||||
| # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||||
| # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||||
| # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||||
| # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||||
| # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||||
| # SUCH DAMAGE. | ||||
|  | ||||
| iproute2_depend() { | ||||
| iproute2_depend() | ||||
| { | ||||
| 	program /sbin/ip | ||||
| 	provide interface | ||||
| 	after ifconfig | ||||
| } | ||||
|  | ||||
| _up() { | ||||
| _up() | ||||
| { | ||||
| 	ip link set up dev "${IFACE}" | ||||
| } | ||||
|  | ||||
| _down() { | ||||
| _down() | ||||
| { | ||||
| 	ip link set down dev "${IFACE}" | ||||
| } | ||||
|  | ||||
| _exists() { | ||||
| _exists() | ||||
| { | ||||
| 	grep -Eq "^[[:space:]]*${IFACE}:" /proc/net/dev | ||||
| } | ||||
|  | ||||
| _ifindex() { | ||||
| _ifindex() | ||||
| { | ||||
| 	local line= i=-2 | ||||
| 	while read line; do | ||||
| 		i=$((${i} + 1)) | ||||
| @@ -56,7 +40,8 @@ _ifindex() { | ||||
| 	return 1 | ||||
| } | ||||
|  | ||||
| _is_wireless() { | ||||
| _is_wireless() | ||||
| { | ||||
| 	# Support new sysfs layout | ||||
| 	[ -d /sys/class/net/"${IFACE}"/wireless ] && return 0 | ||||
|  | ||||
| @@ -64,7 +49,8 @@ _is_wireless() { | ||||
| 	grep -Eq "^[[:space:]]*${IFACE}:" /proc/net/wireless | ||||
| } | ||||
|  | ||||
| _set_flag() { | ||||
| _set_flag() | ||||
| { | ||||
| 	local flag=$1 opt="on" | ||||
| 	if [ "${flag#-}" != "${flag}" ]; then | ||||
| 		flag=${flag#-} | ||||
| @@ -73,7 +59,8 @@ _set_flag() { | ||||
| 	ip link set "${IFACE}" "${flag}" "${opt}" | ||||
| } | ||||
|  | ||||
| _get_mac_address() { | ||||
| _get_mac_address() | ||||
| { | ||||
| 	local mac=$(LC_ALL=C ip link show "${IFACE}" | sed -n \ | ||||
| 		-e 'y/abcdef/ABCDEF/' \ | ||||
| 		-e '/link\// s/^.*\<\(..:..:..:..:..:..\)\>.*/\1/p') | ||||
| @@ -89,22 +76,26 @@ _get_mac_address() { | ||||
| 	return 1 | ||||
| } | ||||
|  | ||||
| _set_mac_address() { | ||||
| _set_mac_address() | ||||
| { | ||||
| 	ip link set address "$1" dev "${IFACE}" | ||||
| } | ||||
|  | ||||
| _get_inet_addresses() { | ||||
| _get_inet_addresses() | ||||
| { | ||||
| 	LC_ALL=C ip -family inet addr show "${IFACE}" | \ | ||||
| 	sed -n -e 's/.*inet \([^ ]*\).*/\1/p' | ||||
| } | ||||
|  | ||||
| _get_inet_address() { | ||||
| _get_inet_address() | ||||
| { | ||||
| 	set -- $(_get_inet_addresses) | ||||
| 	[ $# = "0" ] && return 1 | ||||
| 	echo "$1" | ||||
| } | ||||
|  | ||||
| _add_address() { | ||||
| _add_address() | ||||
| { | ||||
| 	if [ "$1" = "127.0.0.1/8" -a "${IFACE}" = "lo" ]; then | ||||
| 		ip addr add "$@" dev "${IFACE}" 2>/dev/null | ||||
| 		return 0 | ||||
| @@ -138,7 +129,8 @@ _add_address() { | ||||
| 	ip addr add dev "${IFACE}" "$@" | ||||
| } | ||||
|  | ||||
| _add_route() { | ||||
| _add_route() | ||||
| { | ||||
| 	if [ $# -eq 3 ]; then | ||||
| 		set -- "$1" "$2" via "$3" | ||||
| 	elif [ "$3" = "gw" ]; then | ||||
| @@ -167,7 +159,8 @@ _add_route() { | ||||
| 	eend $? | ||||
| } | ||||
|  | ||||
| _delete_addresses() { | ||||
| _delete_addresses() | ||||
| { | ||||
| 	ip addr flush dev "${IFACE}" scope global 2>/dev/null | ||||
| 	ip addr flush dev "${IFACE}" scope site 2>/dev/null | ||||
| 	if [ "${IFACE}" != "lo" ]; then | ||||
| @@ -176,15 +169,18 @@ _delete_addresses() { | ||||
| 	return 0 | ||||
| } | ||||
|  | ||||
| _has_carrier() { | ||||
| _has_carrier() | ||||
| { | ||||
| 	return 0 | ||||
| } | ||||
|  | ||||
| _tunnel() { | ||||
| _tunnel() | ||||
| { | ||||
| 	ip tunnel "$@" | ||||
| } | ||||
|  | ||||
| iproute2_pre_start() { | ||||
| iproute2_pre_start() | ||||
| { | ||||
| 	# MTU support | ||||
| 	local mtu= | ||||
| 	eval mtu=\$mtu_${IFVAR} | ||||
| @@ -210,12 +206,14 @@ iproute2_pre_start() { | ||||
| 	return 0 | ||||
| } | ||||
|  | ||||
| _iproute2_ipv6_tentative() { | ||||
| _iproute2_ipv6_tentative() | ||||
| { | ||||
| 	LC_ALL=C ip addr show dev "${IFACE}" | \ | ||||
| 		grep -q "^[[:space:]]*inet6 .* tentative" | ||||
| } | ||||
|  | ||||
| iproute2_post_start() { | ||||
| iproute2_post_start() | ||||
| { | ||||
| 	# Kernel may not have IP built in | ||||
| 	if [ -e /proc/net/route ]; then | ||||
| 		ip route flush table cache dev "${IFACE}" | ||||
| @@ -230,7 +228,8 @@ iproute2_post_start() { | ||||
| 	fi | ||||
| } | ||||
|  | ||||
| iproute2_post_stop() { | ||||
| iproute2_post_stop() | ||||
| { | ||||
| 	# Don't delete sit0 as it's a special tunnel | ||||
| 	if [ "${IFACE}" != "sit0" ]; then | ||||
| 		if [ -n "$(ip tunnel show "${IFACE}" 2>/dev/null)" ]; then | ||||
| @@ -240,5 +239,3 @@ iproute2_post_stop() { | ||||
| 		fi | ||||
| 	fi | ||||
| } | ||||
|  | ||||
| # vim: set ts=4 : | ||||
|   | ||||
| @@ -1,50 +1,35 @@ | ||||
| # Copyright 2007 Roy Marples | ||||
| # Copyright 2007-2008 Roy Marples | ||||
| # All rights reserved | ||||
|  | ||||
| # Redistribution and use in source and binary forms, with or without | ||||
| # modification, are permitted provided that the following conditions | ||||
| # are met: | ||||
| # 1. Redistributions of source code must retain the above copyright | ||||
| #    notice, this list of conditions and the following disclaimer. | ||||
| # 2. Redistributions in binary form must reproduce the above copyright | ||||
| #    notice, this list of conditions and the following disclaimer in the | ||||
| #    documentation and/or other materials provided with the distribution. | ||||
| # | ||||
| # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND | ||||
| # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||||
| # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||||
| # ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||||
| # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||||
| # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||||
| # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||||
| # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||||
| # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||||
| # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||||
| # SUCH DAMAGE. | ||||
| _config_vars="$_config_vars ssid mode associate_timeout sleep_scan" | ||||
| _config_vars="$_config_vars preferred_aps blacklist_aps" | ||||
|  | ||||
| _config_vars="$_config_vars ssid mode associate_timeout sleep_scan preferred_aps blacklist_aps" | ||||
|  | ||||
| iwconfig_depend() { | ||||
| iwconfig_depend() | ||||
| { | ||||
| 	program /sbin/iwconfig | ||||
| 	after plug | ||||
| 	before interface | ||||
| 	provide wireless | ||||
| } | ||||
|  | ||||
| iwconfig_get_wep_status() { | ||||
| iwconfig_get_wep_status() | ||||
| { | ||||
| 	local mode= status="disabled" | ||||
|  | ||||
| 	# No easy way of doing this grep in bash regex :/ | ||||
| 	if LC_ALL=C iwconfig "${IFACE}" | grep -qE "^ +Encryption key:[*0-9,A-F]"; then | ||||
| 	if LC_ALL=C iwconfig "${IFACE}" | \ | ||||
| 	grep -qE "^ +Encryption key:[*0-9,A-F]"; then | ||||
| 		status="enabled" | ||||
| 		mode=$(LC_ALL=C iwconfig "${IFACE}" | sed -n -e 's/^.*Security mode:\(.*[^ ]\).*/\1/p') | ||||
| 		mode=$(LC_ALL=C iwconfig "${IFACE}" | \ | ||||
| 		sed -n -e 's/^.*Security mode:\(.*[^ ]\).*/\1/p') | ||||
| 		[ -n "${mode}" ] && mode=" - ${mode}" | ||||
| 	fi | ||||
|  | ||||
| 	echo "(WEP ${status}${mode})" | ||||
| } | ||||
|  | ||||
| _get_ssid() { | ||||
| _get_ssid() | ||||
| { | ||||
| 	local i=5 ssid= | ||||
|  | ||||
| 	while [ ${i} -gt 0 ]; do | ||||
| @@ -60,7 +45,8 @@ _get_ssid() { | ||||
| 	return 1 | ||||
| } | ||||
|  | ||||
| _get_ap_mac_address() { | ||||
| _get_ap_mac_address() | ||||
| { | ||||
| 	local mac="$(iwgetid --raw --ap "${IFACE}")"  | ||||
| 	case "${mac}" in | ||||
| 		"00:00:00:00:00:00") return 1;; | ||||
| @@ -71,13 +57,15 @@ _get_ap_mac_address() { | ||||
| 	esac | ||||
| } | ||||
|  | ||||
| iwconfig_get_mode() { | ||||
| iwconfig_get_mode() | ||||
| { | ||||
| 	LC_ALL=C iwgetid --mode "${IFACE}" | \ | ||||
| 	sed -n -e 's/^.*Mode:\(.*\)/\1/p' | \ | ||||
| 	tr '[:upper:]' '[:lower:]' | ||||
| } | ||||
|  | ||||
| iwconfig_set_mode() { | ||||
| iwconfig_set_mode() | ||||
| { | ||||
| 	local mode="$1" | ||||
| 	[ "${mode}" = "$(iwconfig_get_mode)" ] && return 0 | ||||
|  | ||||
| @@ -87,11 +75,14 @@ iwconfig_set_mode() { | ||||
| 	_up | ||||
| } | ||||
|  | ||||
| iwconfig_get_type() { | ||||
| 	LC_ALL=C iwconfig "${IFACE}" | sed -n -e 's/^'"$1"' *\([^ ]* [^ ]*\).*/\1/p' | ||||
| iwconfig_get_type() | ||||
| { | ||||
| 	LC_ALL=C iwconfig "${IFACE}" | \ | ||||
| 	sed -n -e 's/^'"$1"' *\([^ ]* [^ ]*\).*/\1/p' | ||||
| } | ||||
|  | ||||
| iwconfig_report() { | ||||
| iwconfig_report() | ||||
| { | ||||
| 	local mac= m="connected to" | ||||
| 	local ssid="$(_get_ssid)" | ||||
| 	local wep_status="$(iwconfig_get_wep_status)" | ||||
| @@ -111,7 +102,8 @@ iwconfig_report() { | ||||
| 	eoutdent | ||||
| } | ||||
|  | ||||
| iwconfig_get_wep_key() { | ||||
| iwconfig_get_wep_key() | ||||
| { | ||||
| 	local mac="$1" key= | ||||
| 	[ -n "${mac}" ] && mac="$(echo "${mac}" | sed -e 's/://g')" | ||||
| 	eval key=\$mac_key_${mac} | ||||
| @@ -132,7 +124,8 @@ iwconfig_get_wep_key() { | ||||
| 	fi | ||||
| } | ||||
|  | ||||
| iwconfig_user_config() { | ||||
| iwconfig_user_config() | ||||
| { | ||||
| 	local conf= var=${SSIDVAR} config= | ||||
| 	[ -z "${var}" ] && var=${IFVAR} | ||||
|  | ||||
| @@ -158,7 +151,8 @@ iwconfig_user_config() { | ||||
| 	done | ||||
| } | ||||
|  | ||||
| iwconfig_setup_specific() { | ||||
| iwconfig_setup_specific() | ||||
| { | ||||
| 	local mode="$1" channel= | ||||
| 	if [ -z "${SSID}" ]; then | ||||
| 		eerror "${IFACE} requires an SSID to be set to operate in ${mode} mode" | ||||
| @@ -199,7 +193,8 @@ iwconfig_setup_specific() { | ||||
| 	return 0 | ||||
| } | ||||
|  | ||||
| iwconfig_wait_for_association() { | ||||
| iwconfig_wait_for_association() | ||||
| { | ||||
| 	local timeout= i=0 | ||||
| 	eval timeout=\$associate_timeout_${IFVAR} | ||||
| 	timeout=${timeout:-10} | ||||
| @@ -236,8 +231,10 @@ iwconfig_wait_for_association() { | ||||
| 	return 1 | ||||
| } | ||||
|  | ||||
| iwconfig_associate() { | ||||
| 	local mode="${1:-managed}" mac="$2" wep_required="$3" freq="$4" chan="$5" | ||||
| iwconfig_associate() | ||||
| { | ||||
| 	local mode="${1:-managed}" mac="$2" wep_required="$3" | ||||
| 	local freq="$4" chan="$5" | ||||
| 	local w="(WEP Disabled)" key= | ||||
|  | ||||
| 	iwconfig_set_mode "${mode}" | ||||
| @@ -322,7 +319,8 @@ iwconfig_associate() { | ||||
| 	return 0 | ||||
| } | ||||
|  | ||||
| iwconfig_scan() { | ||||
| iwconfig_scan() | ||||
| { | ||||
| 	local x= i=0 scan= | ||||
| 	einfo "Scanning for access points" | ||||
| 	eindent | ||||
| @@ -333,9 +331,9 @@ iwconfig_scan() { | ||||
|  | ||||
| 	while [ ${i} -lt 3 ]; do | ||||
| 	    local scan="${scan}${scan:+ }$(LC_ALL=C iwlist "${IFACE}" scan 2>/dev/null | sed -e "s/'/'\\\\''/g" -e "s/$/'/g" -e "s/^/'/g")" | ||||
| 		# If this is the first pass and txpower as off and we have no results | ||||
| 		# then we need to wait for at least 2 seconds whilst the interface | ||||
| 		# does an initial scan. | ||||
| 		# If this is the first pass and txpower as off and we have no | ||||
| 		# results then we need to wait for at least 2 seconds whilst | ||||
| 		# the interface does an initial scan. | ||||
| 		if [ "${i}" = "0" -a "${txpowerwasoff}" = "0" ]; then | ||||
| 			case "${scan}" in | ||||
| 				"'${IFACE} "*"No scan results"*) | ||||
| @@ -509,7 +507,8 @@ iwconfig_scan() { | ||||
| 	eoutdent | ||||
| } | ||||
|  | ||||
| iwconfig_force_preferred() { | ||||
| iwconfig_force_preferred() | ||||
| { | ||||
| 	eval set -- $(_flatten_array "preferred_aps_${IFVAR}") | ||||
| 	[ $# = 0 ] && eval set -- $(_flatten_array "preferred_aps") | ||||
| 	[ $# = 0 ] && return 1 | ||||
| @@ -535,7 +534,8 @@ iwconfig_force_preferred() { | ||||
| 	return 1 | ||||
| } | ||||
|  | ||||
| iwconfig_connect_preferred() { | ||||
| iwconfig_connect_preferred() | ||||
| { | ||||
| 	local ssid= i= mode= mac= enc= freq= chan= | ||||
| 	eval set -- $(_flatten_array "preferred_aps_${IFVAR}") | ||||
| 	[ $# = 0 ] && eval set -- $(_flatten_array "preferred_aps") | ||||
| @@ -562,7 +562,8 @@ iwconfig_connect_preferred() { | ||||
| 	return 1 | ||||
| } | ||||
|  | ||||
| iwconfig_connect_not_preferred() { | ||||
| iwconfig_connect_not_preferred() | ||||
| { | ||||
| 	local ssid= i=0 mode= mac= enc= freq= chan= pref=false | ||||
|  | ||||
| 	while [ ${i} -le ${APS} ]; do | ||||
| @@ -594,7 +595,8 @@ iwconfig_connect_not_preferred() { | ||||
| 	return 1 | ||||
| } | ||||
|  | ||||
| iwconfig_defaults() { | ||||
| iwconfig_defaults() | ||||
| { | ||||
| 	local x= | ||||
| 	for x in txpower rate rts frag; do | ||||
| 	    iwconfig "${IFACE}" "${x}" auto 2>/dev/null | ||||
| @@ -606,7 +608,8 @@ iwconfig_defaults() { | ||||
| 	iwconfig "${IFACE}" essid off 2>/dev/null | ||||
| } | ||||
|  | ||||
| iwconfig_configure() { | ||||
| iwconfig_configure() | ||||
| { | ||||
| 	local x= APS= | ||||
| 	eval SSID=\$ssid_${IFVAR} | ||||
|  | ||||
| @@ -681,7 +684,8 @@ iwconfig_configure() { | ||||
| 	return 1 | ||||
| } | ||||
|  | ||||
| iwconfig_pre_start() { | ||||
| iwconfig_pre_start() | ||||
| { | ||||
| 	# We don't configure wireless if we're being called from | ||||
| 	# the background | ||||
| 	yesno ${IN_BACKGROUND} && return 0 | ||||
| @@ -748,11 +752,10 @@ iwconfig_pre_start() { | ||||
| 	return 1 | ||||
| } | ||||
|  | ||||
| iwconfig_post_stop() { | ||||
| iwconfig_post_stop() | ||||
| { | ||||
| 	yesno ${IN_BACKGROUND} && return 0 | ||||
| 	_exists || return 0 | ||||
| 	iwconfig_defaults | ||||
| 	iwconfig "${IFACE}" txpower off 2>/dev/null | ||||
| } | ||||
|  | ||||
| # vim: set ts=4  | ||||
|   | ||||
| @@ -1,30 +1,10 @@ | ||||
| # Copyright 2007 Roy Marples | ||||
| # Copyright 2007-2008 Roy Marples | ||||
| # All rights reserved | ||||
|  | ||||
| # Redistribution and use in source and binary forms, with or without | ||||
| # modification, are permitted provided that the following conditions | ||||
| # are met: | ||||
| # 1. Redistributions of source code must retain the above copyright | ||||
| #    notice, this list of conditions and the following disclaimer. | ||||
| # 2. Redistributions in binary form must reproduce the above copyright | ||||
| #    notice, this list of conditions and the following disclaimer in the | ||||
| #    documentation and/or other materials provided with the distribution. | ||||
| # | ||||
| # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND | ||||
| # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||||
| # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||||
| # ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||||
| # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||||
| # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||||
| # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||||
| # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||||
| # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||||
| # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||||
| # SUCH DAMAGE. | ||||
|  | ||||
| _config_vars="$_config_vars plug_timeout" | ||||
|  | ||||
| netplugd_depend() { | ||||
| netplugd_depend() | ||||
| { | ||||
| 	program start /sbin/netplugd | ||||
| 	after macnet rename | ||||
| 	before interface | ||||
| @@ -34,7 +14,8 @@ netplugd_depend() { | ||||
| 	before ifplugd | ||||
| } | ||||
|  | ||||
| netplugd_pre_start() { | ||||
| netplugd_pre_start() | ||||
| { | ||||
| 	local pidfile="/var/run/netplugd-${IFACE}.pid" timeout= | ||||
|  | ||||
| 	# We don't start netplug if we're being called from the background | ||||
| @@ -99,7 +80,8 @@ netplugd_pre_start() { | ||||
| 	exit 1 | ||||
| } | ||||
|  | ||||
| netplugd_stop() { | ||||
| netplugd_stop() | ||||
| { | ||||
| 	yesno ${IN_BACKGROUND} && return 0 | ||||
|  | ||||
| 	local pidfile="/var/run/netplugd-${IFACE}.pid" | ||||
| @@ -110,5 +92,3 @@ netplugd_stop() { | ||||
| 		--pidfile "${pidfile}" | ||||
| 	eend $? | ||||
| } | ||||
|  | ||||
| # vim: set ts=4 : | ||||
|   | ||||
| @@ -1,44 +1,27 @@ | ||||
| # Copyright 2005-2007 Gentoo Foundation | ||||
| # Copyright 2007 Roy Marples | ||||
| # Copyright 2007-2008 Roy Marples | ||||
| # All rights reserved | ||||
|  | ||||
| # Redistribution and use in source and binary forms, with or without | ||||
| # modification, are permitted provided that the following conditions | ||||
| # are met: | ||||
| # 1. Redistributions of source code must retain the above copyright | ||||
| #    notice, this list of conditions and the following disclaimer. | ||||
| # 2. Redistributions in binary form must reproduce the above copyright | ||||
| #    notice, this list of conditions and the following disclaimer in the | ||||
| #    documentation and/or other materials provided with the distribution. | ||||
| # | ||||
| # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND | ||||
| # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||||
| # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||||
| # ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||||
| # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||||
| # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||||
| # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||||
| # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||||
| # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||||
| # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||||
| # SUCH DAMAGE. | ||||
|  | ||||
| pppd_depend() { | ||||
| pppd_depend() | ||||
| { | ||||
| 	program /usr/sbin/pppd | ||||
| 	after interface | ||||
| 	before dhcp | ||||
| 	provide ppp | ||||
| } | ||||
|  | ||||
| is_ppp() { | ||||
| is_ppp() | ||||
| { | ||||
| 	[ -e /var/run/ppp-"${IFACE}".pid ] | ||||
| } | ||||
|  | ||||
| requote() { | ||||
| requote() | ||||
| { | ||||
| 	printf "'%s' " "$@" | ||||
| } | ||||
|  | ||||
| pppd_pre_start() { | ||||
| pppd_pre_start() | ||||
| { | ||||
| 	# Interface has to be called ppp | ||||
| 	[ "${IFACE%%[0-9]*}" = "ppp" ] || return 0 | ||||
|  | ||||
| @@ -240,11 +223,13 @@ pppd_pre_start() { | ||||
| } | ||||
|  | ||||
| # Dummy function for users that still have config_ppp0="ppp" | ||||
| pppd_start() { | ||||
| pppd_start() | ||||
| { | ||||
| 	return 0 | ||||
| } | ||||
|  | ||||
| pppd_stop() { | ||||
| pppd_stop() | ||||
| { | ||||
| 	yesno ${IN_BACKGROUND} && return 0 | ||||
| 	local pidfile="/var/run/ppp-${IFACE}.pid" | ||||
|  | ||||
| @@ -256,5 +241,3 @@ pppd_stop() { | ||||
| 		--pidfile "${pidfile}" --retry 30 | ||||
| 	eend $? | ||||
| } | ||||
|  | ||||
| # vim: set ts=4 : | ||||
|   | ||||
| @@ -1,28 +1,8 @@ | ||||
| # Copyright 2007 Roy Marples | ||||
| # Copyright 2007-2008 Roy Marples | ||||
| # All rights reserved | ||||
|  | ||||
| # Redistribution and use in source and binary forms, with or without | ||||
| # modification, are permitted provided that the following conditions | ||||
| # are met: | ||||
| # 1. Redistributions of source code must retain the above copyright | ||||
| #    notice, this list of conditions and the following disclaimer. | ||||
| # 2. Redistributions in binary form must reproduce the above copyright | ||||
| #    notice, this list of conditions and the following disclaimer in the | ||||
| #    documentation and/or other materials provided with the distribution. | ||||
| # | ||||
| # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND | ||||
| # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||||
| # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||||
| # ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||||
| # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||||
| # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||||
| # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||||
| # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||||
| # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||||
| # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||||
| # SUCH DAMAGE. | ||||
|  | ||||
| pump_depend() { | ||||
| pump_depend() | ||||
| { | ||||
| 	program /sbin/pump | ||||
| 	after interface | ||||
| 	provide dhcp | ||||
| @@ -30,7 +10,8 @@ pump_depend() { | ||||
|  | ||||
| _config_vars="$_config_vars dhcp pump" | ||||
|  | ||||
| pump_start() { | ||||
| pump_start() | ||||
| { | ||||
| 	local args= opt= opts= | ||||
|  | ||||
| 	# Get our options | ||||
| @@ -60,7 +41,8 @@ pump_start() { | ||||
| 	return 0 | ||||
| } | ||||
|  | ||||
| pump_stop() { | ||||
| pump_stop() | ||||
| { | ||||
| 	# We check for a pump process first as querying for status | ||||
| 	# causes pump to spawn a process | ||||
| 	start-stop-daemon --quiet --test --stop --exec /sbin/pump || return 0 | ||||
| @@ -75,5 +57,3 @@ pump_stop() { | ||||
| 	pump --release --interface "${IFACE}" | ||||
| 	eend $? "Failed to stop pump" | ||||
| } | ||||
|  | ||||
| # vim: set ts=4 : | ||||
|   | ||||
| @@ -1,38 +1,20 @@ | ||||
| # Copyright 2007 Roy Marples | ||||
| # Copyright 2007-2008 Roy Marples | ||||
| # All rights reserved | ||||
|  | ||||
| # Redistribution and use in source and binary forms, with or without | ||||
| # modification, are permitted provided that the following conditions | ||||
| # are met: | ||||
| # 1. Redistributions of source code must retain the above copyright | ||||
| #    notice, this list of conditions and the following disclaimer. | ||||
| # 2. Redistributions in binary form must reproduce the above copyright | ||||
| #    notice, this list of conditions and the following disclaimer in the | ||||
| #    documentation and/or other materials provided with the distribution. | ||||
| # | ||||
| # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND | ||||
| # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||||
| # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||||
| # ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||||
| # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||||
| # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||||
| # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||||
| # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||||
| # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||||
| # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||||
| # SUCH DAMAGE. | ||||
|  | ||||
| tuntap_depend() { | ||||
| tuntap_depend() | ||||
| { | ||||
| 	before bridge interface macchanger | ||||
| } | ||||
|  | ||||
| _config_vars="$_config_vars tunctl" | ||||
|  | ||||
| _is_tuntap() { | ||||
| _is_tuntap() | ||||
| { | ||||
| 	[ -n "$(export SVCNAME="net.${IFACE}"; service_get_value tuntap)" ] | ||||
| } | ||||
|  | ||||
| tuntap_pre_start() { | ||||
| tuntap_pre_start() | ||||
| { | ||||
| 	local tuntap= | ||||
| 	eval tuntap=\$tuntap_${IFVAR} | ||||
|  | ||||
| @@ -61,7 +43,8 @@ tuntap_pre_start() { | ||||
| 	eend $? && _up && service_set_value tuntap "${tuntap}" | ||||
| } | ||||
|  | ||||
| tuntap_post_stop() { | ||||
| tuntap_post_stop() | ||||
| { | ||||
| 	_is_tuntap || return 0 | ||||
|  | ||||
| 	ebegin "Destroying Tun/Tap interface ${IFACE}" | ||||
| @@ -74,5 +57,3 @@ tuntap_post_stop() { | ||||
| 	fi | ||||
| 	eend $? | ||||
| } | ||||
|  | ||||
| # vim: set ts=4 : | ||||
|   | ||||
| @@ -1,28 +1,8 @@ | ||||
| # Copyright 2007 Roy Marples | ||||
| # Copyright 2007-2008 Roy Marples | ||||
| # All rights reserved | ||||
|  | ||||
| # Redistribution and use in source and binary forms, with or without | ||||
| # modification, are permitted provided that the following conditions | ||||
| # are met: | ||||
| # 1. Redistributions of source code must retain the above copyright | ||||
| #    notice, this list of conditions and the following disclaimer. | ||||
| # 2. Redistributions in binary form must reproduce the above copyright | ||||
| #    notice, this list of conditions and the following disclaimer in the | ||||
| #    documentation and/or other materials provided with the distribution. | ||||
| # | ||||
| # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND | ||||
| # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||||
| # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||||
| # ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||||
| # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||||
| # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||||
| # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||||
| # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||||
| # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||||
| # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||||
| # SUCH DAMAGE. | ||||
|  | ||||
| udhcpc_depend() { | ||||
| udhcpc_depend() | ||||
| { | ||||
| 	program start /sbin/udhcpc | ||||
| 	after interface | ||||
| 	provide dhcp | ||||
| @@ -30,7 +10,9 @@ udhcpc_depend() { | ||||
|  | ||||
| _config_vars="$_config_vars dhcp udhcpc" | ||||
|  | ||||
| udhcpc_start() { | ||||
| # WARNING:- The relies heavily on Gentoo patches and scripts for udhcpc | ||||
| udhcpc_start() | ||||
| { | ||||
| 	local args= opt= opts= pidfile="/var/run/udhcpc-${IFACE}.pid" | ||||
| 	local sendhost=true cachefile="/var/cache/udhcpc-${IFACE}.lease" | ||||
|  | ||||
| @@ -98,7 +80,8 @@ udhcpc_start() { | ||||
| 	return 0 | ||||
| } | ||||
|  | ||||
| udhcpc_stop() { | ||||
| udhcpc_stop() | ||||
| { | ||||
| 	local pidfile="/var/run/udhcpc-${IFACE}.pid" opts= | ||||
| 	[ ! -f "${pidfile}" ] && return 0 | ||||
|  | ||||
| @@ -120,5 +103,3 @@ udhcpc_stop() { | ||||
| 	start-stop-daemon --stop --exec /sbin/udhcpc --pidfile "${pidfile}" | ||||
| 	eend $? | ||||
| } | ||||
|  | ||||
| # vim: set ts=4 : | ||||
|   | ||||
| @@ -1,28 +1,8 @@ | ||||
| # Copyright 2007 Roy Marples | ||||
| # Copyright 2007-2008 Roy Marples | ||||
| # All rights reserved | ||||
|  | ||||
| # Redistribution and use in source and binary forms, with or without | ||||
| # modification, are permitted provided that the following conditions | ||||
| # are met: | ||||
| # 1. Redistributions of source code must retain the above copyright | ||||
| #    notice, this list of conditions and the following disclaimer. | ||||
| # 2. Redistributions in binary form must reproduce the above copyright | ||||
| #    notice, this list of conditions and the following disclaimer in the | ||||
| #    documentation and/or other materials provided with the distribution. | ||||
| # | ||||
| # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND | ||||
| # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||||
| # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||||
| # ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||||
| # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||||
| # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||||
| # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||||
| # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||||
| # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||||
| # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||||
| # SUCH DAMAGE. | ||||
|  | ||||
| vlan_depend() { | ||||
| vlan_depend() | ||||
| { | ||||
| 	program /sbin/vconfig | ||||
| 	after interface | ||||
| 	before dhcp | ||||
| @@ -30,18 +10,21 @@ vlan_depend() { | ||||
|  | ||||
| _config_vars="$_config_vars vlans" | ||||
|  | ||||
| _is_vlan() { | ||||
| _is_vlan() | ||||
| { | ||||
| 	[ ! -d /proc/net/vlan ] && return 1 | ||||
| 	[ -e /proc/net/vlan/"${IFACE}" ] && return 0 | ||||
| 	grep -Eq "^${IFACE}[[:space:]]+" /proc/net/vlan/config | ||||
| } | ||||
|  | ||||
| _get_vlans() { | ||||
| _get_vlans() | ||||
| { | ||||
| 	[ -e /proc/net/vlan/config ] || return 1 | ||||
| 	sed -n -e 's/^\(.*[0-9]\) \(.* \) .*'"${IFACE}"'$/\1/p' /proc/net/vlan/config | ||||
| } | ||||
|  | ||||
| _check_vlan() { | ||||
| _check_vlan() | ||||
| { | ||||
| 	if [ ! -d /proc/net/vlan ]; then | ||||
| 		modprobe 8021q | ||||
| 		if [ ! -d /proc/net/vlan ]; then | ||||
| @@ -51,7 +34,8 @@ _check_vlan() { | ||||
| 	fi | ||||
| } | ||||
|  | ||||
| vlan_pre_start() { | ||||
| vlan_pre_start() | ||||
| { | ||||
| 	local vc="$(_get_array "vconfig_${IFVAR}")" | ||||
| 	[ -z "${vc}" ] && return 0 | ||||
|  | ||||
| @@ -79,7 +63,8 @@ vlan_pre_start() { | ||||
| 	done | ||||
| } | ||||
|  | ||||
| vlan_post_start() { | ||||
| vlan_post_start() | ||||
| { | ||||
| 	local vlans= | ||||
| 	eval vlans=\$vlans_${IFACE} | ||||
| 	[ -z "${vlans}" ] && return 0 | ||||
| @@ -114,7 +99,8 @@ vlan_post_start() { | ||||
| 	return 0 | ||||
| } | ||||
|  | ||||
| vlan_post_stop() { | ||||
| vlan_post_stop() | ||||
| { | ||||
| 	local vlan= | ||||
|  | ||||
| 	for vlan in $(_get_vlans); do | ||||
| @@ -130,5 +116,3 @@ vlan_post_stop() { | ||||
|  | ||||
| 	return 0 | ||||
| } | ||||
|  | ||||
| # vim: set ts=4 : | ||||
|   | ||||
| @@ -1,28 +1,8 @@ | ||||
| # Copyright 2007 Roy Marples | ||||
| # Copyright 2007-2008 Roy Marples | ||||
| # All rights reserved | ||||
|  | ||||
| # Redistribution and use in source and binary forms, with or without | ||||
| # modification, are permitted provided that the following conditions | ||||
| # are met: | ||||
| # 1. Redistributions of source code must retain the above copyright | ||||
| #    notice, this list of conditions and the following disclaimer. | ||||
| # 2. Redistributions in binary form must reproduce the above copyright | ||||
| #    notice, this list of conditions and the following disclaimer in the | ||||
| #    documentation and/or other materials provided with the distribution. | ||||
| # | ||||
| # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND | ||||
| # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||||
| # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||||
| # ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||||
| # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||||
| # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||||
| # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||||
| # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||||
| # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||||
| # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||||
| # SUCH DAMAGE. | ||||
|  | ||||
| dhclient_depend() { | ||||
| dhclient_depend() | ||||
| { | ||||
| 	after interface | ||||
| 	program start /sbin/dhclient | ||||
| 	provide dhcp | ||||
| @@ -30,7 +10,8 @@ dhclient_depend() { | ||||
|  | ||||
| _config_vars="$_config_vars dhcp dhcpcd" | ||||
|  | ||||
| dhclient_start() { | ||||
| dhclient_start() | ||||
| { | ||||
| 	local args= opt= opts= pidfile="/var/run/dhclient-${IFACE}.pid" | ||||
| 	local sendhost=true dconf= | ||||
|  | ||||
| @@ -63,14 +44,16 @@ dhclient_start() { | ||||
| 	# Bring up DHCP for this interface | ||||
| 	ebegin "Running dhclient" | ||||
| 	echo "${dhconf}" | start-stop-daemon --start --exec /sbin/dhclient \ | ||||
| 		--pidfile "${pidfile}" -- ${args} -q -1 -pf "${pidfile}" "${IFACE}" | ||||
| 		--pidfile "${pidfile}" \ | ||||
| 		-- ${args} -q -1 -pf "${pidfile}" "${IFACE}" | ||||
| 	eend $? || return 1 | ||||
|  | ||||
| 	_show_address | ||||
| 	return 0 | ||||
| } | ||||
|  | ||||
| dhclient_stop() { | ||||
| dhclient_stop() | ||||
| { | ||||
| 	local pidfile="/var/run/dhclient-${IFACE}.pid" opts= | ||||
| 	[ ! -f "${pidfile}" ] && return 0 | ||||
|  | ||||
| @@ -90,5 +73,3 @@ dhclient_stop() { | ||||
| 	esac | ||||
| 	eend $? | ||||
| } | ||||
|  | ||||
| # vim: set ts=4 : | ||||
|   | ||||
| @@ -1,28 +1,8 @@ | ||||
| # Copyright 2007 Roy Marples | ||||
| # Copyright 2007-2008 Roy Marples | ||||
| # All rights reserved | ||||
|  | ||||
| # Redistribution and use in source and binary forms, with or without | ||||
| # modification, are permitted provided that the following conditions | ||||
| # are met: | ||||
| # 1. Redistributions of source code must retain the above copyright | ||||
| #    notice, this list of conditions and the following disclaimer. | ||||
| # 2. Redistributions in binary form must reproduce the above copyright | ||||
| #    notice, this list of conditions and the following disclaimer in the | ||||
| #    documentation and/or other materials provided with the distribution. | ||||
| # | ||||
| # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND | ||||
| # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||||
| # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||||
| # ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||||
| # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||||
| # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||||
| # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||||
| # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||||
| # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||||
| # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||||
| # SUCH DAMAGE. | ||||
|  | ||||
| dhcpcd_depend() { | ||||
| dhcpcd_depend() | ||||
| { | ||||
| 	after interface | ||||
| 	program start dhcpcd | ||||
| 	provide dhcp | ||||
| @@ -33,7 +13,8 @@ dhcpcd_depend() { | ||||
|  | ||||
| _config_vars="$_config_vars dhcp dhcpcd" | ||||
|  | ||||
| dhcpcd_start() { | ||||
| dhcpcd_start() | ||||
| { | ||||
| 	local args= opt= opts= pidfile="/var/run/dhcpcd-${IFACE}.pid" | ||||
|  | ||||
| 	eval args=\$dhcpcd_${IFVAR} | ||||
| @@ -66,7 +47,8 @@ dhcpcd_start() { | ||||
| 	return 0 | ||||
| } | ||||
|  | ||||
| dhcpcd_stop() { | ||||
| dhcpcd_stop() | ||||
| { | ||||
| 	local pidfile="/var/run/dhcpcd-${IFACE}.pid" opts= sig=SIGTERM | ||||
| 	[ ! -f "${pidfile}" ] && return 0 | ||||
|  | ||||
| @@ -76,8 +58,6 @@ dhcpcd_stop() { | ||||
| 	case " ${opts} " in | ||||
| 		*" release "*) sig=SIGHUP;; | ||||
| 	esac | ||||
| 	start-stop-daemon --stop --quiet --signal "${sig}" --pidfile "${pidfile}" | ||||
| 	start-stop-daemon --stop --quiet --signal ${sig} --pidfile "${pidfile}" | ||||
| 	eend $? | ||||
| } | ||||
|  | ||||
| # vim: set ts=4 : | ||||
|   | ||||
| @@ -1,34 +1,15 @@ | ||||
| # Copyright 2007 Roy Marples | ||||
| # Copyright 2007-2008 Roy Marples | ||||
| # All rights reserved | ||||
|  | ||||
| # Redistribution and use in source and binary forms, with or without | ||||
| # modification, are permitted provided that the following conditions | ||||
| # are met: | ||||
| # 1. Redistributions of source code must retain the above copyright | ||||
| #    notice, this list of conditions and the following disclaimer. | ||||
| # 2. Redistributions in binary form must reproduce the above copyright | ||||
| #    notice, this list of conditions and the following disclaimer in the | ||||
| #    documentation and/or other materials provided with the distribution. | ||||
| # | ||||
| # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND | ||||
| # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||||
| # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||||
| # ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||||
| # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||||
| # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||||
| # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||||
| # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||||
| # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||||
| # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||||
| # SUCH DAMAGE. | ||||
|  | ||||
| macchanger_depend() { | ||||
| macchanger_depend() | ||||
| { | ||||
| 	before macnet | ||||
| } | ||||
|  | ||||
| _config_vars="$_config_vars mac" | ||||
|  | ||||
| macchanger_pre_start() { | ||||
| macchanger_pre_start() | ||||
| { | ||||
| 	# We don't change MAC addresses from background | ||||
| 	yesno ${IN_BACKGROUND} && return 0 | ||||
|  | ||||
| @@ -49,7 +30,8 @@ macchanger_pre_start() { | ||||
| 	case "${mac}" in | ||||
| 		# specific mac-addr | ||||
| 		${hex}:${hex}:${hex}:${hex}:${hex}:${hex}) | ||||
| 			# We don't need macchanger to change to a specific mac address | ||||
| 			# We don't need macchanger to change to a specific | ||||
| 			# mac address | ||||
| 			_set_mac_address "${mac}" | ||||
| 			if eend "$?"; then | ||||
| 				mac=$(_get_mac_address) | ||||
| @@ -107,5 +89,3 @@ macchanger_pre_start() { | ||||
|  | ||||
| 	return 0 | ||||
| } | ||||
|  | ||||
| # vim: set ts=4 : | ||||
|   | ||||
| @@ -1,33 +1,14 @@ | ||||
| # Copyright 2007 Roy Marples | ||||
| # Copyright 2007-2008 Roy Marples | ||||
| # All rights reserved | ||||
|  | ||||
| # Redistribution and use in source and binary forms, with or without | ||||
| # modification, are permitted provided that the following conditions | ||||
| # are met: | ||||
| # 1. Redistributions of source code must retain the above copyright | ||||
| #    notice, this list of conditions and the following disclaimer. | ||||
| # 2. Redistributions in binary form must reproduce the above copyright | ||||
| #    notice, this list of conditions and the following disclaimer in the | ||||
| #    documentation and/or other materials provided with the distribution. | ||||
| # | ||||
| # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND | ||||
| # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||||
| # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||||
| # ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||||
| # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||||
| # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||||
| # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||||
| # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||||
| # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||||
| # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||||
| # SUCH DAMAGE. | ||||
|  | ||||
| macnet_depend() { | ||||
| macnet_depend() | ||||
| { | ||||
| 	before rename interface wireless | ||||
| 	after macchanger | ||||
| } | ||||
|  | ||||
| macnet_pre_start() { | ||||
| macnet_pre_start() | ||||
| { | ||||
| 	local mac=$(_get_mac_address 2>/dev/null) | ||||
| 	[ -z "${mac}" ] && return 0 | ||||
|  | ||||
| @@ -36,5 +17,3 @@ macnet_pre_start() { | ||||
| 	_configure_variables "${mac}" | ||||
| 	veend 0 | ||||
| } | ||||
|  | ||||
| # vim: set ts=4 : | ||||
|   | ||||
| @@ -1,33 +1,14 @@ | ||||
| # Copyright 2007 Roy Marples | ||||
| # Copyright 2007-2008 Roy Marples | ||||
| # All rights reserved | ||||
|  | ||||
| # Redistribution and use in source and binary forms, with or without | ||||
| # modification, are permitted provided that the following conditions | ||||
| # are met: | ||||
| # 1. Redistributions of source code must retain the above copyright | ||||
| #    notice, this list of conditions and the following disclaimer. | ||||
| # 2. Redistributions in binary form must reproduce the above copyright | ||||
| #    notice, this list of conditions and the following disclaimer in the | ||||
| #    documentation and/or other materials provided with the distribution. | ||||
| # | ||||
| # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND | ||||
| # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||||
| # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||||
| # ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||||
| # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||||
| # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||||
| # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||||
| # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||||
| # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||||
| # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||||
| # SUCH DAMAGE. | ||||
|  | ||||
| ssidnet_depend() { | ||||
| ssidnet_depend() | ||||
| { | ||||
| 	before interface system | ||||
| 	after wireless | ||||
| } | ||||
|  | ||||
| ssidnet_pre_start() { | ||||
| ssidnet_pre_start() | ||||
| { | ||||
| 	[ -z "${SSID}" -a -z "${SSIDVAR}" ] && return 0 | ||||
|  | ||||
| 	local mac=$(_get_ap_mac_address | sed -e 's/://g') x= | ||||
| @@ -41,5 +22,3 @@ ssidnet_pre_start() { | ||||
|  | ||||
| 	veend 0 | ||||
| } | ||||
|  | ||||
| # vim: set ts=4 : | ||||
|   | ||||
| @@ -1,37 +1,18 @@ | ||||
| # Copyright 2007 Roy Marples | ||||
| # Copyright 2007-2008 Roy Marples | ||||
| # All rights reserved | ||||
|  | ||||
| # Redistribution and use in source and binary forms, with or without | ||||
| # modification, are permitted provided that the following conditions | ||||
| # are met: | ||||
| # 1. Redistributions of source code must retain the above copyright | ||||
| #    notice, this list of conditions and the following disclaimer. | ||||
| # 2. Redistributions in binary form must reproduce the above copyright | ||||
| #    notice, this list of conditions and the following disclaimer in the | ||||
| #    documentation and/or other materials provided with the distribution. | ||||
| # | ||||
| # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND | ||||
| # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||||
| # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||||
| # ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||||
| # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||||
| # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||||
| # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||||
| # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||||
| # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||||
| # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||||
| # SUCH DAMAGE. | ||||
|  | ||||
| _config_vars="$_config_vars dns_servers dns_domain dns_search" | ||||
| _config_vars="$_config_vars dns_sortlist dns_options" | ||||
| _config_vars="$_config_vars ntp_servers nis_servers nis_domain" | ||||
|  | ||||
| system_depend() { | ||||
| system_depend() | ||||
| { | ||||
| 	after interface | ||||
| 	before dhcp | ||||
| } | ||||
|  | ||||
| _system_dns() { | ||||
| _system_dns() | ||||
| { | ||||
| 	local servers= domain= search= sortlist= options= x= | ||||
|  | ||||
| 	eval servers=\$dns_servers_${IFVAR} | ||||
| @@ -72,7 +53,8 @@ _system_dns() { | ||||
| 	fi | ||||
| } | ||||
|  | ||||
| _system_ntp() { | ||||
| _system_ntp() | ||||
| { | ||||
| 	local servers= buffer= x= | ||||
|  | ||||
| 	eval servers=\$ntp_servers_${IFVAR} | ||||
| @@ -92,7 +74,8 @@ _system_ntp() { | ||||
| 	chmod 644 /etc/ntp.conf | ||||
| } | ||||
|  | ||||
| _system_nis() { | ||||
| _system_nis() | ||||
| { | ||||
| 	local servers= domain= x= buffer= | ||||
|  | ||||
| 	eval servers=\$nis_servers_${IFVAR} | ||||
| @@ -124,12 +107,11 @@ _system_nis() { | ||||
| 	chmod 644 /etc/yp.conf | ||||
| } | ||||
|  | ||||
| system_pre_start() { | ||||
| system_pre_start() | ||||
| { | ||||
| 	_system_dns | ||||
| 	_system_ntp  | ||||
| 	_system_nis  | ||||
|  | ||||
| 	return 0 | ||||
| } | ||||
|  | ||||
| # vim: set ts=4 : | ||||
|   | ||||
| @@ -1,28 +1,8 @@ | ||||
| # Copyright 2007 Roy Marples | ||||
| # Copyright 2007-2008 Roy Marples | ||||
| # All rights reserved | ||||
|  | ||||
| # Redistribution and use in source and binary forms, with or without | ||||
| # modification, are permitted provided that the following conditions | ||||
| # are met: | ||||
| # 1. Redistributions of source code must retain the above copyright | ||||
| #    notice, this list of conditions and the following disclaimer. | ||||
| # 2. Redistributions in binary form must reproduce the above copyright | ||||
| #    notice, this list of conditions and the following disclaimer in the | ||||
| #    documentation and/or other materials provided with the distribution. | ||||
| # | ||||
| # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND | ||||
| # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||||
| # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||||
| # ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||||
| # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||||
| # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||||
| # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||||
| # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||||
| # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||||
| # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||||
| # SUCH DAMAGE. | ||||
|  | ||||
| wpa_supplicant_depend() { | ||||
| wpa_supplicant_depend() | ||||
| { | ||||
| 	if [ -x /usr/sbin/wpa_supplicant ]; then | ||||
| 		program start /usr/sbin/wpa_supplicant | ||||
| 	else | ||||
| @@ -39,7 +19,8 @@ wpa_supplicant_depend() { | ||||
| # Only set these functions if not set already | ||||
| # IE, prefer to use iwconfig | ||||
| if ! type _get_ssid >/dev/null 2>&1; then | ||||
| _get_ssid() { | ||||
| _get_ssid() | ||||
| { | ||||
| 	local timeout=5 ssid= | ||||
|  | ||||
| 	while [ ${timeout} -gt 0 ]; do | ||||
| @@ -55,13 +36,15 @@ _get_ssid() { | ||||
| 	return 1 | ||||
| } | ||||
|  | ||||
| _get_ap_mac_address() { | ||||
| _get_ap_mac_address() | ||||
| { | ||||
| 	wpa_cli -i"${IFACE}" status | sed -n -e 's/^bssid=\(.*\)$/\1/p' \ | ||||
| 		| tr '[:lower:]' '[:upper:]' | ||||
| } | ||||
| fi | ||||
|  | ||||
| wpa_supplicant_pre_start() { | ||||
| wpa_supplicant_pre_start() | ||||
| { | ||||
| 	local opts= cfgfile= ctrl_dir= wireless=true | ||||
| 	local wpas=/usr/sbin/wpa_supplicant wpac=/usr/bin/wpa_cli | ||||
|  | ||||
| @@ -80,7 +63,8 @@ wpa_supplicant_pre_start() { | ||||
| 	# We don't configure wireless if we're being called from | ||||
| 	# the background unless we're not currently running | ||||
| 	if yesno ${IN_BACKGROUND}; then | ||||
| 		if ${wireless} && service_started_daemon "${SVCNAME}" "${wpas}"; then | ||||
| 		if ${wireless} && \ | ||||
| 		service_started_daemon "${SVCNAME}" "${wpas}"; then | ||||
| 			SSID=$(_get_ssid "${IFACE}") | ||||
| 			SSIDVAR=$(_shell_var "${SSID}") | ||||
| 			service_set_value "SSID" "${SSID}" | ||||
| @@ -163,7 +147,8 @@ wpa_supplicant_pre_start() { | ||||
| 	ebegin "Starting wpa_cli on" "${IFACE}" | ||||
| 	start-stop-daemon --start --exec "${wpac}" \ | ||||
| 		--pidfile "/var/run/wpa_cli-${IFACE}.pid" \ | ||||
| 		-- -a /etc/wpa_supplicant/wpa_cli.sh -p "${ctrl_dir}" -i "${IFACE}" \ | ||||
| 		-- -a /etc/wpa_supplicant/wpa_cli.sh \ | ||||
| 		-p "${ctrl_dir}" -i "${IFACE}" \ | ||||
| 		-P "/var/run/wpa_cli-${IFACE}.pid" -B | ||||
| 	if eend $?; then | ||||
| 		ebegin "Backgrounding ..." | ||||
| @@ -177,7 +162,8 @@ wpa_supplicant_pre_start() { | ||||
| 	return 1 | ||||
| } | ||||
|  | ||||
| wpa_supplicant_post_stop() { | ||||
| wpa_supplicant_post_stop() | ||||
| { | ||||
| 	local wpas=/usr/sbin/wpa_supplicant wpac=/usr/bin/wpa_cli | ||||
|  | ||||
| 	if [ ! -x "${wpas}" ]; then | ||||
| @@ -209,5 +195,3 @@ wpa_supplicant_post_stop() { | ||||
| 	[ -S "/var/run/wpa_supplicant/${IFACE}" ] \ | ||||
| 		&& rm -f "/var/run/wpa_supplicant/${IFACE}" | ||||
| } | ||||
|  | ||||
| # vim: set ts=4 : | ||||
|   | ||||
		Reference in New Issue
	
	Block a user