aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2007-11-28 13:08:25 +0000
committerRoy Marples <roy@marples.name>2007-11-28 13:08:25 +0000
commit8ea741d6994c66df1c2a3851ea1a806e8c87e249 (patch)
tree998ecde6d2911930e1ca59c5b1fa8e579db9cd7f
parent8df5860848485426bb1d08021d562049350bafeb (diff)
Support required_dirs and required_files. Allow services to mark inactive if using templates and fake commands if in background.
-rwxr-xr-xsh/runscript.sh32
1 files changed, 30 insertions, 2 deletions
diff --git a/sh/runscript.sh b/sh/runscript.sh
index 162efb28..44ebd812 100755
--- a/sh/runscript.sh
+++ b/sh/runscript.sh
@@ -87,9 +87,24 @@ fi
# Load our script
. $1
-
shift
+for _d in ${required_dirs}; do
+ if [ ! -d ${_d} ]; then
+ eerror "${SVCNAME}: \`${_d}' is not a directory"
+ exit 1
+ fi
+done
+unset _d
+
+for _f in ${required_files}; do
+ if [ ! -r ${_f} ]; then
+ eerror "${SVCNAME}: \`${_f}' is not readable"
+ exit 1
+ fi
+done
+unset _f
+
# If we have a default command then supply a default start function
if [ -n "${command}" ]; then
if ! type start >/dev/null 2>&1; then
@@ -100,6 +115,7 @@ if [ -n "${command}" ]; then
start_stop_daemon_args="${start_stop_daemon_args} --background --pidfile"
;;
esac
+ yesno "${start_inactive}" && mark_service_inactive "${SVCNAME}"
start-stop-daemon --start \
--exec ${command} \
${procname:+--name} ${procname} \
@@ -131,7 +147,19 @@ while [ -n "$1" ]; do
for _cmd in describe start stop ${extra_commands:-${opts}}; do
if [ "${_cmd}" = "$1" ]; then
if type "$1" >/dev/null 2>&1; then
- unset _cmd
+ # 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
+ shift
+ continue 3
+ fi
+ done
+ fi
+ unset _cmd
if type "$1"_pre >/dev/null 2>&1; then
"$1"_pre || exit $?
fi