summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Heim <phreak@gentoo.org>2006-03-09 10:07:19 +0000
committerChristian Heim <phreak@gentoo.org>2006-03-09 10:07:19 +0000
commitf066e899210534cedced47c0c9076fe7c90a6693 (patch)
tree5ce0ac5c40ad8aeb5a67ec336bb78c750b986828
parentFixing the indentation of the Changelog entries (diff)
downloadbaselayout-vserver-f066e899210534cedced47c0c9076fe7c90a6693.tar.gz
baselayout-vserver-f066e899210534cedced47c0c9076fe7c90a6693.tar.bz2
baselayout-vserver-f066e899210534cedced47c0c9076fe7c90a6693.zip
Merging r1939
svn path=/baselayout-vserver/trunk/; revision=276
-rw-r--r--ChangeLog29
-rwxr-xr-xbin/rc-status2
-rwxr-xr-xnet-scripts/init.d/net.lo4
-rw-r--r--net-scripts/net.modules.d/iwconfig16
-rwxr-xr-xsbin/depscan.sh73
-rwxr-xr-xsbin/functions.sh88
-rwxr-xr-xsbin/init-common-post.sh2
-rwxr-xr-xsbin/rc-daemon.sh8
-rwxr-xr-xsbin/rc-help.sh10
-rwxr-xr-xsbin/rc-services.sh25
-rwxr-xr-xsbin/runscript.sh211
-rw-r--r--src/awk/cachedepends.awk18
-rw-r--r--src/awk/gendepends.awk12
13 files changed, 279 insertions, 219 deletions
diff --git a/ChangeLog b/ChangeLog
index 16e6f78..f7bf2b6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -5,6 +5,35 @@
Give a better error message when no valid DHCP client is installed.
+ 07 Mar 2006; Roy Marples <uberlord@gentoo.org>:
+
+ Set essid to "" instead of -- off as it appears not all drivers work
+ as they should. Hopefully fixes #125067 and maybe #120822.
+
+ 06 Mar 2006; Mike Frysinger <vapier@gentoo.org>:
+
+ Touchup fuser options in netmount so we don't pipe output to /dev/null.
+
+ 03 Mar 2006; Mike Frysinger <vapier@gentoo.org>:
+
+ Pass '-O no_netdev' to `mount -a` in localmount init.d.
+
+ Add note to sysctl.conf about needing nfsd for fs.nfs.* to work #66575.
+
+ 02 Mar 2006; Roy Marples <uberlord@gentoo.org>:
+
+ $myservice is now deprecated for init scripts.
+ $SVCNAME should be used instead and is read-only so it cannot be
+ clobbered.
+
+ Several variables in global scope that provided functions rely on,
+ such as BOOTLEVEL, SOFTLEVEL and svcdir are now read only for init
+ scripts.
+
+ depscan.sh now accepts the --svcdir option so that svcdir can now be
+ specified as the variable is marked readonly in functions.sh. Splash
+ programs will have to be updated.
+
24 Feb 2006; Roy Marples <uberlord@gentoo.org>:
Misc STYLE and quoting issues fixes in net scripts.
diff --git a/bin/rc-status b/bin/rc-status
index 1cc8572..4f6a29a 100755
--- a/bin/rc-status
+++ b/bin/rc-status
@@ -31,8 +31,6 @@ runleveldir=/etc/runlevels
# grab settings from conf.d/rc
source "${svclib}/sh/rc-daemon.sh"
-conf="$(add_suffix /etc/conf.d/rc)"
-[[ -e ${conf} ]] && source "${conf}"
################################################################################
# Parse command line options #
diff --git a/net-scripts/init.d/net.lo b/net-scripts/init.d/net.lo
index 332834b..028f8c7 100755
--- a/net-scripts/init.d/net.lo
+++ b/net-scripts/init.d/net.lo
@@ -16,7 +16,7 @@ depend() {
# Load any custom depend functions for the given interface
# For example, br0 may need eth0 and eth1
- local iface="${myservice#*.}"
+ local iface="${SVCNAME#*.}"
[[ $(type -t "depend_${iface}") == "function" ]] && depend_${iface}
return 0
@@ -953,6 +953,7 @@ link_file() {
# Start entry point so that we only have one function
# which localises variables and unsets functions
start() {
+ declare -r IFACE="${SVCNAME#*.}"
if [[ ${IN_HOTPLUG} == "1" ]] ; then
# If we've been called by hotplug, check if we have
# a policy for the interface for not starting
@@ -988,6 +989,7 @@ start() {
# Stop entry point so that we only have one function
# which localises variables and unsets functions
stop() {
+ declare -r IFACE="${SVCNAME#*.}"
einfo "Stopping ${IFACE}"
run "${IFACE}" stop
}
diff --git a/net-scripts/net.modules.d/iwconfig b/net-scripts/net.modules.d/iwconfig
index 9d079c2..34082d4 100644
--- a/net-scripts/net.modules.d/iwconfig
+++ b/net-scripts/net.modules.d/iwconfig
@@ -335,8 +335,6 @@ iwconfig_associate() {
eerror "Unable to change mode to ${mode}"
return 1
fi
- interface_down "${iface}"
- interface_up "${iface}"
if [[ ${ESSID} == "any" ]]; then
iwconfig "${iface}" ap any 2>/dev/null
@@ -371,7 +369,7 @@ iwconfig_associate() {
fi
# Finally apply the user Config
- #iwconfig_user_config "${iface}" "${ESSIDVAR}"
+ iwconfig_user_config "${iface}" "${ESSIDVAR}"
vebegin "Connecting to \"${dessid}\" ${w}"
@@ -690,8 +688,13 @@ iwconfig_defaults() {
iwconfig "${iface}" txpower auto &>/dev/null
iwconfig "${iface}" key [1] off &>/dev/null
iwconfig "${iface}" mode managed &>/dev/null
- iwconfig "${iface}" essid -- off &>/dev/null
iwconfig "${iface}" ap off &>/dev/null
+
+ # According to the iwconfig man page we should be doing
+ # iwconfig "${iface}" essid -- off &>/dev/null
+ # instead. However, this borks many drivers - setting essid
+ # to "" seems to work for all drivers however.
+ iwconfig "${iface}" essid "" &>/dev/null
}
# void iwconfig_strip_associated(char *iface)
@@ -909,4 +912,9 @@ iwconfig_pre_start() {
return 1
}
+iwconfig_post_stop() {
+ interface_exists "${iface}" || return 0
+ iwconfig_defaults "${iface}"
+}
+
# vim:ts=4
diff --git a/sbin/depscan.sh b/sbin/depscan.sh
index a67b8d7..ed16100 100755
--- a/sbin/depscan.sh
+++ b/sbin/depscan.sh
@@ -3,68 +3,83 @@
# Distributed under the terms of the GNU General Public License v2
source /sbin/functions.sh
-
-if [[ $1 == "--debug" ]] ; then
+mysvcdir="${svcdir}"
+update=false
+
+while [[ -n $1 ]] ; do
+ case "$1" in
+ --debug|-d)
+ set -x
+ ;;
+ --svcdir|-s)
+ if [[ -z $2 || $2 == -* ]] ; then
+ eerror "No svcdir specified"
+ else
+ shift
+ mysvcdir="$1"
+ fi
+ ;;
+ --update|-u)
+ update=true
+ ;;
+ esac
shift
- set -x
-fi
+done
-if [[ ! -d ${svcdir} ]] ; then
- if ! mkdir -p -m 0755 "${svcdir}" 2>/dev/null ; then
- eerror "Could not create needed directory '${svcdir}'!"
+if [[ ! -d ${mysvcdir} ]] ; then
+ if ! mkdir -p -m 0755 "${mysvcdir}" 2>/dev/null ; then
+ eerror "Could not create needed directory '${mysvcdir}'!"
fi
fi
for x in softscripts snapshot options daemons \
started starting inactive wasinactive stopping failed \
exclusive exitcodes scheduled ; do
- if [[ ! -d "${svcdir}/${x}" ]] ; then
- if ! mkdir -p -m 0755 "${svcdir}/${x}" 2>/dev/null ; then
- eerror "Could not create needed directory '${svcdir}/${x}'!"
+ if [[ ! -d "${mysvcdir}/${x}" ]] ; then
+ if ! mkdir -p -m 0755 "${mysvcdir}/${x}" 2>/dev/null ; then
+ eerror "Could not create needed directory '${mysvcdir}/${x}'!"
fi
fi
done
# Only update if files have actually changed
-update=1
-
-if [[ $1 == "-u" ]] ; then
- update=0
- clock_screw=0
- mtime_test="${svcdir}/mtime-test.$$"
+if ! ${update} ; then
+ clock_screw=false
+ mtime_test="${mysvcdir}/mtime-test.$$"
# If its not there, we have to update, and make sure its present
# for next mtime testing
- if [[ ! -e "${svcdir}/depcache" ]] ; then
- update=1
- touch "${svcdir}/depcache"
+ if [[ ! -e "${mysvcdir}/depcache" ]] ; then
+ update=true
+ touch "${mysvcdir}/depcache"
fi
touch "${mtime_test}"
for config in /etc/conf.d /etc/init.d /etc/rc.conf
do
- [[ ${update} == 0 ]] && \
- is_older_than "${svcdir}/depcache" "${config}" && update=1
+ ! ${update} \
+ && is_older_than "${mysvcdir}/depcache" "${config}" \
+ && update=true
- is_older_than "${mtime_test}" "${config}" && clock_screw=1
+ is_older_than "${mtime_test}" "${config}" && clock_screw=true
done
rm -f "${mtime_test}"
- [[ ${clock_screw} == 1 ]] && \
+ ${clock_screw} && \
ewarn "Some file in '/etc/{conf.d,init.d}' have Modification time in the future!"
shift
fi
-[[ ${update} == 0 && -e "${svcdir}/deptree" ]] && exit 0
+! ${update} && [[ -e "${mysvcdir}/deptree" ]] && exit 0
ebegin "Caching service dependencies"
# Clean out the non volitile directories ...
-rm -rf "${svcdir}"/dep{cache,tree} "${svcdir}"/{broken,snapshot}/*
+rm -rf "${mysvcdir}"/dep{cache,tree} "${mysvcdir}"/{broken,snapshot}/*
retval=0
-SVCDIR="${svcdir}"
+SVCDIR="${mysvcdir}"
DEPTYPES="${deptypes}"
ORDTYPES="${ordtypes}"
@@ -77,14 +92,14 @@ cd /etc/init.d
-f /lib/rcscripts/awk/cachedepends.awk || \
retval=1
-bash "${svcdir}/depcache" | \
+bash "${mysvcdir}/depcache" | \
/bin/gawk \
-f /lib/rcscripts/awk/functions.awk \
-f /lib/rcscripts/awk/gendepends.awk || \
retval=1
-touch "${svcdir}"/dep{cache,tree}
-chmod 0644 "${svcdir}"/dep{cache,tree}
+touch "${mysvcdir}"/dep{cache,tree}
+chmod 0644 "${mysvcdir}"/dep{cache,tree}
eend ${retval} "Failed to cache service dependencies"
diff --git a/sbin/functions.sh b/sbin/functions.sh
index 304c03a..1911236 100755
--- a/sbin/functions.sh
+++ b/sbin/functions.sh
@@ -4,14 +4,14 @@
RC_GOT_FUNCTIONS="yes"
# Override defaults with user settings ...
-[ -f /etc/conf.d/rc ] && source /etc/conf.d/rc
+[[ -f /etc/conf.d/rc ]] && source /etc/conf.d/rc
# daemontools dir
SVCDIR="/var/lib/supervise"
# Check /etc/conf.d/rc for a description of these ...
-svclib="/lib/rcscripts"
-svcdir=${svcdir:-/var/lib/init.d}
+declare -r svclib="/lib/rcscripts"
+declare -r svcdir="${svcdir:-/var/lib/init.d}"
# Different types of dependencies
deptypes="need use"
@@ -23,21 +23,21 @@ ordtypes="before after"
#
# Dont output to stdout?
-RC_QUIET_STDOUT=${RC_QUIET_STDOUT:-no}
-RC_VERBOSE=${RC_VERBOSE:-no}
+RC_QUIET_STDOUT="${RC_QUIET_STDOUT:-no}"
+RC_VERBOSE="${RC_VERBOSE:-no}"
# Should we use color?
-RC_NOCOLOR=${RC_NOCOLOR:-no}
+RC_NOCOLOR="${RC_NOCOLOR:-no}"
# Can the terminal handle endcols?
RC_ENDCOL="yes"
#
# Default values for rc system
#
-RC_TTY_NUMBER=${RC_TTY_NUMBER:-0}
-RC_PARALLEL_STARTUP=${RC_PARALLEL_STARTUP:-no}
-RC_NET_STRICT_CHECKING=${RC_NET_STRICT_CHECKING:-none}
-RC_DOWN_INTERFACE=${RC_DOWN_INTERFACE:-yes}
+RC_TTY_NUMBER="${RC_TTY_NUMBER:-0}"
+RC_PARALLEL_STARTUP="${RC_PARALLEL_STARTUP:-no}"
+RC_NET_STRICT_CHECKING="${RC_NET_STRICT_CHECKING:-none}"
+RC_DOWN_INTERFACE="${RC_DOWN_INTERFACE:-yes}"
#
# Default values for e-message indentation and dots
@@ -123,9 +123,9 @@ get_libdir() {
if [[ -n ${CONF_LIBDIR_OVERRIDE} ]] ; then
CONF_LIBDIR="${CONF_LIBDIR_OVERRIDE}"
elif [[ -x /usr/bin/portageq ]] ; then
- CONF_LIBDIR=$(/usr/bin/portageq envvar CONF_LIBDIR)
+ CONF_LIBDIR="$(/usr/bin/portageq envvar CONF_LIBDIR)"
fi
- echo ${CONF_LIBDIR:=lib}
+ echo "${CONF_LIBDIR:=lib}"
}
# void esyslog(char* priority, char* tag, char* message)
@@ -245,12 +245,12 @@ eerror() {
# show a message indicating the start of a process
#
ebegin() {
- local msg="$*" dots spaces=${RC_DOT_PATTERN//?/ }
+ local msg="$*" dots spaces="${RC_DOT_PATTERN//?/ }"
[[ ${RC_QUIET_STDOUT} == "yes" ]] && return 0
if [[ -n ${RC_DOT_PATTERN} ]] ; then
- dots=$(printf "%$(( COLS - 3 - ${#RC_INDENTATION} - ${#msg} - 7 ))s" '')
- dots=${dots//${spaces}/${RC_DOT_PATTERN}}
+ dots="$(printf "%$((COLS - 3 - ${#RC_INDENTATION} - ${#msg} - 7))s" '')"
+ dots="${dots//${spaces}/${RC_DOT_PATTERN}}"
msg="${msg}${dots}"
else
msg="${msg} ..."
@@ -258,7 +258,7 @@ ebegin() {
einfon "${msg}"
[[ ${RC_ENDCOL} == "yes" ]] && echo
- LAST_E_LEN=$(( 3 + ${#RC_INDENTATION} + ${#msg} ))
+ LAST_E_LEN="$(( 3 + ${#RC_INDENTATION} + ${#msg} ))"
LAST_E_CMD="ebegin"
return 0
}
@@ -272,7 +272,7 @@ ebegin() {
# script.
#
_eend() {
- local retval=${1:-0} efunc=${2:-eerror} msg
+ local retval="${1:-0}" efunc="${2:-eerror}" msg
shift 2
if [[ ${retval} == "0" ]] ; then
@@ -301,10 +301,10 @@ _eend() {
# if error, show errstr via eerror
#
eend() {
- local retval=${1:-0}
+ local retval="${1:-0}"
shift
- _eend ${retval} eerror "$*"
+ _eend "${retval}" eerror "$*"
LAST_E_CMD="eend"
return ${retval}
@@ -316,10 +316,10 @@ eend() {
# if error, show errstr via ewarn
#
ewend() {
- local retval=${1:-0}
+ local retval="${1:-0}"
shift
- _eend ${retval} ewarn "$*"
+ _eend "${retval}" ewarn "$*"
LAST_E_CMD="ewend"
return ${retval}
@@ -348,7 +348,7 @@ veend() {
KV_major() {
[[ -z $1 ]] && return 1
- local KV=$@
+ local KV="$@"
echo "${KV%%.*}"
}
@@ -359,8 +359,8 @@ KV_major() {
KV_minor() {
[[ -z $1 ]] && return 1
- local KV=$@
- KV=${KV#*.}
+ local KV="$@"
+ KV="${KV#*.}"
echo "${KV%%.*}"
}
@@ -371,8 +371,8 @@ KV_minor() {
KV_micro() {
[[ -z $1 ]] && return 1
- local KV=$@
- KV=${KV#*.*.}
+ local KV="$@"
+ KV="${KV#*.*.}"
echo "${KV%%[^[:digit:]]*}"
}
@@ -384,10 +384,10 @@ KV_micro() {
KV_to_int() {
[[ -z $1 ]] && return 1
- local KV_MAJOR=$(KV_major "$1")
- local KV_MINOR=$(KV_minor "$1")
- local KV_MICRO=$(KV_micro "$1")
- local KV_int=$(( KV_MAJOR * 65536 + KV_MINOR * 256 + KV_MICRO ))
+ local KV_MAJOR="$(KV_major "$1")"
+ local KV_MINOR="$(KV_minor "$1")"
+ local KV_MICRO="$(KV_micro "$1")"
+ local KV_int="$(( KV_MAJOR * 65536 + KV_MINOR * 256 + KV_MICRO ))"
# We make version 2.2.0 the minimum version we will handle as
# a sanity check ... if its less, we fail ...
@@ -409,9 +409,9 @@ KV_to_int() {
_RC_GET_KV_CACHE=""
get_KV() {
[[ -z ${_RC_GET_KV_CACHE} ]] \
- && _RC_GET_KV_CACHE=$(uname -r)
+ && _RC_GET_KV_CACHE="$(uname -r)"
- echo $(KV_to_int "${_RC_GET_KV_CACHE}")
+ echo "$(KV_to_int "${_RC_GET_KV_CACHE}")"
return $?
}
@@ -474,11 +474,11 @@ save_options() {
local myopts="$1"
shift
- if [[ ! -d "${svcdir}/options/${myservice}" ]] ; then
- mkdir -p -m 0755 "${svcdir}/options/${myservice}"
+ if [[ ! -d "${svcdir}/options/${SVCNAME}" ]] ; then
+ mkdir -p -m 0755 "${svcdir}/options/${SVCNAME}"
fi
- echo "$*" > "${svcdir}/options/${myservice}/${myopts}"
+ echo "$*" > "${svcdir}/options/${SVCNAME}/${myopts}"
return 0
}
@@ -489,8 +489,8 @@ save_options() {
# by calling the save_options function
#
get_options() {
- if [[ -f "${svcdir}/options/${myservice}/$1" ]] ; then
- echo "$(< ${svcdir}/options/${myservice}/$1)"
+ if [[ -f "${svcdir}/options/${SVCNAME}/$1" ]] ; then
+ echo "$(< ${svcdir}/options/${SVCNAME}/$1)"
fi
return 0
@@ -512,7 +512,7 @@ add_suffix() {
#
get_base_ver() {
[[ ! -r /etc/gentoo-release ]] && return 0
- local ver=$(</etc/gentoo-release)
+ local ver="$(</etc/gentoo-release)"
echo "${ver##* }"
}
@@ -687,7 +687,7 @@ if [[ -z ${EBUILD} ]] ; then
# have a TTY. rc unsets it at the end of running so it shouldn't hang
# around
if [[ -z ${CONSOLETYPE} ]] ; then
- export CONSOLETYPE=$( /sbin/consoletype 2>/dev/null )
+ export CONSOLETYPE="$( /sbin/consoletype 2>/dev/null )"
fi
if [[ ${CONSOLETYPE} == "serial" ]] ; then
RC_NOCOLOR="yes"
@@ -704,6 +704,12 @@ if [[ -z ${EBUILD} ]] ; then
done
setup_defaultlevels
+
+ # If we are not /sbin/rc then ensure that we cannot change level variables
+ if [[ -n ${BASH_SOURCE} \
+ && ${BASH_SOURCE[${#BASH_SOURCE[@]}-1]} != "/sbin/rc" ]] ; then
+ declare -r BOOTLEVEL DEFAULTLEVEL SOFTLEVEL
+ fi
else
setup_defaultlevels
# Should we use colors ?
@@ -724,8 +730,8 @@ if [[ -n ${EBUILD} && $* == *depend* ]] ; then
COLS=80
else
# Setup COLS and ENDCOL so eend can line up the [ ok ]
- COLS=${COLUMNS:-0} # bash's internal COLUMNS variable
- (( COLS == 0 )) && COLS=$(set -- `stty size 2>/dev/null` ; echo $2)
+ COLS="${COLUMNS:-0}" # bash's internal COLUMNS variable
+ (( COLS == 0 )) && COLS="$(set -- `stty size 2>/dev/null` ; echo "$2")"
(( COLS > 0 )) || (( COLS = 80 )) # width of [ ok ] == 7
fi
diff --git a/sbin/init-common-post.sh b/sbin/init-common-post.sh
index 3aed8b8..82445d2 100755
--- a/sbin/init-common-post.sh
+++ b/sbin/init-common-post.sh
@@ -45,7 +45,7 @@ echo "sysinit" > "${svcdir}/softlevel"
check_critical_services
# Update the dependency cache
-/sbin/depscan.sh -u
+/sbin/depscan.sh
# Now that the dependency cache are up to date, make sure these
# are marked as started ...
diff --git a/sbin/rc-daemon.sh b/sbin/rc-daemon.sh
index 24409ed..9f9cd26 100755
--- a/sbin/rc-daemon.sh
+++ b/sbin/rc-daemon.sh
@@ -12,13 +12,11 @@
# when we're testing for the daemon to be running. I (Roy Marples) view this
# as behaviour by design as start-stop-daemon should not be used to run shell
# scripts!
-# At the time of writing, the only culprit I know of is courier-imap.
-# There may be others!
RC_GOT_DAEMON="yes"
[[ ${RC_GOT_FUNCTIONS} != "yes" ]] && source /sbin/functions.sh
-[[ ${RC_GOT_SERVICES} != "yes" ]] && source "${svclib}/sh/rc-services.sh"
+[[ ${RC_GOT_SVCNAMES} != "yes" ]] && source "${svclib}/sh/rc-services.sh"
RC_RETRY_KILL="no"
RC_RETRY_TIMEOUT=1
@@ -100,7 +98,7 @@ rc_setup_daemon_vars() {
# We may want to launch the daemon with a custom command
# This is mainly useful for debugging with apps like valgrind, strace
- local bash_service="$( bash_variable "${myservice}" )"
+ local bash_service="$( bash_variable "${SVCNAME}" )"
if [[ -n ${RC_DAEMON} ]]; then
local -a d=( ${RC_DAEMON} )
if ${stopping}; then
@@ -357,7 +355,7 @@ update_service_status() {
start-stop-daemon() {
local args="$( requote "$@" )" result i
local cmd pidfile pid stopping signal nothing=false
- local daemonfile="${svcdir}/daemons/${myservice}"
+ local daemonfile="${svcdir}/daemons/${SVCNAME}"
local -a RC_DAEMONS=() RC_PIDFILES=()
[[ -e ${daemonfile} ]] && source "${daemonfile}"
diff --git a/sbin/rc-help.sh b/sbin/rc-help.sh
index 1799d96..c86880e 100755
--- a/sbin/rc-help.sh
+++ b/sbin/rc-help.sh
@@ -20,11 +20,11 @@ if [[ -z ${myscript} ]] ; then
fi
if [[ -L ${myscript} ]] ; then
- myservice=$(readlink "${myscript}")
+ SERVICE=$(readlink "${myscript}")
else
- myservice=${myscript}
+ SERVICE=${myscript}
fi
-myservice=${myservice##*/}
+SERVICE=${SERVICE##*/}
if [[ $2 == "help" ]] ; then
BE_VERBOSE="yes"
@@ -44,7 +44,7 @@ ${GREEN}Gentoo RC-Scripts; ${BLUE}http://www.gentoo.org/${OFF}
"
fi
-echo -e "Usage: ${CYAN}${myservice}${OFF} [ ${GREEN}flags${OFF} ] < ${GREEN}options${OFF} >
+echo -e "Usage: ${CYAN}${SERVICE}${OFF} [ ${GREEN}flags${OFF} ] < ${GREEN}options${OFF} >
${CYAN}Normal Options:${OFF}"
@@ -221,7 +221,7 @@ echo -e "
"
fi
-echo -e " /etc/conf.d/${myservice}${NL} /etc/rc.conf"
+echo -e " /etc/conf.d/${SERVICE}${NL} /etc/rc.conf"
if [[ ${BE_VERBOSE} == "yes" ]] ; then
echo -e "
diff --git a/sbin/rc-services.sh b/sbin/rc-services.sh
index 1b68506..2991176 100755
--- a/sbin/rc-services.sh
+++ b/sbin/rc-services.sh
@@ -2,14 +2,13 @@
# Distributed under the terms of the GNU General Public License v2
# RC Dependency and misc service functions
-
-RC_GOT_SERVICES="yes"
+RC_GOT_SVCNAMES="yes"
[[ ${RC_GOT_FUNCTIONS} != "yes" ]] && source /sbin/functions.sh
if [[ ${RC_GOT_DEPTREE_INFO} != "yes" ]] ; then
# Only try and update if we are root
- if [[ ${EUID} == "0" ]] && ! /sbin/depscan.sh -u ; then
+ if [[ ${EUID} == "0" ]] && ! /sbin/depscan.sh ; then
echo
eerror "Error running '/sbin/depscan.sh'!"
eerror "Please correct any problems above."
@@ -141,18 +140,18 @@ check_dependency() {
fi
# Do we have valid info for 'deptype' ?
- eval deps=\"\$\{rc_$1\}\"
- [[ -z ${deps} ]] && return 1
+ deps="rc_$1"
+ [[ -z ${!deps} ]] && return 1
if [[ $2 == "-t" && -n $4 ]]; then
# Check if 'service1' have 'deptype' dependency on 'service2'
- for x in ${deps} ; do
+ for x in ${!deps} ; do
[[ ${x} == "$4" ]] && return 0
done
return 1
else
# Just list all services that 'service1' have 'deptype' dependency on.
- echo "${deps}"
+ echo "${!deps}"
return 0
fi
}
@@ -508,7 +507,7 @@ mark_service_stopped() {
rm -Rf "${svcdir}/daemons/$1" "${svcdir}/starting/$1" \
"${svcdir}/started/$1" "${svcdir}/inactive/$1" \
"${svcdir}/wasinactive/$1" "${svcdir}/stopping/$1" \
- "${svcdir}/scheduled/$1"
+ "${svcdir}/scheduled/$1" "${svcdir}/options/$1"
end_service "$1" 0
@@ -722,10 +721,10 @@ trace_dependencies() {
if [[ $1 == -* ]]; then
deptype="${1/-/}"
- if net_service "${myservice}" ; then
- services=( "net" "${myservice}" )
+ if net_service "${SVCNAME}" ; then
+ services=( "net" "${SVCNAME}" )
else
- services=( "${myservice}" )
+ services=( "${SVCNAME}" )
fi
fi
@@ -800,10 +799,10 @@ trace_dependencies() {
if [[ -n ${deptype} ]] ; then
# If deptype is set, we do not want the name of this service
x=" ${services[@]} "
- services=( ${x// ${myservice} / } )
+ services=( ${x// ${SVCNAME} / } )
# If its a net service, do not include "net"
- if net_service "${myservice}" ; then
+ if net_service "${SVCNAME}" ; then
x=" ${services[@]} "
sorted=( ${services// net / } )
fi
diff --git a/sbin/runscript.sh b/sbin/runscript.sh
index 156ddb2..72347bc 100755
--- a/sbin/runscript.sh
+++ b/sbin/runscript.sh
@@ -6,29 +6,31 @@
[[ ${RC_GOT_FUNCTIONS} != "yes" ]] && source /sbin/functions.sh
# User must be root to run most script stuff (except status)
-if [[ ${EUID} != 0 ]] && ! [[ $2 == "status" && $# -eq 2 ]] ; then
+if [[ ${EUID} != "0" ]] && ! [[ $2 == "status" && $# -eq 2 ]] ; then
eerror "$0: must be root to run init scripts"
exit 1
fi
myscript="$1"
if [[ -L $1 && ! -L "/etc/init.d/${1##*/}" ]] ; then
- myservice="$(readlink "$1")"
+ SVCNAME="$(readlink "$1")"
else
- myservice="$1"
+ SVCNAME="$1"
fi
-myservice="${myservice##*/}"
-export SVCNAME="${myservice}"
+declare -r SVCNAME="${SVCNAME##*/}"
+export SVCNAME
+# Support deprecated myservice variable
+myservice="${SVCNAME}"
# Stop init scripts from working until sysinit completes
if [[ -e /dev/.rcsysinit ]] ; then
- eerror "ERROR: cannot run ${myservice} until sysinit completes"
+ eerror "ERROR: cannot run ${SVCNAME} until sysinit completes"
exit 1
fi
svc_trap() {
- trap 'eerror "ERROR: ${myservice} caught an interrupt"; exit 1' \
+ trap 'eerror "ERROR: ${SVCNAME} caught an interrupt"; exit 1' \
INT QUIT TSTP
}
@@ -40,17 +42,14 @@ svcpause="no"
svcrestart="no"
# Functions to handle dependencies and services
-[[ ${RC_GOT_SERVICES} != "yes" ]] && source "${svclib}/sh/rc-services.sh"
+[[ ${RC_GOT_SVCNAMES} != "yes" ]] && source "${svclib}/sh/rc-services.sh"
# Functions to control daemons
[[ ${RC_GOT_DAEMON} != "yes" ]] && source "${svclib}/sh/rc-daemon.sh"
-# Set $IFACE to the name of the network interface if it is a 'net.*' script
-if [[ ${myservice%%.*} == "net" && ${myservice#*.} != "${myservice}" ]] ; then
- IFACE="${myservice#*.}"
+if [[ ${SVCNAME%%.*} == "net" && ${SVCNAME#*.} != "${SVCNAME}" ]] ; then
NETSERVICE="yes"
else
- IFACE=
- NETSERVICE=
+ NETSERVICE="no"
fi
# Check if the textdomain is non-default
@@ -60,7 +59,7 @@ search_lang="${LC_ALL:-${LC_MESSAGES:-${LANG}}}"
# Source configuration files.
# (1) Source /etc/conf.d/net if it is a net.* service
-# (2) Source /etc/conf.d/${myservice} to get initscript-specific
+# (2) Source /etc/conf.d/${SVCNAME} to get initscript-specific
# configuration (if it exists).
# (3) Source /etc/rc.conf to pick up potentially overriding
# configuration, if the system administrator chose to put it
@@ -69,7 +68,7 @@ if [[ ${NETSERVICE} == "yes" ]] ; then
conf="$(add_suffix /etc/conf.d/net)"
[[ -e ${conf} ]] && source "${conf}"
fi
-conf="$(add_suffix "/etc/conf.d/${myservice}")"
+conf="$(add_suffix "/etc/conf.d/${SVCNAME}")"
[[ -e ${conf} ]] && source "${conf}"
conf="$(add_suffix /etc/rc.conf)"
[[ -e ${conf} ]] && source "${conf}"
@@ -80,28 +79,28 @@ mylevel="${SOFTLEVEL}"
&& mylevel="${DEFAULTLEVEL}"
# Call svc_quit if we abort AND we have obtained a lock
-service_started "${myservice}"
+service_started "${SVCNAME}"
svcstarted="$?"
-service_inactive "${myservice}"
+service_inactive "${SVCNAME}"
svcinactive="$?"
svc_quit() {
- eerror "ERROR: ${myservice} caught an interrupt"
- if service_inactive "${myservice}" || [[ ${svcinactive} == 0 ]] ; then
- mark_service_inactive "${myservice}"
+ eerror "ERROR: ${SVCNAME} caught an interrupt"
+ if service_inactive "${SVCNAME}" || [[ ${svcinactive} == 0 ]] ; then
+ mark_service_inactive "${SVCNAME}"
elif [[ ${svcstarted} == 0 ]] ; then
- mark_service_started "${myservice}"
+ mark_service_started "${SVCNAME}"
else
- mark_service_stopped "${myservice}"
+ mark_service_stopped "${SVCNAME}"
fi
exit 1
}
usage() {
local IFS="|"
- myline="Usage: ${myservice} { $* "
+ myline="Usage: ${SVCNAME} { $* "
echo
eerror "${myline}}"
- eerror " ${myservice} without arguments for full help"
+ eerror " ${SVCNAME} without arguments for full help"
}
stop() {
@@ -110,7 +109,7 @@ stop() {
}
start() {
- eerror "ERROR: ${myservice} does not have a start function."
+ eerror "ERROR: ${SVCNAME} does not have a start function."
# Return failure so the symlink doesn't get created
return 1
}
@@ -134,19 +133,19 @@ svc_schedule_start() {
}
svc_start_scheduled() {
- [[ ! -d "${svcdir}/scheduled/${myservice}" ]] && return
+ [[ ! -d "${svcdir}/scheduled/${SVCNAME}" ]] && return
local x= services=
- for x in $(dolisting "${svcdir}/scheduled/${myservice}/") ; do
+ for x in $(dolisting "${svcdir}/scheduled/${SVCNAME}/") ; do
services="${services} ${x##*/}"
done
for x in ${services} ; do
service_stopped "${x}" && start_service "${x}"
- rm -f "${svcdir}/scheduled/${myservice}/${x}"
+ rm -f "${svcdir}/scheduled/${SVCNAME}/${x}"
done
- rmdir "${svcdir}/scheduled/${myservice}"
+ rmdir "${svcdir}/scheduled/${SVCNAME}"
}
svc_stop() {
@@ -154,24 +153,24 @@ svc_stop() {
local -a servicelist=()
# Do not try to stop if it had already failed to do so
- if is_runlevel_stop && service_failed "${myservice}" ; then
+ if is_runlevel_stop && service_failed "${SVCNAME}" ; then
return 1
- elif service_stopped "${myservice}" ; then
- ewarn "WARNING: ${myservice} has not yet been started."
+ elif service_stopped "${SVCNAME}" ; then
+ ewarn "WARNING: ${SVCNAME} has not yet been started."
return 0
fi
- if ! mark_service_stopping "${myservice}" ; then
- eerror "ERROR: ${myservice} is already stopping."
+ if ! mark_service_stopping "${SVCNAME}" ; then
+ eerror "ERROR: ${SVCNAME} is already stopping."
return 1
fi
# Ensure that we clean up if we abort for any reason
trap "svc_quit" INT QUIT TSTP
- mark_service_starting "${myservice}"
- service_message "Service ${myservice} stopping"
+ mark_service_starting "${SVCNAME}"
+ service_message "Service ${SVCNAME} stopping"
- if in_runlevel "${myservice}" "${BOOTLEVEL}" && \
+ if in_runlevel "${SVCNAME}" "${BOOTLEVEL}" && \
[[ ${SOFTLEVEL} != "reboot" && ${SOFTLEVEL} != "shutdown" ]] ; then
ewarn "WARNING: you are stopping a boot service."
fi
@@ -179,15 +178,15 @@ svc_stop() {
if [[ ${svcpause} != "yes" ]] ; then
if [[ ${NETSERVICE} == "yes" ]] ; then
# A net.* service
- if in_runlevel "${myservice}" "${BOOTLEVEL}" || \
- in_runlevel "${myservice}" "${mylevel}" ; then
+ if in_runlevel "${SVCNAME}" "${BOOTLEVEL}" || \
+ in_runlevel "${SVCNAME}" "${mylevel}" ; then
# Only worry about net.* services if this is the last one
# running or if RC_NET_STRICT_CHECKING is set ...
! is_net_up && mydeps="net"
fi
- mydeps="${mydeps} ${myservice}"
+ mydeps="${mydeps} ${SVCNAME}"
else
- mydeps="${myservice}"
+ mydeps="${SVCNAME}"
fi
fi
@@ -222,7 +221,7 @@ svc_stop() {
if [[ ${retval} != 0 ]] ; then
eerror "ERROR: problems stopping dependent services."
- eerror " ${myservice} is still up."
+ eerror " ${SVCNAME} is still up."
else
# Now that deps are stopped, stop our service
(
@@ -241,7 +240,7 @@ svc_stop() {
# If a service has been marked inactive, exit now as something
# may attempt to start it again later
- if service_inactive "${myservice}" ; then
+ if service_inactive "${SVCNAME}" ; then
svcinactive=0
return 0
fi
@@ -250,28 +249,28 @@ svc_stop() {
if [[ ${retval} != 0 ]] ; then
# Did we fail to stop? create symlink to stop multible attempts at
# runlevel change. Note this is only used at runlevel change ...
- is_runlevel_stop && mark_service_failed "${myservice}"
+ is_runlevel_stop && mark_service_failed "${SVCNAME}"
# If we are halting the system, do it as cleanly as possible
if [[ ${SOFTLEVEL} == "reboot" || ${SOFTLEVEL} == "shutdown" ]] ; then
- mark_service_stopped "${myservice}"
+ mark_service_stopped "${SVCNAME}"
else
if [[ ${svcinactive} == 0 ]] ; then
- mark_service_inactive "${myservice}"
+ mark_service_inactive "${SVCNAME}"
else
- mark_service_started "${myservice}"
+ mark_service_started "${SVCNAME}"
fi
fi
- service_message "eerror" "ERROR: ${myservice} failed to stop"
+ service_message "eerror" "ERROR: ${SVCNAME} failed to stop"
else
svcstarted=1
- if service_inactive "${myservice}" ; then
+ if service_inactive "${SVCNAME}" ; then
svcinactive=0
else
- mark_service_stopped "${myservice}"
+ mark_service_stopped "${SVCNAME}"
fi
- service_message "Service ${myservice} stopped"
+ service_message "Service ${SVCNAME} stopped"
fi
# Reset the trap
@@ -284,23 +283,23 @@ svc_start() {
local x= y= retval=0 startfail= startinactive=
# Do not try to start if i have done so already on runlevel change
- if is_runlevel_start && service_failed "${myservice}" ; then
+ if is_runlevel_start && service_failed "${SVCNAME}" ; then
return 1
- elif service_started "${myservice}" ; then
- ewarn "WARNING: ${myservice} has already been started."
+ elif service_started "${SVCNAME}" ; then
+ ewarn "WARNING: ${SVCNAME} has already been started."
return 0
- elif service_inactive "${myservice}" ; then
+ elif service_inactive "${SVCNAME}" ; then
if [[ ${IN_BACKGROUND} != "true" ]] ; then
- ewarn "WARNING: ${myservice} has already been started."
+ ewarn "WARNING: ${SVCNAME} has already been started."
return 0
fi
fi
- if ! mark_service_starting "${myservice}" ; then
- if service_stopping "${myservice}" ; then
- eerror "ERROR: ${myservice} is already stopping."
+ if ! mark_service_starting "${SVCNAME}" ; then
+ if service_stopping "${SVCNAME}" ; then
+ eerror "ERROR: ${SVCNAME} is already stopping."
else
- eerror "ERROR: ${myservice} is already starting."
+ eerror "ERROR: ${SVCNAME} is already starting."
fi
return 1
fi
@@ -308,13 +307,13 @@ svc_start() {
# Ensure that we clean up if we abort for any reason
trap "svc_quit" INT QUIT TSTP
- service_message "Service ${myservice} starting"
+ service_message "Service ${SVCNAME} starting"
# Save the IN_BACKGROUND var as we need to clear it for starting depends
local ib_save="${IN_BACKGROUND}"
unset IN_BACKGROUND
- local startupservices="$(ineed "${myservice}") $(valid_iuse "${myservice}")"
+ local startupservices="$(ineed "${SVCNAME}") $(valid_iuse "${SVCNAME}")"
local netservices=
for x in $(dolisting "/etc/runlevels/${BOOTLEVEL}/net.*") \
$(dolisting "/etc/runlevels/${mylevel}/net.*") ; do
@@ -339,7 +338,7 @@ svc_start() {
# We also wait for any services we're after to finish incase they
# have a "before" dep but we don't dep on them.
if is_runlevel_start ; then
- startupservices="${startupservices} $(valid_iafter "${myservice}")"
+ startupservices="${startupservices} $(valid_iafter "${SVCNAME}")"
fi
if [[ " ${startupservices} " == *" net "* ]] ; then
@@ -354,12 +353,12 @@ svc_start() {
wait_service "${x}"
if ! service_started "${x}" ; then
# A 'need' dependency is critical for startup
- if ineed -t "${myservice}" "${x}" >/dev/null \
- || net_service "${x}" && ineed -t "${myservice}" net \
+ if ineed -t "${SVCNAME}" "${x}" >/dev/null \
+ || 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
- svc_schedule_start "${x}" "${myservice}"
+ svc_schedule_start "${x}" "${SVCNAME}"
startinactive="${x}"
else
startfail="${x}"
@@ -371,15 +370,15 @@ svc_start() {
if [[ -n ${startfail} ]] ; then
eerror "ERROR: Problem starting needed service ${startfail}"
- eerror " ${myservice} was not started."
+ eerror " ${SVCNAME} was not started."
retval=1
elif [[ -n ${startinactive} ]] ; then
- ewarn "WARNING: ${myservice} is scheduled to start when ${startinactive} has started."
+ ewarn "WARNING: ${SVCNAME} is scheduled to start when ${startinactive} has started."
retval=1
- elif broken "${myservice}" ; then
+ elif broken "${SVCNAME}" ; then
eerror "ERROR: Some services needed are missing. Run"
- eerror " './${myservice} broken' for a list of those"
- eerror " services. ${myservice} was not started."
+ eerror " './${SVCNAME} broken' for a list of those"
+ eerror " services. ${SVCNAME} was not started."
retval=1
else
IN_BACKGROUND="${ib_save}"
@@ -404,28 +403,28 @@ svc_start() {
# If a service has been marked inactive, exit now as something
# may attempt to start it again later
- if service_inactive "${myservice}" ; then
+ if service_inactive "${SVCNAME}" ; then
svcinactive=0
- service_message "ewarn" "WARNING: ${myservice} has started but is inactive"
+ service_message "ewarn" "WARNING: ${SVCNAME} has started but is inactive"
return 1
fi
fi
if [[ ${retval} != 0 ]] ; then
if [[ ${svcinactive} == 0 ]] ; then
- mark_service_inactive "${myservice}"
+ mark_service_inactive "${SVCNAME}"
else
- mark_service_stopped "${myservice}"
+ mark_service_stopped "${SVCNAME}"
fi
if [[ -z ${startinactive} ]] ; then
- is_runlevel_start && mark_service_failed "${myservice}"
- service_message "eerror" "ERROR: ${myservice} failed to start"
+ is_runlevel_start && mark_service_failed "${SVCNAME}"
+ service_message "eerror" "ERROR: ${SVCNAME} failed to start"
fi
else
svcstarted=0
- mark_service_started "${myservice}"
- service_message "Service ${myservice} started"
+ mark_service_started "${SVCNAME}"
+ service_message "Service ${SVCNAME} started"
fi
# Reset the trap
@@ -435,7 +434,7 @@ svc_start() {
}
svc_restart() {
- if ! service_stopped "${myservice}" ; then
+ if ! service_stopped "${SVCNAME}" ; then
svc_stop || return "$?"
fi
svc_start
@@ -451,18 +450,18 @@ svc_status() {
# If we are effectively root, check to see if required daemons are running
# and update our status accordingly
- [[ ${EUID} == 0 ]] && update_service_status "${myservice}"
+ [[ ${EUID} == 0 ]] && update_service_status "${SVCNAME}"
- if service_stopping "${myservice}" ; then
+ if service_stopping "${SVCNAME}" ; then
efunc="eerror"
state="stopping"
- elif service_starting "${myservice}" ; then
+ elif service_starting "${SVCNAME}" ; then
efunc="einfo"
state="starting"
- elif service_inactive "${myservice}" ; then
+ elif service_inactive "${SVCNAME}" ; then
efunc="ewarn"
state="inactive"
- elif service_started "${myservice}" ; then
+ elif service_started "${SVCNAME}" ; then
efunc="einfo"
state="started"
else
@@ -544,8 +543,8 @@ retval=0
for arg in $* ; do
case "${arg}" in
stop)
- if [[ -e "${svcdir}/scheduled/${myservice}" ]] ; then
- rm -Rf "${svcdir}/scheduled/${myservice}"
+ if [[ -e "${svcdir}/scheduled/${SVCNAME}" ]] ; then
+ rm -Rf "${svcdir}/scheduled/${SVCNAME}"
fi
# Stoped from the background - treat this as a restart so that
@@ -554,7 +553,7 @@ for arg in $* ; do
rm -rf "${svcdir}/snapshot/$$"
mkdir -p "${svcdir}/snapshot/$$"
cp -pP "${svcdir}"/started/* "${svcdir}/snapshot/$$/"
- rm -f "${svcdir}/snapshot/$$/${myservice}"
+ rm -f "${svcdir}/snapshot/$$/${SVCNAME}"
fi
svc_stop
@@ -563,18 +562,18 @@ for arg in $* ; do
if [[ ${IN_BACKGROUND} == "true" ]] ; then
for x in $(dolisting "${svcdir}/snapshot/$$/") ; do
if service_stopped "${x##*/}" ; then
- svc_schedule_start "${myservice}" "${x##*/}"
+ svc_schedule_start "${SVCNAME}" "${x##*/}"
fi
done
else
- rm -f "${svcdir}"/scheduled/*/"${myservice}"
+ rm -f "${svcdir}"/scheduled/*/"${SVCNAME}"
fi
;;
start)
svc_start
retval="$?"
- service_started "${myservice}" && svc_start_scheduled
+ service_started "${SVCNAME}" && svc_start_scheduled
;;
needsme|ineed|usesme|iuse|broken)
trace_dependencies "-${arg}"
@@ -584,8 +583,8 @@ for arg in $* ; do
retval="$?"
;;
zap)
- einfo "Manually resetting ${myservice} to stopped state."
- mark_service_stopped "${myservice}"
+ einfo "Manually resetting ${SVCNAME} to stopped state."
+ mark_service_stopped "${SVCNAME}"
;;
restart)
svcrestart="yes"
@@ -598,17 +597,17 @@ for arg in $* ; do
rm -rf "${svcdir}/snapshot/$$"
mkdir -p "${svcdir}/snapshot/$$"
cp -pP "${svcdir}"/started/* "${svcdir}/snapshot/$$/"
- rm -f "${svcdir}/snapshot/$$/${myservice}"
+ rm -f "${svcdir}/snapshot/$$/${SVCNAME}"
# Simple way to try and detect if the service use svc_{start,stop}
# to restart if it have a custom restart() funtion.
- if [[ -n $(egrep '^[[:space:]]*restart[[:space:]]*()' "/etc/init.d/${myservice}") ]] ; then
- if [[ -z $(egrep 'svc_stop' "/etc/init.d/${myservice}") || \
- -z $(egrep 'svc_start' "/etc/init.d/${myservice}") ]] ; then
+ if [[ -n $(egrep '^[[:space:]]*restart[[:space:]]*()' "/etc/init.d/${SVCNAME}") ]] ; then
+ if [[ -z $(egrep 'svc_stop' "/etc/init.d/${SVCNAME}") || \
+ -z $(egrep 'svc_start' "/etc/init.d/${SVCNAME}") ]] ; then
echo
ewarn "Please use 'svc_stop; svc_start' and not 'stop; start' to"
ewarn "restart the service in its custom 'restart()' function."
- ewarn "Run ${myservice} without arguments for more info."
+ ewarn "Run ${SVCNAME} without arguments for more info."
echo
svc_restart
else
@@ -619,24 +618,24 @@ for arg in $* ; do
fi
retval="$?"
- [[ -e "${svcdir}/scheduled/${myservice}" ]] \
- && rm -Rf "${svcdir}/scheduled/${myservice}"
+ [[ -e "${svcdir}/scheduled/${SVCNAME}" ]] \
+ && rm -Rf "${svcdir}/scheduled/${SVCNAME}"
# Restart dependencies as well
for x in $(dolisting "${svcdir}/snapshot/$$/") ; do
if service_stopped "${x##*/}" ; then
- if service_inactive "${myservice}" \
- || service_wasinactive "${myservice}" ; then
- svc_schedule_start "${myservice}" "${x##*/}"
- ewarn "WARNING: ${x##*/} is scheduled to start when ${myservice} has started."
- elif service_started "${myservice}" ; then
+ if service_inactive "${SVCNAME}" \
+ || service_wasinactive "${SVCNAME}" ; then
+ svc_schedule_start "${SVCNAME}" "${x##*/}"
+ ewarn "WARNING: ${x##*/} is scheduled to start when ${SVCNAME} has started."
+ elif service_started "${SVCNAME}" ; then
start_service "${x##*/}"
fi
fi
done
rm -rf "${svcdir}/snapshot/$$"
- service_started "${myservice}" && svc_start_scheduled
+ service_started "${SVCNAME}" && svc_start_scheduled
# Wait for services to come up
[[ ${RC_PARALLEL_STARTUP} == "yes" ]] && wait
diff --git a/src/awk/cachedepends.awk b/src/awk/cachedepends.awk
index 017e231..46945e9 100644
--- a/src/awk/cachedepends.awk
+++ b/src/awk/cachedepends.awk
@@ -30,9 +30,13 @@ function print_start() {
function print_header1(mtime) {
print "#*** " MYFILENAME " ***" >> TMPCACHE
print "" >> TMPCACHE
- print "myservice=\"" MYFILENAME "\"" >> TMPCACHE
- print "myservice=\"${myservice##*/}\"" >> TMPCACHE
- print "echo \"RCSCRIPT ${myservice}\"" >> TMPCACHE
+ print "SVCNAME=\"" MYFILENAME "\"" >> TMPCACHE
+ print "SVCNAME=\"${SVCNAME##*/}\"" >> TMPCACHE
+
+ # Support deprected myservice variable
+ print "myservice=\"${SVCNAME}\"" >> TMPCACHE
+
+ print "echo \"RCSCRIPT ${SVCNAME}\"" >> TMPCACHE
print "" >> TMPCACHE
print "echo \"MTIME " mtime "\"" >> TMPCACHE
print "" >> TMPCACHE
@@ -42,11 +46,11 @@ function print_header2(mtime) {
print "(" >> TMPCACHE
print " # Get settings for rc-script ..." >> TMPCACHE
print "" >> TMPCACHE
- print " [ -e \"/etc/conf.d/${myservice}\" ] && source \"/etc/conf.d/${myservice}\"" >> TMPCACHE
- print "" >> TMPCACHE
print " [ -e /etc/conf.d/net ] && \\" >> TMPCACHE
- print " [ \"${myservice%%.*}\" = \"net\" ] && \\" >> TMPCACHE
- print " [ \"${myservice##*.}\" != \"${myservice}\" ] && source /etc/conf.d/net" >> TMPCACHE
+ print " [ \"${SVCNAME%%.*}\" = \"net\" ] && \\" >> TMPCACHE
+ print " [ \"${SVCNAME##*.}\" != \"${SVCNAME}\" ] && source /etc/conf.d/net" >> TMPCACHE
+ print "" >> TMPCACHE
+ print " [ -e \"/etc/conf.d/${SVCNAME}\" ] && source \"/etc/conf.d/${SVCNAME}\"" >> TMPCACHE
print "" >> TMPCACHE
print " [ -e /etc/rc.conf ] && source /etc/rc.conf" >> TMPCACHE
print "" >> TMPCACHE
diff --git a/src/awk/gendepends.awk b/src/awk/gendepends.awk
index c4073b4..d092ccb 100644
--- a/src/awk/gendepends.awk
+++ b/src/awk/gendepends.awk
@@ -504,8 +504,8 @@ END {
}
for (x = TYPES_MIN; x <= TYPES_MAX; x++)
- print "rc_type_" TYPE_NAMES[x] "=" x >> (CACHEDTREE)
- print "rc_index_scale=" (TYPES_MAX + 1) >> (CACHEDTREE)
+ print "declare -r rc_type_" TYPE_NAMES[x] "=" x >> (CACHEDTREE)
+ print "declare -r rc_index_scale=" (TYPES_MAX + 1) >> (CACHEDTREE)
print "" >> (CACHEDTREE)
print "declare -a RC_DEPEND_TREE" >> (CACHEDTREE)
print "" >> (CACHEDTREE)
@@ -542,15 +542,17 @@ END {
print "" >> (CACHEDTREE)
}
+ # Ensure that no-one changes our tree
+ print "declare -r RC_DEPEND_TREE" >> (CACHEDTREE)
# Do not export these, as we want them local
- print "RC_GOT_DEPTREE_INFO=\"yes\"" >> (CACHEDTREE)
+ print "declare -r RC_GOT_DEPTREE_INFO=\"yes\"" >> (CACHEDTREE)
print "" >> (CACHEDTREE)
if (check_provide("logger"))
- print "LOGGER_SERVICE=\"" get_provide("logger") "\"" >> (CACHEDTREE)
+ print "declare -r LOGGER_SERVICE=\"" get_provide("logger") "\"" >> (CACHEDTREE)
else
- print "LOGGER_SERVICE=" >> (CACHEDTREE)
+ print "declare -r LOGGER_SERVICE=" >> (CACHEDTREE)
close(CACHEDTREE)