From 8ea741d6994c66df1c2a3851ea1a806e8c87e249 Mon Sep 17 00:00:00 2001 From: Roy Marples Date: Wed, 28 Nov 2007 13:08:25 +0000 Subject: Support required_dirs and required_files. Allow services to mark inactive if using templates and fake commands if in background. --- sh/runscript.sh | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) (limited to 'sh') 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 -- cgit v1.2.3