From 5de53f176c8c650017052722bd61368d08023f82 Mon Sep 17 00:00:00 2001 From: Roy Marples Date: Fri, 11 Jan 2008 15:08:57 +0000 Subject: Adopt a more C style for scripts and remove vim settings. --- net.Linux/adsl.sh | 35 ++++------------ net.Linux/apipa.sh | 34 ++++----------- net.Linux/arping.sh | 37 ++++------------- net.Linux/bonding.sh | 37 ++++------------- net.Linux/br2684ctl.sh | 37 ++++------------- net.Linux/bridge.sh | 37 ++++------------- net.Linux/ccwgroup.sh | 47 +++++++-------------- net.Linux/clip.sh | 32 ++++++++------ net.Linux/ifconfig.sh | 83 +++++++++++++++++------------------- net.Linux/ifplugd.sh | 34 ++++----------- net.Linux/ip6to4.sh | 31 +++----------- net.Linux/ipppd.sh | 34 ++++----------- net.Linux/iproute2.sh | 87 +++++++++++++++++++------------------- net.Linux/iwconfig.sh | 111 +++++++++++++++++++++++++------------------------ net.Linux/netplugd.sh | 34 ++++----------- net.Linux/pppd.sh | 43 ++++++------------- net.Linux/pump.sh | 34 ++++----------- net.Linux/tuntap.sh | 37 ++++------------- net.Linux/udhcpc.sh | 35 ++++------------ net.Linux/vlan.sh | 46 +++++++------------- 20 files changed, 301 insertions(+), 604 deletions(-) (limited to 'net.Linux') diff --git a/net.Linux/adsl.sh b/net.Linux/adsl.sh index 1b8bcef..d866c59 100644 --- a/net.Linux/adsl.sh +++ b/net.Linux/adsl.sh @@ -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 : diff --git a/net.Linux/apipa.sh b/net.Linux/apipa.sh index 8a1653b..3236466 100644 --- a/net.Linux/apipa.sh +++ b/net.Linux/apipa.sh @@ -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 : diff --git a/net.Linux/arping.sh b/net.Linux/arping.sh index 25fa3ab..7bea0d0 100644 --- a/net.Linux/arping.sh +++ b/net.Linux/arping.sh @@ -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 : diff --git a/net.Linux/bonding.sh b/net.Linux/bonding.sh index 433778d..122d70a 100644 --- a/net.Linux/bonding.sh +++ b/net.Linux/bonding.sh @@ -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 : diff --git a/net.Linux/br2684ctl.sh b/net.Linux/br2684ctl.sh index 06efc3c..8d15f78 100644 --- a/net.Linux/br2684ctl.sh +++ b/net.Linux/br2684ctl.sh @@ -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 : diff --git a/net.Linux/bridge.sh b/net.Linux/bridge.sh index c4c62d8..b35e6a6 100644 --- a/net.Linux/bridge.sh +++ b/net.Linux/bridge.sh @@ -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 : diff --git a/net.Linux/ccwgroup.sh b/net.Linux/ccwgroup.sh index 98d3d56..dcdb7b1 100644 --- a/net.Linux/ccwgroup.sh +++ b/net.Linux/ccwgroup.sh @@ -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 @@ -47,17 +28,18 @@ ccwgroup_pre_start() { ccw="${ccw}${ccw:+,}${x}" done if [ -e /sys/devices/qeth/"${first}" ]; then - echo "0" > /sys/devices/qeth/"${first}"/online + echo "0" >/sys/devices/qeth/"${first}"/online else - echo "${ccw}" > /sys/bus/ccwgroup/drivers/qeth/group + echo "${ccw}" >/sys/bus/ccwgroup/drivers/qeth/group fi eval layer2=\$qeth_layer2_${IFVAR} echo "${layer2:-0}" > /sys/devices/qeth/"${first}"/layer2 - echo "1" > /sys/devices/qeth/"${first}"/online + echo "1" >/sys/devices/qeth/"${first}"/online eend $? } -ccwgroup_pre_stop() { +ccwgroup_pre_stop() +{ # Erase any existing ccwgroup to be safe service_set_value ccwgroup_device "" @@ -73,14 +55,13 @@ 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 einfo "Disabling ccwgroup on ${iface}" - echo "0" > /sys/devices/qeth/"${device}"/online - echo "1" > /sys/devices/qeth/"${device}"/ungroup + echo "0" >/sys/devices/qeth/"${device}"/online + echo "1" >/sys/devices/qeth/"${device}"/ungroup eend $? } - -# vim: set ts=4 : diff --git a/net.Linux/clip.sh b/net.Linux/clip.sh index 329716b..78344d2 100644 --- a/net.Linux/clip.sh +++ b/net.Linux/clip.sh @@ -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 : diff --git a/net.Linux/ifconfig.sh b/net.Linux/ifconfig.sh index ff5c543..12c71eb 100644 --- a/net.Linux/ifconfig.sh +++ b/net.Linux/ifconfig.sh @@ -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 : diff --git a/net.Linux/ifplugd.sh b/net.Linux/ifplugd.sh index e4600b7..098e68d 100644 --- a/net.Linux/ifplugd.sh +++ b/net.Linux/ifplugd.sh @@ -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 : diff --git a/net.Linux/ip6to4.sh b/net.Linux/ip6to4.sh index d428c4a..0216484 100644 --- a/net.Linux/ip6to4.sh +++ b/net.Linux/ip6to4.sh @@ -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 : diff --git a/net.Linux/ipppd.sh b/net.Linux/ipppd.sh index 6093884..5c633ad 100644 --- a/net.Linux/ipppd.sh +++ b/net.Linux/ipppd.sh @@ -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 : diff --git a/net.Linux/iproute2.sh b/net.Linux/iproute2.sh index 3fc8620..8cfcae9 100644 --- a/net.Linux/iproute2.sh +++ b/net.Linux/iproute2.sh @@ -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() { - LC_ALL=C ip addr show dev "${IFACE}" | \ +_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 : diff --git a/net.Linux/iwconfig.sh b/net.Linux/iwconfig.sh index 13f43d0..89e466a 100644 --- a/net.Linux/iwconfig.sh +++ b/net.Linux/iwconfig.sh @@ -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 preferred_aps blacklist_aps" - -iwconfig_depend() { +_config_vars="$_config_vars ssid mode associate_timeout sleep_scan" +_config_vars="$_config_vars preferred_aps blacklist_aps" + +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 diff --git a/net.Linux/netplugd.sh b/net.Linux/netplugd.sh index 8b77cd7..cad380e 100644 --- a/net.Linux/netplugd.sh +++ b/net.Linux/netplugd.sh @@ -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 : diff --git a/net.Linux/pppd.sh b/net.Linux/pppd.sh index 510a63a..4ab2007 100644 --- a/net.Linux/pppd.sh +++ b/net.Linux/pppd.sh @@ -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 : diff --git a/net.Linux/pump.sh b/net.Linux/pump.sh index 75c981b..dd399ab 100644 --- a/net.Linux/pump.sh +++ b/net.Linux/pump.sh @@ -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 : diff --git a/net.Linux/tuntap.sh b/net.Linux/tuntap.sh index d0fa5a8..64b09d7 100644 --- a/net.Linux/tuntap.sh +++ b/net.Linux/tuntap.sh @@ -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 : diff --git a/net.Linux/udhcpc.sh b/net.Linux/udhcpc.sh index 468d056..542c7e0 100644 --- a/net.Linux/udhcpc.sh +++ b/net.Linux/udhcpc.sh @@ -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 : diff --git a/net.Linux/vlan.sh b/net.Linux/vlan.sh index ec07561..f8cc4fd 100644 --- a/net.Linux/vlan.sh +++ b/net.Linux/vlan.sh @@ -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 : -- cgit v1.2.3