diff options
author | Christian Heim <phreak@gentoo.org> | 2006-07-11 08:41:32 +0000 |
---|---|---|
committer | Christian Heim <phreak@gentoo.org> | 2006-07-11 08:41:32 +0000 |
commit | 9bd77d932c6b6cde0496026733b925b26c65951c (patch) | |
tree | bfdba9ec0f6b0b371fd02557fdfe73c495feb19a | |
parent | Merging r2121 (diff) | |
download | baselayout-vserver-9bd77d932c6b6cde0496026733b925b26c65951c.tar.gz baselayout-vserver-9bd77d932c6b6cde0496026733b925b26c65951c.tar.bz2 baselayout-vserver-9bd77d932c6b6cde0496026733b925b26c65951c.zip |
Merging r2145 from upstream baselayout
svn path=/baselayout-vserver/branches/baselayout-1_12/; revision=400
-rw-r--r-- | ChangeLog | 10 | ||||
-rw-r--r-- | etc/inputrc | 9 | ||||
-rw-r--r-- | net-scripts/conf.d/net.example | 13 | ||||
-rw-r--r-- | net-scripts/net/iwconfig.sh | 87 | ||||
-rwxr-xr-x | sbin/rc-services.sh | 40 | ||||
-rwxr-xr-x | sbin/runscript.sh | 42 |
6 files changed, 113 insertions, 88 deletions
@@ -1,6 +1,16 @@ # ChangeLog for Gentoo System Intialization ("rc") scripts # Copyright 1999-2006 Gentoo Foundation; Distributed under the GPLv2 + 10 Jul 2006; Roy Marples <uberlord@gentoo.org>: + + Fixed some internal net dependencies with >1 active net service + Services can now be scheduled on any inactive services. + + 27 Jun 2006; Roy Marples <uberlord@gentoo.org>: + + Document that depend_eth0() only works in conf.d/net and + not conf.d/net.$profile, #137727. + 23 Jun 2006; Roy Marples <uberlord@gentoo.org>: Fix rc-status broken link reporting properly, #137656 diff --git a/etc/inputrc b/etc/inputrc index aaabc80..8126e2b 100644 --- a/etc/inputrc +++ b/etc/inputrc @@ -3,6 +3,14 @@ # For more information on how this file works, please see the # INITIALIZATION FILE section of the readline(3) man page # +# Quick dirty little note: +# To get the key sequence for binding, you can abuse bash. +# While running bash, hit CTRL+V, and then type the key sequence. +# So, typing 'ALT + left arrow' in Konsole gets you back: +# ^[[1;3D +# The readline entry to make this skip back a word will then be: +# "\e[1;3D" backward-word +# # do not bell on tab-completion #set bell-style none @@ -34,6 +42,7 @@ $if mode=emacs # konsole / xterm / rxvt (escape + arrow key) "\e\e[C": forward-word "\e\e[D": backward-word +# konsole (alt + arrow key) # aterm / eterm (control + arrow key) "\eOc": forward-word "\eOd": backward-word diff --git a/net-scripts/conf.d/net.example b/net-scripts/conf.d/net.example index 3038451..7f789b1 100644 --- a/net-scripts/conf.d/net.example +++ b/net-scripts/conf.d/net.example @@ -346,6 +346,8 @@ # depend_vlan1() { # need net.eth0 # } +# NOTE: depend functions only work in /etc/conf.d/net +# and not in profile configs such as /etc/conf.d/net.foo #----------------------------------------------------------------------------- # Bonding @@ -362,7 +364,8 @@ #depend_br0() { # need net.eth0 net.eth1 #} - +# NOTE: depend functions only work in /etc/conf.d/net +# and not in profile configs such as /etc/conf.d/net.foo #----------------------------------------------------------------------------- # PPP @@ -467,6 +470,8 @@ #depend_ppp0() { # need net.nas0 #} +# NOTE: depend functions only work in /etc/conf.d/net +# and not in profile configs such as /etc/conf.d/net.foo #----------------------------------------------------------------------------- # ADSL @@ -566,7 +571,8 @@ #depend_br0() { # need net.eth0 net.eth1 #} - +# NOTE: depend functions only work in /etc/conf.d/net +# and not in profile configs such as /etc/conf.d/net.foo # NOTE: This creates an interface called br0 - you can give the interface # any name you like @@ -613,11 +619,14 @@ # depend_6to4() { # need net.eth0 # } +# NOTE: depend functions only work in /etc/conf.d/net +# and not in profile configs such as /etc/conf.d/net.foo # To ensure that eth0 is configured before 6to4. Of course, the tunnel could be # any name and this also works for any configured interface. # NOTE: If you're not using iproute2 then your 6to4 tunnel has to be called # sit0 - otherwise use a different name like 6to4 in the example above. + #----------------------------------------------------------------------------- # System # For configuring system specifics such as domain, dns, ntp and nis servers diff --git a/net-scripts/net/iwconfig.sh b/net-scripts/net/iwconfig.sh index 8c9a4f9..9e31cda 100644 --- a/net-scripts/net/iwconfig.sh +++ b/net-scripts/net/iwconfig.sh @@ -63,7 +63,7 @@ iwconfig_exists() { [[ -L /sys/class/net/$1/wiphy ]] && return 0 [[ ! -e /proc/net/wireless ]] && return 1 - grep -q "^[ \t]*$1:" /proc/net/wireless + [[ $(</proc/net/wireless) =~ $'\n'"[ \t]*$1:" ]] } # char* iwconfig_get_wep_status(char *interface) @@ -71,10 +71,9 @@ iwconfig_exists() { # Echos a string showing whether WEP is enabled or disabled # for the given interface iwconfig_get_wep_status() { - local key=$(iwconfig "$1" | grep -i -o "Encryption key:[0-9,A-F]") local mode= status="disabled" - if [[ -n ${key} ]]; then + if [[ $(iwconfig "$1") =~ $'\n'" +Encryption key:[0-9,A-F]" ]]; then status="enabled" mode=$(iwconfig "$1" | sed -n -e 's/^.*Security mode:\(.*[^ ]\).*/\1/p') [[ -n ${mode} ]] && mode=" - ${mode}" @@ -116,6 +115,19 @@ iwconfig_get_mode() { iwgetid --mode "$1" | sed -n -e 's/^.*Mode:\(.*\)/\L\1/p' } +iwconfig_set_mode() { + local iface="$1" mode="$2" + [[ ${mode} == $(iwconfig_get_mode "${iface}") ]] && return 0 + + # Devicescape stack requires the interface to be down + interface_down "${iface}" + if ! iwconfig "${iface}" mode "${mode}" ; then + eerror "${iface} does not support setting the mode to \"${mode}\"" + return 1 + fi + interface_up "${iface}" +} + # char* iwconfig_get_type(char *interface) # # Returns the type of interface - the IEEE part @@ -208,14 +220,7 @@ iwconfig_setup_specific() { ESSIDVAR=$(bash_variable "${ESSID}") key=$(iwconfig_get_wep_key) - # We only change the mode if it's not the same - local cur_mode=$(iwconfig_get_mode "${iface}") - if [[ ${cur_mode} != "${mode}" ]]; then - if ! iwconfig "${iface}" mode "${mode}" ; then - eerror "${iface} does not support setting the mode to \"${mode}\"" - return 1 - fi - fi + iwconfig_set_mode "${iface}" "${mode}" channel="channel_${ifvar}" # We default the channel to 3 @@ -287,6 +292,12 @@ iwconfig_test_associated() { # Some drivers don't set MAC to a bogus value when assocation is lost/fails # whereas they do set link quality to 0 + # Use sysfs if we can + if [[ -e /sys/class/net/${iface}/carrier ]] ; then + [[ $(</sys/class/net/"${iface}"/carrier) == "1" ]] + return $? + fi + x="associate_test_${ifvar}" ttype=$(echo "${!x:-mac}" | tr '[:upper:]' '[:lower:]') if [[ ${ttype} != "mac" && ${ttype} != "quality" && ${ttype} != "all" ]]; then @@ -336,16 +347,10 @@ iwconfig_wait_for_association() { # so we can fail gracefully without even trying to connect iwconfig_associate() { local iface="$1" mode="${2:-managed}" - local mac="$3" wep_required="$4" w="(WEP Disabled)" + local mac="$3" wep_required="$4" freq="$5" w="(WEP Disabled)" local dessid="${ESSID//\\\\/\\\\}" key= - local cur_mode=$(iwconfig_get_mode "${iface}") - if [[ ${cur_mode} != "${mode}" ]]; then - if ! iwconfig "${iface}" mode "${mode}" ; then - eerror "Unable to change mode to ${mode}" - return 1 - fi - fi + iwconfig_set_mode "${iface}" "${mode}" if [[ ${ESSID} == "any" ]]; then iwconfig "${iface}" ap any 2>/dev/null @@ -373,6 +378,7 @@ iwconfig_associate() { [[ ${key} != "off" ]] && w=$(iwconfig_get_wep_status "${iface}") fi + [[ -n ${freq} ]] && iwconfig "${iface}" freq "${freq}" [[ -n ${mac} ]] && iwconfig "${iface}" ap "${mac}" if ! iwconfig "${iface}" essid "${ESSID}" ; then @@ -428,16 +434,7 @@ iwconfig_associate() { iwconfig_scan() { local iface="$1" mode= x= ifvar=$(bash_variable "$1") - # First, we may need to change mode to scan in - x="scan_mode_${ifvar}" - mode=$(echo "${!x}" | tr '[:upper:]' '[:lower:]') - if [[ -n ${mode} ]]; then - if ! iwconfig "${iface}" mode "${mode}" ; then - ewarn "${iface} does not support setting the mode to \"${mode}\"" - fi - fi - - # Next we set any private driver ioctls needed + # Set any private driver ioctls needed x="iwpriv_scan_pre_${ifvar}" if [[ -n ${!x} ]]; then if ! eval iwpriv "${iface}" "${!x}" ; then @@ -477,6 +474,9 @@ iwconfig_scan() { *'Encryption key:'*) enc[i]="${line#*:}" ;; + *Frequency:*) + freq[i]="${line#*:}" + ;; *Quality*) qual[i]="${line#*:}" qual[i]="${qual[i]%/*}" @@ -516,11 +516,6 @@ iwconfig_scan() { fi fi - # Change back mode if needed - x="mode_${ifvar}" - x=$(echo "${!x:-managed}" | tr '[:upper:]' '[:lower:]') - [[ ${mode} != "${x}" ]] && iwconfig "${iface}" mode "${x}" - # Strip any duplicates local i= j= x="${#mac[@]}" y= for (( i=0; i<x-1; i++ )) ; do @@ -537,6 +532,7 @@ iwconfig_scan() { unset essid[y] unset mode[y] unset enc[y] + unset freq[y] fi done done @@ -545,6 +541,7 @@ iwconfig_scan() { essid=( "${essid[@]}" ) mode=( "${mode[@]}" ) enc=( "${enc[@]}" ) + freq=( "${freq[@]}" ) for (( i=0; i<${#mac[@]}; i++ )); do # Don't like ad-hoc nodes by default @@ -559,6 +556,7 @@ iwconfig_scan() { essid_APs[i]="${essid[${sortline[x]}]}" mode_APs[i]="${mode[${sortline[x]}]}" enc_APs[i]="${enc[${sortline[x]}]}" + freq_APs[i]="${freq[${sortline[x]}]}" done return 0 @@ -630,6 +628,7 @@ iwconfig_scan_report() { unset mode_APs[i] unset mac_APs[i] unset enc_APs[i] + unset freq_APs[i] done # We need to squash our arrays so indexes work again @@ -637,6 +636,7 @@ iwconfig_scan_report() { mode_APs=( "${mode_APs[@]}" ) mac_APs=( "${mac_APs[@]}" ) enc_APs=( "${enc_APs[@]}" ) + freq_APs=( "${freq_APs[@]}" ) } # bool iwconfig_force_preferred(char *iface) @@ -679,7 +679,7 @@ iwconfig_connect_preferred() { if [[ ${essid} == "${essid_APs[i]}" ]]; then ESSID="${essid}" iwconfig_associate "${iface}" "${mode_APs[i]}" "${mac_APs[i]}" \ - "${enc_APs[i]}" && return 0 + "${enc_APs[i]}" "${freq_APs[i]}" && return 0 break fi done @@ -706,7 +706,7 @@ iwconfig_connect_not_preferred() { if ! ${has_preferred} ; then ESSID="${essid_APs[i]}" iwconfig_associate "${iface}" "${mode_APs[i]}" "${mac_APs[i]}" \ - "${enc_APs[i]}" && return 0 + "${enc_APs[i]}" "${freq_APs[i]}" && return 0 fi done @@ -750,11 +750,13 @@ iwconfig_strip_associated() { unset mode_Aps[j] unset mac_APs[j] unset enc_APs[j] + unset freq_APs[j] # We need to squash our arrays so that indexes work essid_APs=( "${essid_APs[@]}" ) mode_APs=( "${mode_APs[@]}" ) mac_APs=( "${mac_APs[@]}" ) enc_APs=( "${enc_APs[@]}" ) + freq_APs=( "${freq_APs[@]}" ) break fi done @@ -778,7 +780,7 @@ iwconfig_strip_associated() { # variables for the ESSID iwconfig_configure() { local iface="$1" e= x= ifvar=$(bash_variable "$1") - local -a essid_APs=() mac_APs=() mode_APs=() enc_APs=() + local -a essid_APs=() mac_APs=() mode_APs=() enc_APs=() freq_APs=() ESSID="essid_${ifvar}" ESSID="${!ESSID}" @@ -796,18 +798,9 @@ iwconfig_configure() { return 1 fi - # We only change the mode if it's not the same as some drivers - # only do managed and throw an error changing to managed - local cur_mode=$(iwconfig_get_mode "${iface}") - if [[ ${cur_mode} != "${x}" ]]; then - if ! iwconfig "${iface}" mode "${x}" ; then - eerror "${iface} does not support setting the mode to \"${x}\"" - return 1 - fi - fi - # Has an ESSID been forced? if [[ -n ${ESSID} ]]; then + iwconfig_set_mode "${iface}" "${x}" iwconfig_associate "${iface}" && return 0 [[ ${ESSID} == "any" ]] && iwconfig_force_preferred "${iface}" && return 0 diff --git a/sbin/rc-services.sh b/sbin/rc-services.sh index ef4ccf1..8fcd7c1 100755 --- a/sbin/rc-services.sh +++ b/sbin/rc-services.sh @@ -686,7 +686,7 @@ net_service() { [[ -n $1 && ${1%%.*} == "net" && ${1#*.} != "$1" ]] } -# bool is_net_up() +# bool is_net_up(char *exclude) # # Return true if service 'net' is considered up, else false. # @@ -697,29 +697,34 @@ net_service() { # so there have to be at least one other interface up. # yes All interfaces must be up. is_net_up() { - local netcount=0 - + local x= + case "${RC_NET_STRICT_CHECKING}" in none) return 0 ;; lo) - netcount="$(ls -1 "${svcdir}"/started/net.* 2> /dev/null | \ - egrep -c "\/net\..*$")" + service_started "net.lo" + return $? ;; - *) - netcount="$(ls -1 "${svcdir}"/started/net.* 2> /dev/null | \ - grep -v 'net\.lo' | egrep -c "\/net\..*$")" + yes) + for x in $(dolisting "/etc/runlevels/${BOOTLEVEL}/net.*") \ + $(dolisting "/etc/runlevels/${SOFTLEVEL}/net.*") ; do + local y="${x##*/}" + [[ ${y} == "$1" ]] && return 1 + service_started "${y}" || return 1 + done + return 0 ;; + *) + for x in $(dolisting "${svcdir}/started/net.*") ; do + local y="${x##*/}" + [[ ${y} == "$1" ]] && continue + [[ ${y} != "net.lo" ]] && return 0 + done + return 1 + ;; esac - - # Only worry about net.* services if this is the last one running, - # or if RC_NET_STRICT_CHECKING is set ... - if [[ ${netcount} -lt 1 || ${RC_NET_STRICT_CHECKING} == "yes" ]] ; then - return 1 - fi - - return 0 } # bool dependon(service1, service2) @@ -795,7 +800,8 @@ trace_dependencies() { done else for x in $(dolisting "/etc/runlevels/${BOOTLEVEL}/net.*") \ - $(dolisting "/etc/runlevels/${SOFTLEVEL}/net.*") ; do + $(dolisting "/etc/runlevels/${SOFTLEVEL}/net.*") \ + $(dolisting "/etc/runlevels/coldplugged/net.*") ; do net_services="${net_services} ${x##*/}" done fi diff --git a/sbin/runscript.sh b/sbin/runscript.sh index 19b5f58..e9b5388 100755 --- a/sbin/runscript.sh +++ b/sbin/runscript.sh @@ -146,9 +146,8 @@ svc_schedule_start() { local service="$1" start="$2" [[ ! -d "${svcdir}/scheduled/${service}" ]] \ && mkdir -p "${svcdir}/scheduled/${service}" - [[ ! -e "${svcdir}/scheduled/${service}/${start}" ]] \ - && ln -snf "/etc/init.d/${service}" \ - "${svcdir}/scheduled/${service}/${start}" + ln -snf "/etc/init.d/${service}" \ + "${svcdir}/scheduled/${service}/${start}" } svc_start_scheduled() { @@ -197,7 +196,9 @@ svc_stop() { if [[ ${svcpause} != "yes" && ${RC_NO_DEPS} != "yes" ]] ; then if net_service "${SVCNAME}" ; then - is_net_up || mydeps="net" + if is_runlevel_stop || is_net_up "${SVCNAME}" ; then + mydeps="net" + fi fi mydeps="${mydeps} ${SVCNAME}" fi @@ -208,17 +209,15 @@ svc_stop() { for mydep in ${mydeps} ; do for x in $(needsme "${mydep}") ; do - service_started "${x}" && stop_service "${x}" + if service_started "${x}" || service_inactive "${x}" ; then + stop_service "${x}" + fi service_list=( "${service_list[@]}" "${x}" ) done done for x in "${service_list[@]}" ; do - # We need to test if the service has been marked stopped - # as the fifo may still be around if called by custom code - # such as postup from a net script. - service_stopped "${mynetservice}" && continue - + service_stopped "${x}" && continue wait_service "${x}" if ! service_stopped "${x}" ; then retval=1 @@ -337,7 +336,8 @@ svc_start() { local startupservices="$(ineed "${SVCNAME}") $(valid_iuse "${SVCNAME}")" local netservices= for x in $(dolisting "/etc/runlevels/${BOOTLEVEL}/net.*") \ - $(dolisting "/etc/runlevels/${mylevel}/net.*") ; do + $(dolisting "/etc/runlevels/${mylevel}/net.*") \ + $(dolisting "/etc/runlevels/coldplugged/net.*") ; do netservices="${netservices} ${x##*/}" done @@ -350,9 +350,7 @@ svc_start() { service_stopped "${y}" && start_service "${y}" done elif [[ ${x} != "net" ]] ; then - if service_stopped "${x}" ; then - start_service "${x}" - fi + service_stopped "${x}" && start_service "${x}" fi done fi @@ -379,14 +377,13 @@ svc_start() { if ! service_started "${x}" ; then # A 'need' dependency is critical for startup if ineed -t "${SVCNAME}" "${x}" >/dev/null \ - || net_service "${x}" && ineed -t "${SVCNAME}" net \ - && ! is_net_up ; then + || ( net_service "${x}" && ineed -t "${SVCNAME}" net \ + && ! is_net_up ) ; then if service_inactive "${x}" || service_wasinactive "${x}" || \ [[ -n $(ls "${svcdir}"/scheduled/*/"${x}" 2>/dev/null) ]] ; then - if svc_schedule_start "${x}" "${SVCNAME}" ; then - [[ -n ${startinactive} ]] && startinactive="${startinactive}, " - startinactive="${startinactive}${x}" - fi + svc_schedule_start "${x}" "${SVCNAME}" + [[ -n ${startinactive} ]] && startinactive="${startinactive}, " + startinactive="${startinactive}${x}" else startfail="${x}" break @@ -428,11 +425,11 @@ svc_start() { || -e ${svcdir}/exclusive/${SVCNAME} ]] \ && RC_QUIET_STDOUT="yes" fi - + start ) retval="$?" - + # If a service has been marked inactive, exit now as something # may attempt to start it again later if [[ ${retval} == "0" ]] && service_inactive "${SVCNAME}" ; then @@ -601,6 +598,7 @@ for arg in $* ; do svc_schedule_start "${SVCNAME}" "${x##*/}" fi done + rm -f "${svcdir}/snapshot/$$" else rm -f "${svcdir}"/scheduled/*/"${SVCNAME}" fi |