diff options
author | Christian Heim <phreak@gentoo.org> | 2006-04-24 14:30:20 +0000 |
---|---|---|
committer | Christian Heim <phreak@gentoo.org> | 2006-04-24 14:30:20 +0000 |
commit | c7b10efd125522f3beeb3144b8a5b4cc511d93cf (patch) | |
tree | 09506e4c389d58f5303799712bf9dfcae8117835 /sbin | |
parent | Merging r1965 (diff) | |
download | baselayout-vserver-c7b10efd125522f3beeb3144b8a5b4cc511d93cf.tar.gz baselayout-vserver-c7b10efd125522f3beeb3144b8a5b4cc511d93cf.tar.bz2 baselayout-vserver-c7b10efd125522f3beeb3144b8a5b4cc511d93cf.zip |
Merging r2014
svn path=/baselayout-vserver/trunk/; revision=341
Diffstat (limited to 'sbin')
-rwxr-xr-x | sbin/depscan.sh | 56 | ||||
-rwxr-xr-x | sbin/rc-daemon.sh | 2 | ||||
-rwxr-xr-x | sbin/rc-services.sh | 34 | ||||
-rwxr-xr-x | sbin/rc-update | 6 | ||||
-rwxr-xr-x | sbin/runscript.sh | 8 |
5 files changed, 70 insertions, 36 deletions
diff --git a/sbin/depscan.sh b/sbin/depscan.sh index ed16100..e9454a1 100755 --- a/sbin/depscan.sh +++ b/sbin/depscan.sh @@ -1,9 +1,37 @@ #!/bin/bash -# Copyright 1999-2004 Gentoo Foundation +# Copyright 1999-2006 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -source /sbin/functions.sh -mysvcdir="${svcdir}" +if [[ ${BOOT} == "yes" ]] ; then + trap ":" INT QUIT TSTP +fi + +argv0=${0##*/} +source /etc/init.d/functions.sh || { + echo "${argv0}: Could not source /etc/init.d/functions.sh!" 1>&2 + exit 1 +} +esyslog() { :; } + +usage() { + cat <<-EOF + Usage: ${argv0} [options] + + Rebuild Gentoo init.d service dependency tree. + + Options: + -d, --debug Turn on debug output + -s, --svcdir Specify svcdir (default: ${svcdir}) + -u, --update Force update even if mtimes are OK + -h, --help Show this help cruft + EOF + [[ -z $@ ]] && exit 0 + echo + eerror "$*" + exit 1 +} + +mysvcdir=${svcdir} update=false while [[ -n $1 ]] ; do @@ -22,6 +50,12 @@ while [[ -n $1 ]] ; do --update|-u) update=true ;; + --help|-h) + usage + ;; + *) + usage "Invalid option '$1'" + ;; esac shift done @@ -44,14 +78,14 @@ done # Only update if files have actually changed if ! ${update} ; then - clock_screw=false + clock_screw=0 mtime_test="${mysvcdir}/mtime-test.$$" # If its not there, we have to update, and make sure its present # for next mtime testing if [[ ! -e "${mysvcdir}/depcache" ]] ; then - update=true - touch "${mysvcdir}/depcache" + update=true + touch "${mysvcdir}/depcache" fi touch "${mtime_test}" @@ -61,12 +95,14 @@ if ! ${update} ; then && is_older_than "${mysvcdir}/depcache" "${config}" \ && update=true - is_older_than "${mtime_test}" "${config}" && clock_screw=true + is_older_than "${mtime_test}" "${config}" && clock_screw=1 done rm -f "${mtime_test}" - ${clock_screw} && \ - ewarn "Some file in '/etc/{conf.d,init.d}' have Modification time in the future!" + if [[ ${clock_screw} == 1 ]] ; then + ewarn "One of the files in /etc/{conf.d,init.d} or /etc/rc.conf" + ewarn "has a modification time in the future!" + fi shift fi @@ -75,7 +111,7 @@ fi ebegin "Caching service dependencies" -# Clean out the non volitile directories ... +# Clean out the non volatile directories ... rm -rf "${mysvcdir}"/dep{cache,tree} "${mysvcdir}"/{broken,snapshot}/* retval=0 diff --git a/sbin/rc-daemon.sh b/sbin/rc-daemon.sh index 3d89447..f0b3dca 100755 --- a/sbin/rc-daemon.sh +++ b/sbin/rc-daemon.sh @@ -378,7 +378,7 @@ start-stop-daemon() { # We should really check for valid cmd AND pidfile # But most called to --stop only set the pidfile if [[ ${RC_DAEMONS[i]} == "{cmd}" \ - || ${RC_PIDFILES[i]}="${pidfile}" ]]; then + || ${RC_PIDFILES[i]} == "${pidfile}" ]]; then unset RC_DAEMONS[i] RC_PIDFILES[i] RC_DAEMONS=( "${RC_DAEMONS[@]}" ) RC_PIDFILES=( "${RC_PIDFILES[@]}" ) diff --git a/sbin/rc-services.sh b/sbin/rc-services.sh index df0b557..25e1805 100755 --- a/sbin/rc-services.sh +++ b/sbin/rc-services.sh @@ -745,8 +745,8 @@ valid_iafter() { # Get and sort the dependencies of given service[s]. # trace_dependencies() { - local -a services=( "$@" ) net_deps - local i j net_services x + local -a services=( "$@" ) net_deps=() + local i= j= net_services= x= if [[ $1 == -* ]]; then deptype="${1/-/}" @@ -757,26 +757,16 @@ trace_dependencies() { fi fi - net_services="$( cd "${svcdir}"/started; ls net.* 2>/dev/null )" - # If no net services are running or we only have net.lo up, then - # assume we are in boot runlevel or starting a new runlevel - if [[ -z ${net_services} || ${net_services} == "net.lo" ]]; then - get_net_services() { - local runlevel="$1" - - if [[ -d "/etc/runlevels/${runlevel}" ]] ; then - cd "/etc/runlevels/${runlevel}" - ls net.* 2>/dev/null - fi - } - - local mylevel="${BOOTLEVEL}" - local x="$( get_net_services "${mylevel}" )" - - [[ -f "${svcdir}/softlevel" ]] && mylevel="$( < "${svcdir}/softlevel" )" - [[ ${BOOTLEVEL} != "${mylevel}" ]] && \ - local x="${x} $( get_net_services "${mylevel}" )" - [[ -n ${x} ]] && net_services="${x}" + if is_runlevel_stop ; then + for x in $(dolisting "${svcdir}/started/net.*") \ + $(dolisting "${svcdir}/inactive/net.*") ; do + net_services="${net_services} ${x##*/}" + done + elif is_runlevel_start || ! is_net_up ; then + for x in $(dolisting "/etc/runlevels/${BOOTLEVEL}/net.*") \ + $(dolisting "/etc/runlevels/${SOFTLEVEL}/net.*") ; do + net_services="${net_services} ${x##*/}" + done fi # Cache the generic "net" depends diff --git a/sbin/rc-update b/sbin/rc-update index a1864a9..28bf91e 100755 --- a/sbin/rc-update +++ b/sbin/rc-update @@ -11,7 +11,7 @@ usage() { cat << FOO usage: ${argv0} -a|add script runlevel1 [runlevel2 ...] ${argv0} -d|del script [runlevel1 ...] - ${argv0} -s|show [runlevel1 ...] + ${argv0} -s|show [-v|--verbose] [runlevel1 ...] examples: # ${argv0} add net.eth0 default @@ -28,8 +28,8 @@ examples: /etc/runlevels/default and /etc/runlevels/wumpus. # ${argv0} show - Show all the available scripts and list at which runlevels they - will execute. + Show all enabled scripts and list at which runlevels they will + execute. Run with --verbose to see all available scripts. FOO exit ${1:-0} } diff --git a/sbin/runscript.sh b/sbin/runscript.sh index 558aff3..9614529 100755 --- a/sbin/runscript.sh +++ b/sbin/runscript.sh @@ -27,6 +27,14 @@ myservice="${SVCNAME}" # until after rc sysinit has completed so we punt them to the boot runlevel if [[ -e /dev/.rcsysinit ]] ; then eerror "ERROR: cannot run ${SVCNAME} until sysinit completes" + [[ ${RC_COLDPLUG} == "no" ]] && exit 1 + if [[ ${RC_COLDPLUG} != "yes" ]] ; then + for x in ${RC_COLDPLUG} ; do + # We don't quote ${x} so we can do globbing + [[ ${SVCNAME} == ${x} ]] && break + [[ "!${SVCNAME}" == ${x} ]] && exit 1 + done + fi eerror "${SVCNAME} will be started in the ${BOOTLEVEL} runlevel" if [[ ! -L /dev/.rcboot/"${SVCNAME}" ]] ; then [[ ! -d /dev/.rcboot ]] && mkdir /dev/.rcboot |