aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2009-04-26 21:13:26 +0000
committerRoy Marples <roy@marples.name>2009-04-26 21:13:26 +0000
commit2b866f264fa2ea9cda891018234414c4f4942eb8 (patch)
tree4e0083f36d53b61ee4d3e54495e46af5a1eab3e8
parent59574780da461ea08af57a0bb322268369f89abc (diff)
Stop using needless {} in vars
-rw-r--r--sh/functions.sh.in47
-rw-r--r--sh/gendepends.sh.in65
-rw-r--r--sh/ifwatchd-carrier.sh.in2
-rw-r--r--sh/ifwatchd-nocarrier.sh.in2
-rw-r--r--sh/init-common-post.sh.in16
-rw-r--r--sh/init.sh.BSD.in16
-rw-r--r--sh/init.sh.Linux.in22
-rw-r--r--sh/rc-functions.sh.in28
-rw-r--r--sh/rc-mount.sh38
-rw-r--r--sh/runscript.sh.in131
-rwxr-xr-xsh/runtests.sh22
11 files changed, 198 insertions, 191 deletions
diff --git a/sh/functions.sh.in b/sh/functions.sh.in
index acf37e45..3f41f8fc 100644
--- a/sh/functions.sh.in
+++ b/sh/functions.sh.in
@@ -1,4 +1,4 @@
-# Copyright 2007-2008 Roy Marples <roy@marples.name>
+# Copyright 2007-2009 Roy Marples <roy@marples.name>
# All rights reserved. Released under the 2-clause BSD license.
# Allow any sh script to work with einfo functions and friends
@@ -9,14 +9,14 @@ RC_GOT_FUNCTIONS="yes"
eindent()
{
EINFO_INDENT=$((${EINFO_INDENT:-0} + 2))
- [ "${EINFO_INDENT}" -gt 40 ] && EINFO_INDENT=40
+ [ "$EINFO_INDENT" -gt 40 ] && EINFO_INDENT=40
export EINFO_INDENT
}
eoutdent()
{
EINFO_INDENT=$((${EINFO_INDENT:-0} - 2))
- [ "${EINFO_INDENT}" -lt 0 ] && EINFO_INDENT=0
+ [ "$EINFO_INDENT" -lt 0 ] && EINFO_INDENT=0
return 0
}
@@ -31,10 +31,10 @@ yesno()
local value=
eval value=\$${1}
- case "${value}" in
+ case "$value" in
[Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1) return 0;;
[Nn][Oo]|[Ff][Aa][Ll][Ss][Ee]|[Oo][Ff][Ff]|0) return 1;;
- *) vewarn "\$${1} is not set properly"; return 1;;
+ *) vewarn "\$$1 is not set properly"; return 1;;
esac
}
@@ -45,17 +45,16 @@ rc_runlevel() {
_sanitize_path()
{
local IFS=":" p= path=
- for p in ${PATH}; do
- case "${p}" in
+ for p in $PATH; do
+ case "$p" in
@PREFIX@/@LIB@/rc/bin|@PREFIX@/@LIB@/rc/sbin);;
@PREFIX@/bin|@PREFIX@/sbin|/usr/bin|/usr/sbin);;
@PKG_PREFIX@/bin|@PKG_PREFIX@/sbin);;
@LOCAL_PREFIX@/bin|@LOCAL_PREFIX@/sbin);;
- *) path="${path}${path:+:}${p}";;
+ *) path="$path${path:+:}$p";;
esac
done
-
- echo "${path}"
+ echo "$path"
}
# Allow our scripts to support zsh
@@ -77,24 +76,24 @@ _PKG_PREFIX=@PKG_PREFIX@
_LOCAL_PREFIX=@LOCAL_PREFIX@
_LOCAL_PREFIX=${_LOCAL_PREFIX:-/usr/local}
_PATH=@PREFIX@/@LIB@/rc/bin
-case "${_PREFIX}" in
- "${_PKG_PREFIX}"|"${_LOCAL_PREFIX}") ;;
- *) _PATH="${_PATH}:${_PREFIX}/bin:${_PREFIX}/sbin";;
+case "$_PREFIX" in
+ "$_PKG_PREFIX"|"$_LOCAL_PREFIX") ;;
+ *) _PATH="$_PATH:$_PREFIX/bin:$_PREFIX/sbin";;
esac
-_PATH="${_PATH}":/bin:/sbin:/usr/bin:/usr/sbin
+_PATH="$_PATH":/bin:/sbin:/usr/bin:/usr/sbin
-if [ -n "${_PKG_PREFIX}" ]; then
- _PATH="${_PATH}:${_PKG_PREFIX}/bin:${_PKG_PREFIX}/sbin"
+if [ -n "$_PKG_PREFIX" ]; then
+ _PATH="$_PATH:$_PKG_PREFIX/bin:$_PKG_PREFIX/sbin"
fi
-if [ -n "${_LOCAL_PREFIX}" ]; then
- _PATH="${_PATH}:${_LOCAL_PREFIX}/bin:${_LOCAL_PREFIX}/sbin"
+if [ -n "$_LOCAL_PREFIX" ]; then
+ _PATH="$_PATH:$_LOCAL_PREFIX/bin:$_LOCAL_PREFIX/sbin"
fi
-_path="$(_sanitize_path "${PATH}")"
-export PATH="${_PATH}${_path:+:}${_path}"
+_path="$(_sanitize_path "$PATH")"
+export PATH="$_PATH${_path:+:}$_path"
unset _sanitize_path _PREFIX _PKG_PREFIX _LOCAL_PREFIX _PATH _path
for arg; do
- case "${arg}" in
+ case "$arg" in
--nocolor|--nocolour|-C)
export EINFO_COLOR="NO"
;;
@@ -102,7 +101,7 @@ for arg; do
done
if [ -t 1 ] && yesno "${EINFO_COLOR:-YES}"; then
- if [ -z "${GOOD}" ]; then
+ if [ -z "$GOOD" ]; then
eval $(eval_ecolors)
fi
else
@@ -110,8 +109,8 @@ else
# the last ecmd
for _e in ebegin eend error errorn einfo einfon ewarn ewarnn ewend \
vebegin veend veinfo vewarn vewend; do
- eval "${_e}() { local _r; @PREFIX@/@LIB@/rc/bin/${_e} \"\$@\"; _r=$?; \
- export EINFO_LASTCMD=${_e}; return \$_r; }"
+ eval "$_e() { local _r; @PREFIX@/@LIB@/rc/bin/$_e \"\$@\"; _r=$?; \
+ export EINFO_LASTCMD=$_e; return \$_r; }"
done
unset _e
fi
diff --git a/sh/gendepends.sh.in b/sh/gendepends.sh.in
index 618c5f2d..f18e5284 100644
--- a/sh/gendepends.sh.in
+++ b/sh/gendepends.sh.in
@@ -1,31 +1,31 @@
#!@SHELL@
# Shell wrapper to list our dependencies
-# Copyright 2007-2008 Roy Marples <roy@marples.name>
+# Copyright 2007-2009 Roy Marples <roy@marples.name>
# All rights reserved. Released under the 2-clause BSD license.
. @SYSCONFDIR@/init.d/functions.sh
config() {
- [ -n "$*" ] && echo "${RC_SVCNAME} config $*" >&3
+ [ -n "$*" ] && echo "$RC_SVCNAME config $*" >&3
}
need() {
- [ -n "$*" ] && echo "${RC_SVCNAME} ineed $*" >&3
+ [ -n "$*" ] && echo "$RC_SVCNAME ineed $*" >&3
}
use() {
- [ -n "$*" ] && echo "${RC_SVCNAME} iuse $*" >&3
+ [ -n "$*" ] && echo "$RC_SVCNAME iuse $*" >&3
}
before() {
- [ -n "$*" ] && echo "${RC_SVCNAME} ibefore $*" >&3
+ [ -n "$*" ] && echo "$RC_SVCNAME ibefore $*" >&3
}
after() {
- [ -n "$*" ] && echo "${RC_SVCNAME} iafter $*" >&3
+ [ -n "$*" ] && echo "$RC_SVCNAME iafter $*" >&3
}
provide() {
- [ -n "$*" ] && echo "${RC_SVCNAME} iprovide $*" >&3
+ [ -n "$*" ] && echo "$RC_SVCNAME iprovide $*" >&3
}
keyword() {
- [ -n "$*" ] && echo "${RC_SVCNAME} keyword $*" >&3
+ [ -n "$*" ] && echo "$RC_SVCNAME keyword $*" >&3
}
depend() {
:
@@ -37,65 +37,66 @@ for _dir in \
@PKG_PREFIX@/etc/init.d \
@LOCAL_PREFIX@/etc/init.d
do
- [ -d "${_dir}" ] || continue
+ [ -d "$_dir" ] || continue
# Don't do the same dir twice
- for _d in ${_done_dirs}; do
- [ "${_d}" = "${_dir}" ] && continue 2
+ for _d in $_done_dirs; do
+ [ "$_d" = "$_dir" ] && continue 2
done
unset _d
- _done_dirs="${_done_dirs} ${_dir}"
+ _done_dirs="$_done_dirs $_dir"
- cd "${_dir}"
+ cd "$_dir"
for RC_SERVICE in *; do
- [ -x "${RC_SERVICE}" -a -f "${RC_SERVICE}" ] || continue
+ [ -x "$RC_SERVICE" -a -f "$RC_SERVICE" ] || continue
# Only generate dependencies for runscripts
- read one two three < "${RC_SERVICE}"
- [ "${one}" = "#!@PREFIX@/sbin/runscript" ] || \
- [ "${one}" = "#!" -a "${two}" = "@PREFIX@/sbin/runscript" ] || \
- continue
+ read one two three <"$RC_SERVICE"
+ [ "$one" = "#!@PREFIX@/sbin/runscript" ] || \
+ [ "$one" = "#!" -a "$two" = "@PREFIX@/sbin/runscript" ] || \
+ continue
unset one two three
export RC_SVCNAME=${RC_SERVICE##*/}
# Compat
- export SVCNAME=${RC_SVCNAME}
+ export SVCNAME=$RC_SVCNAME
(
# Save stdout in fd3, then remap it to stderr
exec 3>&1 1>&2
_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}"
+ 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/${RC_SVCNAME}" ]; then
- . "${_dir}/../conf.d/${RC_SVCNAME}"
+ if [ -e "$_dir/../conf.d/$RC_SVCNAME" ]; then
+ . "$_dir/../conf.d/$RC_SVCNAME"
fi
[ -e @SYSCONFDIR@/rc.conf ] && . @SYSCONFDIR@/rc.conf
- if . "${_dir}/${RC_SVCNAME}"; then
- echo "${RC_SVCNAME}" >&3
+ if . "$_dir/$RC_SVCNAME"; then
+ echo "$RC_SVCNAME" >&3
depend
- _rc_svcname=$(shell_var "${RC_SVCNAME}")
+ _rc_svcname=$(shell_var "$RC_SVCNAME")
# Add any user defined depends
for _deptype in config:CONFIG need:NEED use:USE \
after:AFTER before:BEFORE \
provide:PROVIDE keyword:KEYWORD; do
IFS=:
- set -- ${_deptype}
+ set -- $_deptype
unset IFS
- eval _depends=\$rc_${_rc_svcname}_$1
- [ -z "${_depends}" ] && eval _depends=\$rc_$1
- [ -z "${_depends}" ] && eval _depends=\$RC_${_rc_svcname}_$2
- [ -z "${_depends}" ] && eval _depends=\$RC_$2
+ eval _depends=\$rc_$_rc_svcname_$1
+ [ -z "$_depends" ] && eval _depends=\$rc_$1
+ [ -z "$_depends" ] && \
+ eval _depends=\$RC_$_rc_svcname_$2
+ [ -z "$_depends" ] && eval _depends=\$RC_$2
$1 ${_depends}
done
diff --git a/sh/ifwatchd-carrier.sh.in b/sh/ifwatchd-carrier.sh.in
index ec9c5abd..3b1dc449 100644
--- a/sh/ifwatchd-carrier.sh.in
+++ b/sh/ifwatchd-carrier.sh.in
@@ -2,4 +2,4 @@
# Wrapper for ifwatchd(8)
export IN_BACKGROUND=yes
-${RC_SERVICE} --quiet start
+$RC_SERVICE --quiet start
diff --git a/sh/ifwatchd-nocarrier.sh.in b/sh/ifwatchd-nocarrier.sh.in
index 3ba111cb..cedc275f 100644
--- a/sh/ifwatchd-nocarrier.sh.in
+++ b/sh/ifwatchd-nocarrier.sh.in
@@ -2,4 +2,4 @@
# Wrapper for ifwatchd(8)
export IN_BACKGROUND=yes
-${RC_SERVICE} --quiet stop
+$RC_SERVICE --quiet stop
diff --git a/sh/init-common-post.sh.in b/sh/init-common-post.sh.in
index 5c3af3a1..f9e3aa3e 100644
--- a/sh/init-common-post.sh.in
+++ b/sh/init-common-post.sh.in
@@ -4,11 +4,11 @@
# mount $RC_SVCDIR as something we can write to if it's not rw
# On vservers, / is always rw at this point, so we need to clean out
# the old service state data
-RC_SVCDIR=${RC_SVCDIR:-/@LIB@/rc/init.d}
+: ${RC_SVCDIR:=/@LIB@/rc/init.d}
case "$(rc --sys)" in
- OPENVZ|VSERVER) rm -rf "${RC_SVCDIR}"/*;;
- *) if mountinfo --quiet "${RC_SVCDIR}"; then
- rm -rf "${RC_SVCDIR}"/*
+ OPENVZ|VSERVER) rm -rf "$RC_SVCDIR"/*;;
+ *) if mountinfo --quiet "$RC_SVCDIR"; then
+ rm -rf "$RC_SVCDIR"/*
else
mount_svcdir
fi
@@ -16,9 +16,9 @@ case "$(rc --sys)" in
esac
retval=$?
-if [ -e "${RC_LIBDIR}"/cache/deptree ]; then
- cp -p "${RC_LIBDIR}"/cache/* "${RC_SVCDIR}" 2>/dev/null
+if [ -e "$RC_LIBDIR"/cache/deptree ]; then
+ cp -p "$RC_LIBDIR"/cache/* "$RC_SVCDIR" 2>/dev/null
fi
-echo "sysinit" > "${RC_SVCDIR}/softlevel"
-exit ${retval}
+echo sysinit >"$RC_SVCDIR"/softlevel
+exit $retval
diff --git a/sh/init.sh.BSD.in b/sh/init.sh.BSD.in
index 652a3de2..c3c6d516 100644
--- a/sh/init.sh.BSD.in
+++ b/sh/init.sh.BSD.in
@@ -1,5 +1,5 @@
#!@SHELL@
-# Copyright 2007-2008 Roy Marples <roy@marples.name>
+# Copyright 2007-2009 Roy Marples <roy@marples.name>
# All rights reserved. Released under the 2-clause BSD license.
# This basically mounts $svcdir as a ramdisk, but preserving its content
@@ -10,21 +10,23 @@
# FreeBSD-7 supports tmpfs now :)
mount_svcdir()
{
- if ! fstabinfo --mount "${RC_SVCDIR}"; then
- if ! mount -t tmpfs -o rw,noexec,nosuid none "${RC_SVCDIR}" 2>/dev/null; then
+ if ! fstabinfo --mount "$RC_SVCDIR"; then
+ if ! mount -t tmpfs -o rw,noexec,nosuid none \
+ "$RC_SVCDIR" 2>/dev/null
+ then
mdconfig -a -t malloc -s "${rc_svcsize:-1024}"k -u 0
newfs -b 4096 -i 1024 -n /dev/md0
- mount -o rw,noexec,nosuid /dev/md0 "${RC_SVCDIR}"
+ mount -o rw,noexec,nosuid /dev/md0 "$RC_SVCDIR"
fi
fi
}
-. "${RC_LIBDIR}"/sh/functions.sh
+. "$RC_LIBDIR"/sh/functions.sh
[ -r /etc/rc.conf ] && . /etc/rc.conf
# Disable devd until we need it
-if [ -z "${RC_SYS}" -a "${RC_UNAME}" = "FreeBSD" ]; then
+if [ -z "$RC_SYS" -a "$RC_UNAME" = "FreeBSD" ]; then
sysctl hw.bus.devctl_disable=1 >/dev/null
fi
-. "${RC_LIBDIR}"/sh/init-common-post.sh
+. "$RC_LIBDIR"/sh/init-common-post.sh
diff --git a/sh/init.sh.Linux.in b/sh/init.sh.Linux.in
index f38fe4e0..3fe03742 100644
--- a/sh/init.sh.Linux.in
+++ b/sh/init.sh.Linux.in
@@ -1,6 +1,6 @@
#!@SHELL@
# Copyright 1999-2007 Gentoo Foundation
-# Copyright 2007-2008 Roy Marples <roy@marples.name>
+# Copyright 2007-2009 Roy Marples <roy@marples.name>
# All rights reserved. Released under the 2-clause BSD license.
# This basically mounts $RC_SVCDIR as a ramdisk.
@@ -14,7 +14,7 @@ mount_svcdir()
if grep -Eq "[[:space:]]+tmpfs$" /proc/filesystems; then
fs="tmpfs"
- fsopts="${fsopts},mode=0755,size=${svcsize}k"
+ fsopts="$fsopts,mode=0755,size=${svcsize}k"
elif grep -Eq "[[:space:]]+ramfs$" /proc/filesystems; then
fs="ramfs"
# ramfs has no special options
@@ -22,8 +22,8 @@ mount_svcdir()
&& grep -Eq "[[:space:]]+ext2$" /proc/filesystems; then
devdir="/dev/ram0"
fs="ext2"
- dd if=/dev/zero of="${devdir}" bs=1k count="${svcsize}"
- mkfs -t "${fs}" -i 1024 -vm0 "${devdir}" "${svcsize}"
+ dd if=/dev/zero of="$devdir" bs=1k count="$svcsize"
+ mkfs -t "$fs" -i 1024 -vm0 "$devdir" "$svcsize"
else
echo
eerror "OpenRC requires tmpfs, ramfs or a ramdisk + ext2"
@@ -33,8 +33,8 @@ mount_svcdir()
fi
# If we have no entry in fstab for $RC_SVCDIR, provide our own
- if ! fstabinfo --mount "${RC_SVCDIR}"; then
- mount -n -t "${fs}" ${fsopts} "${devdir}" "${RC_SVCDIR}"
+ if ! fstabinfo --mount "$RC_SVCDIR"; then
+ mount -n -t "$fs" $fsopts "$devdir" "$RC_SVCDIR"
fi
}
@@ -50,7 +50,7 @@ mountproc=true
if [ -e /proc/uptime ]; then
up="$(cat /proc/uptime)"
sleep 1
- if [ "${up}" = "$(cat /proc/uptime)" ]; then
+ if [ "$up" = "$(cat /proc/uptime)" ]; then
eerror "You have cruft in /proc that should be deleted"
else
einfo "/proc is already mounted, skipping"
@@ -58,14 +58,14 @@ if [ -e /proc/uptime ]; then
fi
fi
-if ${mountproc}; then
+if $mountproc; then
procfs="proc"
- [ "${RC_UNAME}" = "GNU/kFreeBSD" ] && proc="linprocfs"
+ [ "$RC_UNAME" = "GNU/kFreeBSD" ] && proc="linprocfs"
ebegin "Mounting /proc"
if ! fstabinfo --mount /proc; then
- mount -n -t "${procfs}" -o noexec,nosuid,nodev proc /proc
+ mount -n -t "$procfs" -o noexec,nosuid,nodev proc /proc
fi
eend $?
fi
-. "${RC_LIBDIR}"/sh/init-common-post.sh
+. "$RC_LIBDIR"/sh/init-common-post.sh
diff --git a/sh/rc-functions.sh.in b/sh/rc-functions.sh.in
index c2927113..ebdb7687 100644
--- a/sh/rc-functions.sh.in
+++ b/sh/rc-functions.sh.in
@@ -1,25 +1,25 @@
# Copyright 2007 Gentoo Foundation
-# Copyright 2007-2008 Roy Marples <roy@marples.name>
+# Copyright 2007-2009 Roy Marples <roy@marples.name>
# All rights reserved. Released under the 2-clause BSD license.
has_addon()
{
- [ -e "${RC_LIBDIR}/addons/$1.sh" ] || [ -e /@LIB@/rcscripts/addons/"$1".sh ]
+ [ -e "$RC_LIBDIR/addons/$1.sh" -o -e /@LIB@/rcscripts/addons/"$1".sh ]
}
_addon_warn()
{
eindent
- ewarn "${RC_SVCNAME} uses addon code which is deprecated"
+ ewarn "$RC_SVCNAME uses addon code which is deprecated"
ewarn "and may not be available in the future."
eoutdent
}
import_addon()
{
- if [ -e "${RC_LIBDIR}/addons/$1.sh" ]; then
+ if [ -e "$RC_LIBDIR/addons/$1.sh" ]; then
_addon_warn
- . "${RC_LIBDIR}/addons/$1.sh"
+ . "$RC_LIBDIR/addons/$1.sh"
elif [ -e /@LIB@/rcscripts/addons/"$1".sh ]; then
_addon_warn
. /@LIB@/rcscripts/addons/"$1".sh
@@ -49,8 +49,8 @@ is_net_fs()
# Fall back on fs types
local t=$(mountinfo --fstype "$1")
- for x in ${net_fs_list}; do
- [ "${x}" = "${t}" ] && return 0
+ for x in $net_fs_list; do
+ [ "$x" = "$t" ] && return 0
done
return 1
}
@@ -64,17 +64,17 @@ is_union_fs()
get_bootparam()
{
local match="$1"
- [ -z "${match}" -o ! -r /proc/cmdline ] && return 1
+ [ -z "$match" -o ! -r /proc/cmdline ] && return 1
set -- $(cat /proc/cmdline)
while [ -n "$1" ]; do
- [ "$1" = "${match}" ] && return 0
+ [ "$1" = "$match" ] && return 0
case "$1" in
gentoo=*)
local params="${1##*=}"
local IFS=, x=
- for x in ${params}; do
- [ "${x}" = "${match}" ] && return 0
+ for x in $params; do
+ [ "$x" = "$match" ] && return 0
done
;;
esac
@@ -85,7 +85,7 @@ get_bootparam()
}
# Add our sbin to $PATH
-case "${PATH}" in
- "${RC_LIBDIR}"/sbin|"${RC_LIBDIR}"/sbin:*);;
- *) export PATH="${RC_LIBDIR}/sbin:${PATH}";;
+case "$PATH" in
+ "$RC_LIBDIR"/sbin|"$RC_LIBDIR"/sbin:*);;
+ *) export PATH="$RC_LIBDIR/sbin:$PATH";;
esac
diff --git a/sh/rc-mount.sh b/sh/rc-mount.sh
index 154fe802..8c952f94 100644
--- a/sh/rc-mount.sh
+++ b/sh/rc-mount.sh
@@ -1,4 +1,4 @@
-# Copyright 2007-2008 Roy Marples <roy@marples.name>
+# Copyright 2007-2009 Roy Marples <roy@marples.name>
# All rights reserved. Released under the 2-clause BSD license.
# Declare this here so that no formatting doesn't affect the embedded newline
@@ -7,13 +7,13 @@ __IFS="
# Handy function to handle all our unmounting needs
# mountinfo is a C program to actually find our mounts on our supported OS's
-# We rely on fuser being preset, so if it's not then we don't unmount anything.
+# We rely on fuser being present, so if it's not then don't unmount anything.
# This isn't a real issue for the BSD's, but it is for Linux.
do_unmount()
{
local cmd="$1" retval=0 retry= pids=-
local f_opts="-m -c" f_kill="-s " mnt=
- if [ "${RC_UNAME}" = "Linux" ]; then
+ if [ "$RC_UNAME" = "Linux" ]; then
f_opts="-m"
f_kill="-"
fi
@@ -25,26 +25,26 @@ do_unmount()
for mnt; do
# Unmounting a shared mount can unmount other mounts, so
# we need to check the mount is still valid
- mountinfo --quiet "${mnt}" || continue
+ mountinfo --quiet "$mnt" || continue
- case "${cmd}" in
+ case "$cmd" in
umount)
- ebegin "Unmounting ${mnt}"
+ ebegin "Unmounting $mnt"
;;
*)
- ebegin "Remounting ${mnt} read only"
+ ebegin "Remounting $mnt read only"
;;
esac
retry=3
- while ! LC_ALL=C ${cmd} "${mnt}" 2>/dev/null; do
+ while ! LC_ALL=C $cmd "$mnt" 2>/dev/null; do
if type fuser >/dev/null 2>&1; then
- pids="$(fuser ${f_opts} "${mnt}" 2>/dev/null)"
+ pids="$(fuser $f_opts "$mnt" 2>/dev/null)"
fi
- case " ${pids} " in
+ case " $pids " in
*" $$ "*)
eend 1 "failed because we are using" \
- "${mnt}"
+ "$mnt"
retry=0;;
" - ")
eend 1
@@ -54,21 +54,21 @@ do_unmount()
retry=0;;
*)
local sig="KILL"
- [ ${retry} -gt 0 ] && sig="TERM"
- fuser ${f_kill}${sig} -k ${f_opts} \
- "${mnt}" >/dev/null 2>&1
+ [ $retry -gt 0 ] && sig="TERM"
+ fuser $f_kill$sig -k $f_opts \
+ "$mnt" >/dev/null 2>&1
sleep 1
- retry=$((${retry} - 1))
- [ ${retry} -le 0 ] && eend 1
+ retry=$(($retry - 1))
+ [ $retry -le 0 ] && eend 1
;;
esac
- [ ${retry} -le 0 ] && break
+ [ $retry -le 0 ] && break
done
- if [ ${retry} -le 0 ]; then
+ if [ $retry -le 0 ]; then
retval=1
else
eend 0
fi
done
- return ${retval}
+ return $retval
}
diff --git a/sh/runscript.sh.in b/sh/runscript.sh.in
index c1930f26..8ed84d89 100644
--- a/sh/runscript.sh.in
+++ b/sh/runscript.sh.in
@@ -1,11 +1,11 @@
#!@SHELL@
# Shell wrapper for runscript
-# Copyright 2007-2008 Roy Marples <roy@marples.name>
+# Copyright 2007-2009 Roy Marples <roy@marples.name>
# All rights reserved. Released under the 2-clause BSD license.
. @SYSCONFDIR@/init.d/functions.sh
-. "${RC_LIBDIR}"/sh/rc-functions.sh
+. "$RC_LIBDIR"/sh/rc-functions.sh
# Support LiveCD foo
if [ -r /sbin/livecd-functions.sh ]; then
@@ -14,7 +14,7 @@ if [ -r /sbin/livecd-functions.sh ]; then
fi
if [ -z "$1" -o -z "$2" ]; then
- eerror "${RC_SVCNAME}: not enough arguments"
+ eerror "$RC_SVCNAME: not enough arguments"
exit 1
fi
@@ -23,24 +23,24 @@ export RC_SERVICE="$1"
shift
# Compat
-export SVCNAME=${RC_SVCNAME}
+export SVCNAME=$RC_SVCNAME
# Descript the init script to the user
describe()
{
- if [ -n "${description}" ]; then
- einfo "${description}"
+ if [ -n "$description" ]; then
+ einfo "$description"
else
- ewarn "No description for ${RC_SVCNAME}"
+ ewarn "No description for $RC_SVCNAME"
fi
local svc= desc=
- for svc in ${extra_commands:-${opts}} ${extra_started_commands}; do
- eval desc=\$description_${svc}
- if [ -n "${desc}" ]; then
- einfo "${HILITE}${svc}${NORMAL}: ${desc}"
+ for svc in ${extra_commands:-$opts} $extra_started_commands; do
+ eval desc=\$description_$svc
+ if [ -n "$desc" ]; then
+ einfo "$HILITE$svc$NORMAL: $desc"
else
- ewarn "${HILITE}${svc}${NORMAL}: no description"
+ ewarn "$HILITE$svc$NORMAL: no description"
fi
done
}
@@ -73,26 +73,26 @@ _status()
# Template start / stop / status functions
start()
{
- [ -n "${command}" ] || return 0
+ [ -n "$command" ] || return 0
local _background=
- ebegin "Starting ${name:-${RC_SVCNAME}}"
+ ebegin "Starting ${name:-$RC_SVCNAME}"
if yesno "${command_background}"; then
_background="--background --pidfile"
fi
- if yesno "${start_inactive}"; then
+ if yesno "$start_inactive"; then
local _inactive=false
service_inactive && _inactive=true
mark_service_inactive
fi
start-stop-daemon --start \
- --exec ${command} \
- ${procname:+--name} ${procname} \
- ${pidfile:+--pidfile} ${pidfile} \
- ${_background} ${start_stop_daemon_args} \
- -- ${command_args}
- eend $? "Failed to start ${RC_SVCNAME}" && return 0
- if yesno "${start_inactive}"; then
- if ! ${_inactive}; then
+ --exec $command \
+ ${procname:+--name} $procname \
+ ${pidfile:+--pidfile} $pidfile \
+ $_background $start_stop_daemon_args \
+ -- $command_args
+ eend $? "Failed to start $RC_SVCNAME" && return 0
+ if yesno "$start_inactive"; then
+ if ! $_inactive; then
mark_service_stopped
fi
fi
@@ -101,13 +101,13 @@ start()
stop()
{
- [ -n "${command}" -o -n "${procname}" -o -n "${pidfile}" ] || return 0
- ebegin "Stopping ${name:-${RC_SVCNAME}}"
+ [ -n "$command" -o -n "$procname" -o -n "$pidfile" ] || return 0
+ ebegin "Stopping ${name:-$RC_SVCNAME}"
start-stop-daemon --stop \
- ${command:+--exec} ${command} \
- ${procname:+--name} ${procname} \
- ${pidfile:+--pidfile} ${pidfile}
- eend $? "Failed to stop ${RC_SVCNAME}"
+ ${command:+--exec} $command \
+ ${procname:+--name} $procname \
+ ${pidfile:+--pidfile} $pidfile
+ eend $? "Failed to stop $RC_SVCNAME"
}
status()
@@ -115,25 +115,25 @@ status()
_status
}
-yesno ${RC_DEBUG} && set -x
+yesno $RC_DEBUG && set -x
_conf_d=${RC_SERVICE%/*}/../conf.d
# If we're net.eth0 or openvpn.work then load net or openvpn config
_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
- . "${_conf_d}//${_c}"
+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
+ . "$_conf_d/$_c"
fi
fi
unset _c
# Overlay with our specific config
-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}"
+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
@@ -141,22 +141,22 @@ unset _conf_d
[ -e @SYSCONFDIR@/rc.conf ] && . @SYSCONFDIR@/rc.conf
# Apply any ulimit defined
-[ -n "${rc_ulimit:-${RC_ULIMIT}}" ] && ulimit ${rc_ulimit:-${RC_ULIMIT}}
+[ -n "${rc_ulimit:-$RC_ULIMIT}" ] && ulimit ${rc_ulimit:-$RC_ULIMIT}
# Load our script
-. "${RC_SERVICE}"
+. "$RC_SERVICE"
-for _d in ${required_dirs}; do
- if [ ! -d ${_d} ]; then
- eerror "${RC_SVCNAME}: \`${_d}' is not a directory"
+for _d in $required_dirs; do
+ if [ ! -d $_d ]; then
+ eerror "$RC_SVCNAME: \`$_d' is not a directory"
exit 1
fi
done
unset _d
-for _f in ${required_files}; do
- if [ ! -r ${_f} ]; then
- eerror "${RC_SVCNAME}: \`${_f}' is not readable"
+for _f in $required_files; do
+ if [ ! -r $_f ]; then
+ eerror "$RC_SVCNAME: \`$_f' is not readable"
exit 1
fi
done
@@ -164,18 +164,20 @@ unset _f
while [ -n "$1" ]; do
# See if we have the required function and run it
- for _cmd in describe start stop status ${extra_commands:-${opts}} \
- ${extra_started_commands}; do
- if [ "${_cmd}" = "$1" ]; then
+ for _cmd in describe start stop status ${extra_commands:-$opts} \
+ $extra_started_commands
+ do
+ if [ "$_cmd" = "$1" ]; then
if [ "$(command -v "$1")" = "$1" ]; then
# If we're in the background, we may wish to
# fake some commands. We do this so we can
# "start" ourselves from inactive which then
- # triggers other services to start which depend
- # on us. A good example of this is openvpn.
- if yesno ${IN_BACKGROUND}; then
- for _cmd in ${in_background_fake}; do
- if [ "${_cmd}" = "$1" ]; then
+ # triggers other services to start which
+ # depend on us.
+ # A good example of this is openvpn.
+ if yesno $IN_BACKGROUND; then
+ for _cmd in $in_background_fake; do
+ if [ "$_cmd" = "$1" ]; then
shift
continue 3
fi
@@ -183,35 +185,38 @@ while [ -n "$1" ]; do
fi
# Check to see if we need to be started before
# we can run this command
- for _cmd in ${extra_started_commands}; do
- if [ "${_cmd}" = "$1" ]; then
+ for _cmd in $extra_started_commands; do
+ if [ "$_cmd" = "$1" ]; then
if ! service_started; then
- eerror "${RC_SVCNAME}: cannot \`$1' as it has not been started"
+ eerror "$RC_SVCNAME: cannot \`$1' as it has not been started"
exit 1
fi
fi
done
unset _cmd
- if [ "$(command -v "$1_pre")" = "$1_pre" ]; then
+ if [ "$(command -v "$1_pre")" = "$1_pre" ]
+ then
"$1"_pre || exit $?
fi
"$1" || exit $?
- if [ "$(command -v "$1_post")" = "$1_post" ]; then
+ if [ "$(command -v "$1_post")" = "$1_post" ]
+ then
"$1"_post || exit $?
fi
shift
continue 2
else
- if [ "${_cmd}" = "start" -o "${_cmd}" = "stop" ]; then
+ if [ "$_cmd" = "start" -o "$_cmd" = "stop" ]
+ then
shift
continue 2
else
- eerror "${RC_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 "${RC_SVCNAME}: unknown function \`$1'"
+ eerror "$RC_SVCNAME: unknown function \`$1'"
exit 1
done
diff --git a/sh/runtests.sh b/sh/runtests.sh
index 110266b3..7f7e7bdd 100755
--- a/sh/runtests.sh
+++ b/sh/runtests.sh
@@ -1,25 +1,25 @@
#!/bin/sh
-top_srcdir=${top_srcdir:-..}
-. ${top_srcdir}/test/setup_env.sh
+: ${top_srcdir:=..}
+. $top_srcdir/test/setup_env.sh
ret=0
tret=0
ebegin "Testing yesno()"
for f in yes YES Yes true TRUE True 1 ; do
- if ! yesno ${f} ; then
- tret=$((${tret} + 1))
- echo "!${f}!"
+ if ! yesno $f; then
+ tret=$(($tret + 1))
+ echo "!$f!"
fi
done
for f in no NO No false FALSE False 0 ; do
- if yesno ${f} ; then
- tret=$(({$tret} + 1))
- echo "!${f}!"
+ if yesno $f; then
+ tret=$(($tret + 1))
+ echo "!$f!"
fi
done
-eend ${tret}
-ret=$((${ret} + ${tret}))
+eend $tret
+ret=$(($ret + $tret))
-exit ${ret}
+exit $ret