diff options
author | Christian Heim <phreak@gentoo.org> | 2006-02-23 13:39:22 +0000 |
---|---|---|
committer | Christian Heim <phreak@gentoo.org> | 2006-02-23 13:39:22 +0000 |
commit | a2c749b6b0e3e3fc03edf067486d950d494a9ff3 (patch) | |
tree | 0ae717a18dc285e9aee74b77d583ac1fe21eb99d | |
parent | Merging r1909 (diff) | |
download | baselayout-vserver-a2c749b6b0e3e3fc03edf067486d950d494a9ff3.tar.gz baselayout-vserver-a2c749b6b0e3e3fc03edf067486d950d494a9ff3.tar.bz2 baselayout-vserver-a2c749b6b0e3e3fc03edf067486d950d494a9ff3.zip |
Merging baselayout r1924
svn path=/baselayout-vserver/trunk/; revision=252
-rw-r--r-- | ChangeLog | 21 | ||||
-rw-r--r-- | ChangeLog.vserver | 15 | ||||
-rw-r--r-- | net-scripts/conf.d/net.example | 2 | ||||
-rw-r--r-- | net-scripts/net.modules.d/helpers.d/functions | 2 | ||||
-rw-r--r-- | net-scripts/net.modules.d/ifplugd | 5 | ||||
-rw-r--r-- | net-scripts/net.modules.d/netplugd | 5 | ||||
-rw-r--r-- | net-scripts/net.modules.d/wpa_supplicant | 4 | ||||
-rwxr-xr-x | sbin/functions.sh | 2 | ||||
-rwxr-xr-x | sbin/rc-update | 191 |
9 files changed, 179 insertions, 68 deletions
@@ -5,6 +5,27 @@ Give a better error message when no valid DHCP client is installed. + 22 Feb 2006; Mike Frysinger <vapier@gentoo.org>: + + Overhaul rc-update and make it more user friendly. + + 22 Feb 2006; Roy Marples <uberlord@gentoo.org>: + + Ensure that ifplugd, netplugd and wpa_supplicant timeouts really are + infinite when requested. Thanks to embobo. + + 21 Feb 2006; Mike Frysinger <vapier@gentoo.org>: + + Add patch by Alun Jones to respect RC_QUIET_STDOUT in conf.d/rc #123606. + + 18 Feb 2006; Mike Frysinger <vapier@gentoo.org>: + + Add patch by Craig to nuke swap at shutdown #122893. + + 17 Feb 2006; Roy Marples <uberlord@gentoo.org>: + + Fixed typo in functions, #123136 thanks to Alexander Danilov. + * baselayout-1.12.0_pre16 (16 Feb 2006) 15 Feb 2006; Roy Marples <uberlord@gentoo.org>: diff --git a/ChangeLog.vserver b/ChangeLog.vserver index 3658feb..32cface 100644 --- a/ChangeLog.vserver +++ b/ChangeLog.vserver @@ -1,6 +1,21 @@ # ChangeLog for Gentoo System Intialization ("rc") scripts # Copyright 1999-2006 Gentoo Foundation; Distributed under the GPLv2 + 23 Feb 2006; Christian Heim <phreak@gentoo.org>: + Merging latest changes to the rc-scripts branch. This merge is based + upon revision 1924. + + ChangeLog | 21 + + ChangeLog.vserver | 15 + + net-scripts/conf.d/net.example | 2 + net-scripts/net.modules.d/helpers.d/functions | 2 + net-scripts/net.modules.d/ifplugd | 5 + net-scripts/net.modules.d/netplugd | 5 + net-scripts/net.modules.d/wpa_supplicant | 4 + sbin/functions.sh | 2 + sbin/rc-update | 191 ++++++++++++------ + 9 files changed, 179 insertions(+), 68 deletions(-) + 17 Feb 2006; Christian Heim <phreak@gentoo.org>: Merging latest changes to the rc-scripts branch. This merge is based upon revision 1909. diff --git a/net-scripts/conf.d/net.example b/net-scripts/conf.d/net.example index baec820..a28bf43 100644 --- a/net-scripts/conf.d/net.example +++ b/net-scripts/conf.d/net.example @@ -45,7 +45,7 @@ # In other words, you probably should DO NOTHING HERE... # Prefer ifconfig over iproute2 -#modules=( "iproute2" ) +#modules=( "ifconfig" ) # You can also specify other modules for an interface # In this case we prefer udhcpc over dhcpcd diff --git a/net-scripts/net.modules.d/helpers.d/functions b/net-scripts/net.modules.d/helpers.d/functions index 058ba95..52f3da1 100644 --- a/net-scripts/net.modules.d/helpers.d/functions +++ b/net-scripts/net.modules.d/helpers.d/functions @@ -74,7 +74,7 @@ apply_state() { local file for file in ${files} ; do # Skip .sv files - [[ ${file} == *".sv" ]] && contine + [[ ${file} == *".sv" ]] && continue local link=$( readlink "/etc/${file}" 2>/dev/null ) if [[ ${link} != "${netdir}/${file}" ]]; then [[ -e "/etc/${file}" ]] && rm -f "/etc/${file}" diff --git a/net-scripts/net.modules.d/ifplugd b/net-scripts/net.modules.d/ifplugd index 818969e..edeefe9 100644 --- a/net-scripts/net.modules.d/ifplugd +++ b/net-scripts/net.modules.d/ifplugd @@ -29,7 +29,7 @@ ifplugd_check_installed() { # # Start ifplugd on an interface ifplugd_pre_start() { - local iface="$1" ifvar=$( bash_variable "$1" ) timeout i opts + local iface="$1" ifvar=$( bash_variable "$1" ) timeout opts local pidfile="/var/run/ifplugd.${iface}.pid" # We don't start ifplugd if we're being called from the background @@ -104,7 +104,7 @@ ifplugd_pre_start() { veinfo "Waiting for ${iface} to be marked as started" - i=0 + local i=0 while true ; do if service_started "net.${iface}"; then local addr=$( interface_get_address "${iface}" ) @@ -112,6 +112,7 @@ ifplugd_pre_start() { exit 0 fi sleep 1 + [[ ${timeout} == "0" ]] && continue (( i++ )) [[ ${i} == "${timeout}" || ${i} -gt "${timeout}" ]] && break done diff --git a/net-scripts/net.modules.d/netplugd b/net-scripts/net.modules.d/netplugd index a079c3f..109e569 100644 --- a/net-scripts/net.modules.d/netplugd +++ b/net-scripts/net.modules.d/netplugd @@ -29,7 +29,7 @@ netplugd_check_installed() { # # Start netplug on an interface netplugd_pre_start() { - local iface="$1" timeout i + local iface="$1" timeout local pidfile="/var/run/netplugd.${iface}.pid" # We don't start netplug if we're being called from the background @@ -82,7 +82,7 @@ netplugd_pre_start() { veinfo "Waiting for ${iface} to be marked as started" - i=0 + local i=0 while true ; do if service_started "net.${iface}"; then local addr=$( interface_get_address "${iface}" ) @@ -90,6 +90,7 @@ netplugd_pre_start() { exit 0 fi sleep 1 + [[ ${timeout} == "0" ]] && continue (( i++ )) [[ ${i} == "${timeout}" || ${i} -gt "${timeout}" ]] && break done diff --git a/net-scripts/net.modules.d/wpa_supplicant b/net-scripts/net.modules.d/wpa_supplicant index 77fc29c..c695a27 100644 --- a/net-scripts/net.modules.d/wpa_supplicant +++ b/net-scripts/net.modules.d/wpa_supplicant @@ -138,7 +138,7 @@ wpa_supplicant_kill() { # Returns 0 if wpa_supplicant associates and authenticates to an AP # otherwise, 1 wpa_supplicant_associate() { - local iface="$1" ifvar="$( bash_variable "$1" )" timeout i + local iface="$1" ifvar="$( bash_variable "$1" )" timeout timeout="associate_timeout_${ifvar}" [[ -z ${!timeout} ]] && timeout="wpa_timeout_${ifvar}" timeout="${!timeout:--1}" @@ -150,6 +150,7 @@ wpa_supplicant_associate() { exit 0 fi + local i=0 while true ; do if [[ -n ${actfile} ]] ; then service_started "net.${iface}" && return 0 @@ -161,6 +162,7 @@ wpa_supplicant_associate() { wpa_supplicant_associated "${iface}" && return 0 fi sleep 1 + [[ ${timeout} == "0" ]] && continue (( i++ )) [[ ${i} == "${timeout}" || ${i} -gt "${timeout}" ]] && break done diff --git a/sbin/functions.sh b/sbin/functions.sh index e371382..304c03a 100755 --- a/sbin/functions.sh +++ b/sbin/functions.sh @@ -23,7 +23,7 @@ ordtypes="before after" # # Dont output to stdout? -RC_QUIET_STDOUT="no" +RC_QUIET_STDOUT=${RC_QUIET_STDOUT:-no} RC_VERBOSE=${RC_VERBOSE:-no} # Should we use color? diff --git a/sbin/rc-update b/sbin/rc-update index 3f9a980..a1864a9 100755 --- a/sbin/rc-update +++ b/sbin/rc-update @@ -3,69 +3,80 @@ # Distributed under the terms of the GNU General Public License v2 source /sbin/functions.sh +esyslog() { :; } + +argv0=${0##*/} usage() { cat << FOO -usage: rc-update -a|add script runlevel2 [runlevel2 ...] - rc-update -d|del script [runlevel1 ...] - rc-update -s|show [runlevel1 ...] +usage: ${argv0} -a|add script runlevel1 [runlevel2 ...] + ${argv0} -d|del script [runlevel1 ...] + ${argv0} -s|show [runlevel1 ...] examples: - # rc-update add net.eth0 default + # ${argv0} add net.eth0 default Adds the net.eth0 script (in /etc/init.d) to the "default" runlevel. - # rc-update del sysklogd + # ${argv0} del sysklogd Deletes the sysklogd script from all runlevels. The original script is not deleted, just any symlinks to the script in /etc/runlevels/*. - # rc-update del net.eth2 default wumpus + # ${argv0} del net.eth2 default wumpus Delete the net.eth2 script from the default and wumpus runlevels. All other runlevels are unaffected. Again, the net.eth2 script residing in /etc/init.d is not deleted, just any symlinks in /etc/runlevels/default and /etc/runlevels/wumpus. - # rc-update show + # ${argv0} show Show all the available scripts and list at which runlevels they will execute. FOO - exit 1 + exit ${1:-0} } add() { + local ret=0 local x= local myscript= - if [[ $# -lt 3 ]] ; then - eerror "$0: at least two arguments expected after \"$1\"." + if [[ $# -lt 2 ]] ; then + eerror "Usage: ${argv0} add <script> runlevel1 [runlevel2 ...]" 1>&2 exit 1 fi - shift - myscript="$1" + + [[ ${quiet} -gt 0 ]] && exec 2> /dev/null + + myscript=$1 if [[ ! -e ${ROOT}/etc/init.d/${myscript} ]] ; then - eerror "$0: '${ROOT}/etc/init.d/${myscript}' not found; aborting." + eerror "${argv0}: '${ROOT}etc/init.d/${myscript}' not found; aborting" 1>&2 exit 1 fi shift for x in $* ; do - if [[ ! -e ${ROOT}/etc/runlevels/${x} ]] ; then - ewarn "runlevel ${x} not found; skipping" + if [[ ! -e ${ROOT}etc/runlevels/${x} ]] ; then + ewarn "runlevel '${x}' not found; skipping" 1>&2 + ((++ret)) continue fi - if [[ -L ${ROOT}/etc/runlevels/${x}/${myscript} ]] ; then - ewarn "${myscript} already installed in runlevel ${x}; skipping" + if [[ -L ${ROOT}etc/runlevels/${x}/${myscript} ]] ; then + ewarn "${myscript} already installed in runlevel '${x}'; skipping" 1>&2 continue fi - if [[ ! -x ${ROOT}/etc/init.d/${myscript} ]] ; then - ewarn "${myscript} not executable; skipping" + if [[ ! -x ${ROOT}etc/init.d/${myscript} ]] ; then + ewarn "${myscript} not executable; skipping" 1>&2 + ((++ret)) continue fi - ln -snf "/etc/init.d/${myscript}" "${ROOT}/etc/runlevels/${x}/${myscript}" + ln -snf "/etc/init.d/${myscript}" "${ROOT}etc/runlevels/${x}/${myscript}" if [[ $? -ne 0 ]] ; then - eerror "$0: failed to add ${myscript} to ${x}." - exit 1 + eerror "${argv0}: failed to add '${myscript}' to '${x}'" 1>&2 + ((++ret)) + continue fi einfo "${myscript} added to runlevel ${x}" done + + return ${ret} } del() { @@ -74,30 +85,39 @@ del() { local myscript= local remlevels= - if [[ $# -lt 2 ]] ; then - eerror "$0: at least one argument expected after \"$1\"." + if [[ $# -lt 1 ]] ; then + eerror "Usage: ${argv0} del <script> [runlevel1 ...]" 1>&2 exit 1 fi - shift + + [[ ${quiet} -gt 0 ]] && exec 2> /dev/null + myscript=$1 shift if [[ $# -eq 0 ]] ; then - mylevels=$(cd "${ROOT}"/etc/runlevels/; ls) + mylevels=$(cd "${ROOT}"etc/runlevels/; ls) else mylevels="$*" fi remlevels="" for x in ${mylevels} ; do - if [[ -L ${ROOT}/etc/runlevels/${x}/${myscript} ]] ; then - rm -f "${ROOT}/etc/runlevels/${x}/${myscript}" - remlevels="${remlevels} ${x}" + # -e will return false for broken symlinks so we need the extra -L + [[ ! -L ${ROOT}etc/runlevels/${x}/${myscript} ]] && \ + [[ ! -e ${ROOT}etc/runlevels/${x}/${myscript} ]] && continue + + remlevels="${remlevels} ${x}" + if [[ ! -L ${ROOT}etc/runlevels/${x}/${myscript} ]] ; then + ewarn "Removing invalid init.d script: '${ROOT}etc/runlevels/${x}/${myscript}'" 1>&2 fi + rm -f "${ROOT}etc/runlevels/${x}/${myscript}" + ((ret+=$?)) done if [[ -z ${remlevels} ]] ; then - einfo "${myscript} not found in any of the specified runlevels." - else - einfo "${myscript} removed from the following runlevels:${remlevels}" + ewarn "'${myscript}' not found in any of the specified runlevels" 1>&2 + elif [[ ${quiet} -eq 0 ]] ; then + einfo "'${myscript}' removed from the following runlevels:${remlevels}" fi + return ${ret} } show() { @@ -106,62 +126,113 @@ show() { local mylevels= local myscripts= - shift + shopt -s nullglob if [[ $# -eq 0 ]] ; then - mylevels=$(cd "${ROOT}"/etc/runlevels/; ls) + mylevels=$(cd "${ROOT}"etc/runlevels/; ls) else mylevels="$*" + # verify runlevels provided by user + for y in ${mylevels} ; do + [[ ! -d ${ROOT}etc/runlevels/${y} ]] && ewarn "Runlevel doesn't exist: ${y}" + done fi - myscripts=$(cd "${ROOT}"/etc/init.d; ls) + myscripts=$(cd "${ROOT}"etc/init.d; ls) + + # Sanity check to make sure everything is kosher ... + for x in $(find "${ROOT}"etc/runlevels -xtype l) ; do + ewarn "Broken runlevel entry: ${x}" + done + for x in $(find "${ROOT}"etc/runlevels ! -type l -a ! -type d) ; do + ewarn "Invalid runlevel entry: ${x}" + done for x in ${myscripts} ; do - if [[ ${x%%.sh} = "${x}" ]] ; then - printf "%20s | " ${x:0:19} + # skip *.sh scripts as they are helpers, not init.d scripts + [[ ${x} == *.sh ]] && continue + + # unless we are running in verbose mode, don't display scripts + # that aren't in any runlevels that we are examining + if [[ ${verbose} -eq 0 ]] ; then + local found_it=0 for y in ${mylevels} ; do - if [[ -L ${ROOT}/etc/runlevels/${y}/${x} ]] ; then - echo -n "${y} " - else - printf "%${#y}s " " " + if [[ -L ${ROOT}etc/runlevels/${y}/${x} ]] ; then + found_it=1 + break fi done - echo "" + [[ ${found_it} -eq 0 ]] && continue fi + + # ok, let's show this script already ! + printf "%20s | " ${x:0:19} + for y in ${mylevels} ; do + if [[ -L ${ROOT}etc/runlevels/${y}/${x} ]] ; then + echo -n "${y} " + else + printf "%${#y}s " " " + fi + done + echo "" done } check_is_root() { if [[ ${EUID} -ne 0 ]] ; then - eerror "$0: must be root." + eerror "${argv0}: must be root to complete this operation" 1>&2 exit 1 fi } -if [[ $# -lt 1 ]] ; then - usage - exit 1 -fi +export ROOT=${ROOT%/}/ +[[ ${ROOT} != "/" ]] && einfo "Working with files in root ${ROOT} ..." -if [[ -n ${ROOT} ]] ; then - [[ ${ROOT:0-1} == "/" ]] && export ROOT=${ROOT:0:${#ROOT}-1} - einfo "Working with files in root ${ROOT} ..." -fi +verbose=0 +quiet=0 +action="" +opts="" +check_root=0 + +[[ ${RC_VERBOSE} == "yes" ]] && ((++verbose)) -case "$1" in +while [[ -n $* ]] ; do + case "$1" in add|-a) - check_is_root - add "$@" + check_root=1 + action="add" ;; del|delete|-d) - check_is_root - del "$@" + check_root=1 + action="del" ;; show|-s) - show "$@" + action="show" + ;; + help|-h|--help) + usage 0 + ;; + verbose|-v|--verbose) + ((++verbose)) + ;; + quiet|-q|--quiet) + ((++quiet)) + ;; + -*) + echo -e "${argv0}: Unknown option $1\n" 1>&2 + usage 1 ;; *) - usage - exit 1 + opts="${opts} $1" ;; -esac + esac + shift +done + +if [[ -z ${action} ]] ; then + eerror "${argv0}: gimme something to do!" 1>&2 + exit 1 +fi + +[[ ${check_root} -eq 1 ]] && check_is_root +${action} ${opts} # vim:ts=4 |