summaryrefslogtreecommitdiff
path: root/sh
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2008-03-19 19:57:24 +0000
committerRoy Marples <roy@marples.name>2008-03-19 19:57:24 +0000
commit6159a32f39afc60d88602cc796cef6a395bb78bf (patch)
tree6b2471081a475c0c42b41bd7aca6a1a0e8fcdbe6 /sh
parent6d2e1f7addcf5ff6594d381845708229086d8d96 (diff)
downloadopenrc-6159a32f39afc60d88602cc796cef6a395bb78bf.tar.gz
openrc-6159a32f39afc60d88602cc796cef6a395bb78bf.tar.bz2
openrc-6159a32f39afc60d88602cc796cef6a395bb78bf.tar.xz
SVCNAME -> RC_SVCNAME, but export SVCNAME still for compat.
Diffstat (limited to 'sh')
-rw-r--r--sh/gendepends.sh.in42
-rw-r--r--sh/net.sh.in10
-rw-r--r--sh/runscript.sh.in37
3 files changed, 48 insertions, 41 deletions
diff --git a/sh/gendepends.sh.in b/sh/gendepends.sh.in
index c80508d..8ab50ad 100644
--- a/sh/gendepends.sh.in
+++ b/sh/gendepends.sh.in
@@ -7,25 +7,25 @@
. @PREFIX@/@SYSCONFDIR@/init.d/functions.sh
config() {
- [ -n "$*" ] && echo "${SVCNAME} config $*" >&3
+ [ -n "$*" ] && echo "${RC_SVCNAME} config $*" >&3
}
need() {
- [ -n "$*" ] && echo "${SVCNAME} ineed $*" >&3
+ [ -n "$*" ] && echo "${RC_SVCNAME} ineed $*" >&3
}
use() {
- [ -n "$*" ] && echo "${SVCNAME} iuse $*" >&3
+ [ -n "$*" ] && echo "${RC_SVCNAME} iuse $*" >&3
}
before() {
- [ -n "$*" ] && echo "${SVCNAME} ibefore $*" >&3
+ [ -n "$*" ] && echo "${RC_SVCNAME} ibefore $*" >&3
}
after() {
- [ -n "$*" ] && echo "${SVCNAME} iafter $*" >&3
+ [ -n "$*" ] && echo "${RC_SVCNAME} iafter $*" >&3
}
provide() {
- [ -n "$*" ] && echo "${SVCNAME} iprovide $*" >&3
+ [ -n "$*" ] && echo "${RC_SVCNAME} iprovide $*" >&3
}
keyword() {
- [ -n "$*" ] && echo "${SVCNAME} keyword $*" >&3
+ [ -n "$*" ] && echo "${RC_SVCNAME} keyword $*" >&3
}
depend() {
:
@@ -47,35 +47,39 @@ do
_done_dirs="${_done_dirs} ${_dir}"
cd "${_dir}"
- for SVCNAME in *; do
- [ -x "${SVCNAME}" ] || continue
+ for RC_SERVICE in *; do
+ [ -x "${RC_SERVICE}" ] || continue
# Only generate dependencies for runscripts
- read one two < "${SVCNAME}"
+ read one two < "${RC_SERVICE}"
[ "${one}" = "#!@PREFIX@/sbin/runscript" ] || continue
unset one two
- export SVCNAME=${SVCNAME##*/}
+ export RC_SVCNAME=${RC_SERVICE##*/}
+
+ # Compat
+ export SVCNAME=${RC_SVCNAME}
+
(
# Save stdout in fd3, then remap it to stderr
exec 3>&1 1>&2
- _rc_c=${SVCNAME%%.*}
- if [ -n "${_rc_c}" -a "${_rc_c}" != "${SVCNAME}" ]; then
+ _rc_c=${RC_SVCNAME%%.*}
+ if [ -n "${_rc_c}" -a "${_rc_c}" != "${RC_SVCNAME}" ]; then
if [ -e "${_dir}/../conf.d/${_rc_c}" ]; then
. "${_dir}/../conf.d/${_rc_c}"
fi
fi
unset _rc_c
- if [ -e "${_dir}/../conf.d/${SVCNAME}" ]; then
- . "${_dir}/../conf.d/${SVCNAME}"
+ if [ -e "${_dir}/../conf.d/${RC_SVCNAME}" ]; then
+ . "${_dir}/../conf.d/${RC_SVCNAME}"
fi
[ -e @PREFIX@/@SYSCONFDIR@/rc.conf ] && . @PREFIX@/@SYSCONFDIR@/rc.conf
- if . "${_dir}/${SVCNAME}"; then
- echo "${SVCNAME}" >&3
+ if . "${_dir}/${RC_SVCNAME}"; then
+ echo "${RC_SVCNAME}" >&3
depend
# Add any user defined depends
@@ -85,9 +89,9 @@ do
IFS=:
set -- ${_deptype}
unset IFS
- eval _depends=\$rc_$(shell_var "${SVCNAME}")_$1
+ eval _depends=\$rc_$(shell_var "${RC_SVCNAME}")_$1
[ -z "${_depends}" ] && eval _depends=\$rc_$1
- [ -z "${_depends}" ] && eval _depends=\$RC_$(shell_var "${SVCNAME}")_$2
+ [ -z "${_depends}" ] && eval _depends=\$RC_$(shell_var "${RC_SVCNAME}")_$2
[ -z "${_depends}" ] && eval _depends=\$RC_$2
$1 ${_depends}
diff --git a/sh/net.sh.in b/sh/net.sh.in
index 1ad9998..8b03aff 100644
--- a/sh/net.sh.in
+++ b/sh/net.sh.in
@@ -15,7 +15,7 @@ __IFS="
"
depend()
{
- local IFACE=${SVCNAME#*.}
+ local IFACE=${RC_SVCNAME#*.}
local IFVAR=$(shell_var "${IFACE}")
need localmount
@@ -335,7 +335,7 @@ _load_modules()
# Now load and wrap our functions
if ! . "${MODULESDIR}/${mod}.sh"; then
- eend 1 "${SVCNAME}: error loading module \`${mod}'"
+ eend 1 "${RC_SVCNAME}: error loading module \`${mod}'"
exit 1
fi
@@ -447,7 +447,7 @@ _load_config()
start()
{
- local IFACE=${SVCNAME#*.} oneworked=false module=
+ local IFACE=${RC_SVCNAME#*.} oneworked=false module=
local IFVAR=$(shell_var "${IFACE}") cmd= our_metric=
local metric=0
@@ -487,7 +487,7 @@ start()
if ! _wait_for_carrier; then
if service_started devd; then
ewarn "no carrier, but devd will start us when we have one"
- mark_service_inactive "${SVCNAME}"
+ mark_service_inactive "${RC_SVCNAME}"
else
eerror "no carrier"
fi
@@ -617,7 +617,7 @@ ${routes}"
stop()
{
- local IFACE=${SVCNAME#*.} module=
+ local IFACE=${RC_SVCNAME#*.} module=
local IFVAR=$(shell_var "${IFACE}") opts=
einfo "Bringing down interface ${IFACE}"
diff --git a/sh/runscript.sh.in b/sh/runscript.sh.in
index 0df0aa0..51777fa 100644
--- a/sh/runscript.sh.in
+++ b/sh/runscript.sh.in
@@ -14,20 +14,23 @@ if [ -r /sbin/livecd-functions.sh ]; then
fi
if [ -z "$1" -o -z "$2" ]; then
- eerror "${SVCNAME}: not enough arguments"
+ eerror "${RC_SVCNAME}: not enough arguments"
exit 1
fi
# So daemons know where to recall us if needed
export RC_SERVICE="$1"
+# Compat
+export SVCNAME=${RC_SVCNAME}
+
# Descript the init script to the user
describe()
{
if [ -n "${description}" ]; then
einfo "${description}"
else
- ewarn "No description for ${SVCNAME}"
+ ewarn "No description for ${RC_SVCNAME}"
fi
local svc= desc=
@@ -45,8 +48,8 @@ yesno ${RC_DEBUG} && set -x
_conf_d=${1%/*}/../conf.d
# If we're net.eth0 or openvpn.work then load net or openvpn config
-_c=${SVCNAME%%.*}
-if [ -n "${_c}" -a "${_c}" != "${SVCNAME}" ]; then
+_c=${RC_SVCNAME%%.*}
+if [ -n "${_c}" -a "${_c}" != "${RC_SVCNAME}" ]; then
if [ -e "${_conf_d}/${_c}.${RC_RUNLEVEL}" ]; then
. "${_conf_d}/${_c}.${RC_RUNLEVEL}"
elif [ -e "${_conf_d}/${_c}" ]; then
@@ -56,10 +59,10 @@ fi
unset _c
# Overlay with our specific config
-if [ -e "${_conf_d}/${SVCNAME}.${RC_RUNLEVEL}" ]; then
- . "${_conf_d}/${SVCNAME}.${RC_RUNLEVEL}"
-elif [ -e "${_conf_d}/${SVCNAME}" ]; then
- . "${_conf_d}/${SVCNAME}"
+if [ -e "${_conf_d}/${RC_SVCNAME}.${RC_RUNLEVEL}" ]; then
+ . "${_conf_d}/${RC_SVCNAME}.${RC_RUNLEVEL}"
+elif [ -e "${_conf_d}/${RC_SVCNAME}" ]; then
+ . "${_conf_d}/${RC_SVCNAME}"
fi
unset _conf_d
@@ -75,7 +78,7 @@ shift
for _d in ${required_dirs}; do
if [ ! -d ${_d} ]; then
- eerror "${SVCNAME}: \`${_d}' is not a directory"
+ eerror "${RC_SVCNAME}: \`${_d}' is not a directory"
exit 1
fi
done
@@ -83,7 +86,7 @@ unset _d
for _f in ${required_files}; do
if [ ! -r ${_f} ]; then
- eerror "${SVCNAME}: \`${_f}' is not readable"
+ eerror "${RC_SVCNAME}: \`${_f}' is not readable"
exit 1
fi
done
@@ -94,7 +97,7 @@ if [ -n "${command}" ]; then
if ! type start >/dev/null 2>&1; then
start() {
local _background=
- ebegin "Starting ${name:-${SVCNAME}}"
+ ebegin "Starting ${name:-${RC_SVCNAME}}"
if yesno "${command_background}"; then
_background="--background --pidfile"
fi
@@ -109,7 +112,7 @@ if [ -n "${command}" ]; then
${pidfile:+--pidfile} ${pidfile} \
${_background} ${start_stop_daemon_args} \
-- ${command_args}
- eend $? "Failed to start ${SVCNAME}" && return 0
+ eend $? "Failed to start ${RC_SVCNAME}" && return 0
if yesno "${start_inactive}"; then
if ! ${_inactive}; then
mark_service_stopped
@@ -125,12 +128,12 @@ fi
if [ -n "${command}" -o -n "${procname}" -o -n "${pidfile}" ]; then
if ! type stop >/dev/null 2>&1; then
stop() {
- ebegin "Stopping ${name:-${SVCNAME}}"
+ ebegin "Stopping ${name:-${RC_SVCNAME}}"
start-stop-daemon --stop \
${command:+--exec} ${command} \
${procname:+--name} ${procname} \
${pidfile:+--pidfile} ${pidfile}
- eend $? "Failed to stop ${SVCNAME}"
+ eend $? "Failed to stop ${RC_SVCNAME}"
}
fi
fi
@@ -159,7 +162,7 @@ while [ -n "$1" ]; do
for _cmd in ${extra_started_commands}; do
if [ "${_cmd}" = "$1" ]; then
if ! service_started; then
- eerror "${SVCNAME}: cannot \`$1' as it has not been started"
+ eerror "${RC_SVCNAME}: cannot \`$1' as it has not been started"
exit 1
fi
fi
@@ -179,12 +182,12 @@ while [ -n "$1" ]; do
shift
continue 2
else
- eerror "${SVCNAME}: function \`$1' defined but does not exist"
+ eerror "${RC_SVCNAME}: function \`$1' defined but does not exist"
exit 1
fi
fi
fi
done
- eerror "${SVCNAME}: unknown function \`$1'"
+ eerror "${RC_SVCNAME}: unknown function \`$1'"
exit 1
done