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