2007-04-05 11:18:42 +00:00
|
|
|
#!/bin/sh
|
|
|
|
# Shell wrapper to list our dependencies
|
2007-11-14 15:22:04 +00:00
|
|
|
|
2008-01-11 15:31:10 +00:00
|
|
|
# Copyright 2007-2008 Roy Marples <roy@marples.name>
|
|
|
|
# All rights reserved. Released under the 2-clause BSD license.
|
2007-11-14 15:22:04 +00:00
|
|
|
|
2007-04-05 11:18:42 +00:00
|
|
|
. /etc/init.d/functions.sh
|
|
|
|
|
2007-08-15 14:49:41 +00:00
|
|
|
config() {
|
|
|
|
[ -n "$*" ] && echo "${SVCNAME} config $*" >&3
|
|
|
|
}
|
2007-04-05 11:18:42 +00:00
|
|
|
need() {
|
2007-07-22 11:27:26 +00:00
|
|
|
[ -n "$*" ] && echo "${SVCNAME} ineed $*" >&3
|
2007-04-05 11:18:42 +00:00
|
|
|
}
|
|
|
|
use() {
|
2007-07-22 11:27:26 +00:00
|
|
|
[ -n "$*" ] && echo "${SVCNAME} iuse $*" >&3
|
2007-04-05 11:18:42 +00:00
|
|
|
}
|
|
|
|
before() {
|
2007-07-22 11:27:26 +00:00
|
|
|
[ -n "$*" ] && echo "${SVCNAME} ibefore $*" >&3
|
2007-04-05 11:18:42 +00:00
|
|
|
}
|
|
|
|
after() {
|
2007-07-22 11:27:26 +00:00
|
|
|
[ -n "$*" ] && echo "${SVCNAME} iafter $*" >&3
|
2007-04-05 11:18:42 +00:00
|
|
|
}
|
|
|
|
provide() {
|
2007-07-22 11:27:26 +00:00
|
|
|
[ -n "$*" ] && echo "${SVCNAME} iprovide $*" >&3
|
2007-12-05 17:48:07 +00:00
|
|
|
}
|
|
|
|
keywords() {
|
|
|
|
[ -n "$*" ] && echo "${SVCNAME} keywords $*" >&3
|
|
|
|
}
|
2007-04-05 11:18:42 +00:00
|
|
|
depend() {
|
|
|
|
:
|
|
|
|
}
|
|
|
|
|
2007-12-14 12:24:16 +00:00
|
|
|
for _dir in /etc/init.d /usr/local/etc/init.d; do
|
|
|
|
[ -d "${_dir}" ] || continue
|
|
|
|
cd "${_dir}"
|
|
|
|
for SVCNAME in *; do
|
|
|
|
[ -x "${SVCNAME}" ] || continue
|
2007-08-31 16:21:19 +00:00
|
|
|
|
2007-12-14 12:24:16 +00:00
|
|
|
# Only generate dependencies for runscripts
|
|
|
|
read one two < "${SVCNAME}"
|
|
|
|
[ "${one}" = "#!/sbin/runscript" ] || continue
|
|
|
|
unset one two
|
2007-04-05 11:18:42 +00:00
|
|
|
|
2007-12-30 16:59:56 +00:00
|
|
|
export SVCNAME=${SVCNAME##*/}
|
2007-12-14 12:24:16 +00:00
|
|
|
(
|
|
|
|
# Save stdout in fd3, then remap it to stderr
|
|
|
|
exec 3>&1 1>&2
|
2007-07-22 10:45:56 +00:00
|
|
|
|
2007-12-14 12:24:16 +00:00
|
|
|
_rc_c=${SVCNAME%%.*}
|
|
|
|
if [ -n "${_rc_c}" -a "${_rc_c}" != "${SVCNAME}" ]; then
|
2008-01-11 12:13:46 +00:00
|
|
|
if [ -e "${_dir}/../conf.d/${_rc_c}" ]; then
|
|
|
|
. "${_dir}/../conf.d/${_rc_c}"
|
|
|
|
fi
|
2007-12-14 12:24:16 +00:00
|
|
|
fi
|
|
|
|
unset _rc_c
|
2007-05-03 08:08:59 +00:00
|
|
|
|
2008-01-11 12:13:46 +00:00
|
|
|
if [ -e "${_dir}/../conf.d/${SVCNAME}" ]; then
|
|
|
|
. "${_dir}/../conf.d/${SVCNAME}"
|
|
|
|
fi
|
2007-07-22 11:28:38 +00:00
|
|
|
|
2008-01-02 15:42:52 +00:00
|
|
|
[ -e /etc/rc.conf ] && . /etc/rc.conf
|
|
|
|
|
2007-12-14 12:24:16 +00:00
|
|
|
if . "${_dir}/${SVCNAME}"; then
|
|
|
|
echo "${SVCNAME}" >&3
|
|
|
|
depend
|
2007-04-05 11:18:42 +00:00
|
|
|
|
2007-12-14 12:24:16 +00:00
|
|
|
# Add any user defined depends
|
2008-01-02 15:42:52 +00:00
|
|
|
for _deptype in config need use after before provide keywords; do
|
|
|
|
eval _depends=\$rc_$(shell_var "${SVCNAME}")_${_deptype}
|
|
|
|
[ -z "${_depends}" ] && eval _depends=\$rc_${_deptype}
|
|
|
|
${_deptype} ${_depends}
|
|
|
|
done
|
2007-12-14 12:24:16 +00:00
|
|
|
fi
|
|
|
|
)
|
|
|
|
done
|
2007-04-05 11:18:42 +00:00
|
|
|
done
|