From: Michael Prokop Date: Wed, 6 Jul 2011 23:01:14 +0000 (+0200) Subject: Support running scripts in bootoption "services" in foreground if they contain the... X-Git-Tag: v0.9.31~1 X-Git-Url: https://git.grml.org/?p=grml-autoconfig.git;a=commitdiff_plain;h=5a37523cc5cc18f932c3683e911fcad3c345baa4 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. --- 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 } # }}}