From 5a37523cc5cc18f932c3683e911fcad3c345baa4 Mon Sep 17 00:00:00 2001 From: Michael Prokop Date: Thu, 7 Jul 2011 01:01:14 +0200 Subject: [PATCH] Support running scripts in bootoption "services" in foreground if they contain the string DO_NO_RUN_IN_BACKGROUND. If a script configures the system and has to make sure it's in a consistent state the (custom) init script shouldn't run as background job but should be able to block the boot process until it's in a reliable state. Actually we might also want to provide a more generic solution as well, but until we come up with a decent way this non-intrusive solution solves the problem at least for custom init scripts. --- autoconfig.functions | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/autoconfig.functions b/autoconfig.functions index 30f476c..04f8088 100755 --- a/autoconfig.functions +++ b/autoconfig.functions @@ -1439,11 +1439,18 @@ config_services(){ SERVICE="$(getbootparam 'services' 2>>$DEBUG)" SERVICELIST=$(echo "$SERVICE" | sed 's/,/\\n/g') SERVICENL=$(echo "$SERVICE" | sed 's/,/ /g') - einfo "Starting service(s) ${SERVICENL} in background." for service in $(echo -e $SERVICELIST) ; do - /etc/init.d/${service} start >>$DEBUG & + # support running (custom) init scripts in non-blocking mode + # if they contain the keyword "DO_NO_RUN_IN_BACKGROUND". + if grep -q 'DO_NO_RUN_IN_BACKGROUND' "/etc/init.d/${service}" 2>>$DEBUG ; then + einfo "Starting service ${service}." + /etc/init.d/${service} start >>$DEBUG + else + einfo "Starting service ${service} in background." + /etc/init.d/${service} start >>$DEBUG & + fi done - [ "$?" == "0" ] ; eend $? + eend $? fi } # }}} -- 2.1.4