]> git.ipfire.org Git - ipfire-2.x.git/commitdiff
initscripts: Add switch to start processes in background
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 27 Jul 2021 08:59:00 +0000 (08:59 +0000)
committerArne Fitzenreiter <arne_f@ipfire.org>
Sun, 5 Sep 2021 17:39:14 +0000 (17:39 +0000)
Since systemd, many programs no longer behave like a well-behaved
daemon. To avoid any extra solutions, this patch adds a -b switch which
will start a program in the background and throw away any output.

The behaviour remains unchanged for any other programs.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Signed-off-by: Arne Fitzenreiter <arne_f@ipfire.org>
src/initscripts/system/functions

index d610a524d12a89a8a282c0f0eb0941c005685eb1..e44a2b4a1353ae716b9f209547a73a6c66d09b51 100644 (file)
@@ -436,6 +436,7 @@ getpids()
 #*******************************************************************************
 loadproc()
 {
+       local background=""
        local pidfile=""
        local forcestart=""
        local nicelevel=""
@@ -448,6 +449,10 @@ loadproc()
   while true
        do
                case "${1}" in
+                       -b)
+                               background="1"
+                               shift 1
+                               ;;
                        -f)
                                forcestart="1"
                                shift 1
@@ -506,8 +511,16 @@ loadproc()
                cmd="nice -n "${nicelevel}" ${cmd}"
        fi
 
-       ${cmd}
-       evaluate_retval # This is "Probably" not LSB compliant, but required to be compatible with older bootscripts
+       if [ -n "${background}" ]; then
+               (
+                       ${cmd} &>/dev/null
+               ) &
+               evaluate_retval
+       else
+               ${cmd}
+               evaluate_retval # This is "Probably" not LSB compliant, but required to be compatible with older bootscripts
+       fi
+
        return 0
 }