Support running scripts in bootoption "services" in foreground if they contain the...
authorMichael Prokop <mika@grml.org>
Wed, 6 Jul 2011 23:01:14 +0000 (01:01 +0200)
committerMichael Prokop <mika@grml.org>
Wed, 6 Jul 2011 23:03:45 +0000 (01:03 +0200)
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

index 30f476c..04f8088 100755 (executable)
@@ -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
 }
 # }}}