]> git.ipfire.org Git - ipfire-2.x.git/blobdiff - src/initscripts/system/functions
suricata: Change midstream policy to "pass-flow"
[ipfire-2.x.git] / src / initscripts / system / functions
index 31b30e037f40c1b8b7d922bcc5ae35a190024ba9..5a26aef45f843b55b95e628dbc93111a412b425f 100644 (file)
@@ -1,17 +1,23 @@
 #!/bin/sh
-########################################################################
-# Begin $rc_base/init.d/functions
-#
-# Description : Run Level Control Functions
-#
-# Authors     : Gerard Beekmans - gerard@linuxfromscratch.org
-#
-# Version     : 00.00
-#
-# Notes       : With code based on Matthias Benkmann's simpleinit-msb
-#              http://winterdrache.de/linux/newboot/index.html
-#
-########################################################################
+###############################################################################
+#                                                                             #
+# IPFire.org - A linux based firewall                                         #
+# Copyright (C) 2007-2022  IPFire Team  <info@ipfire.org>                     #
+#                                                                             #
+# This program is free software: you can redistribute it and/or modify        #
+# it under the terms of the GNU General Public License as published by        #
+# the Free Software Foundation, either version 3 of the License, or           #
+# (at your option) any later version.                                         #
+#                                                                             #
+# This program is distributed in the hope that it will be useful,             #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of              #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               #
+# GNU General Public License for more details.                                #
+#                                                                             #
+# You should have received a copy of the GNU General Public License           #
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.       #
+#                                                                             #
+###############################################################################
 
 ## Environmental setup
 # Setup default values for environment
@@ -401,7 +407,7 @@ pidofproc()
 # This will ensure compatibility with previous LFS Bootscripts
 getpids()
 {
-       if [ -z "${PIDFILE}" ]; then
+       if [ -n "${PIDFILE}" ]; then
                pidofproc -s -p "${PIDFILE}" $@
        else
                pidofproc -s $@
@@ -436,9 +442,11 @@ getpids()
 #*******************************************************************************
 loadproc()
 {
+       local background=""
        local pidfile=""
        local forcestart=""
        local nicelevel=""
+       local pid
 
 # This will ensure compatibility with previous LFS Bootscripts
        if [ -n "${PIDFILE}" ]; then
@@ -448,6 +456,10 @@ loadproc()
   while true
        do
                case "${1}" in
+                       -b)
+                               background="1"
+                               shift 1
+                               ;;
                        -f)
                                forcestart="1"
                                shift 1
@@ -506,8 +518,23 @@ 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
+               ) &
+               pid="$!"
+               evaluate_retval
+       else
+               ${cmd}
+               pid="$!"
+               evaluate_retval # This is "Probably" not LSB compliant, but required to be compatible with older bootscripts
+       fi
+
+       # Write the pidfile
+       if [ -n "${pid}" -a -n "${pidfile}" ]; then
+               echo "${pid}" > "${pidfile}"
+       fi
+
        return 0
 }
 
@@ -797,6 +824,9 @@ running_on_ec2() {
        if [ -r "/sys/devices/virtual/dmi/id/product_uuid" ]; then
                uuid=$(</sys/devices/virtual/dmi/id/product_uuid)
 
+               # Convert the UUID as uppercase
+               uuid="${uuid^^}"
+
                [ "${uuid:0:3}" = "EC2" ] && return 0
        fi
 
@@ -853,5 +883,3 @@ running_on_oci() {
        # We are not running on OCI
        return 1
 }
-
-# End $rc_base/init.d/functions