mirror of
https://github.com/vincentmli/bpfire.git
synced 2026-04-27 19:23:24 +02:00
The PID file does not get written when Suricata is not being started in daemon mode and therefore we need to pass it as a command line parameter. The initscript should not deal with the PID file when starting but needs it to terminate the process and to check the process status. The web UI can use the PID file again. Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
59 lines
2.1 KiB
Bash
59 lines
2.1 KiB
Bash
#!/bin/bash
|
|
###############################################################################
|
|
# #
|
|
# IPFire.org - A Linux-based Firewall #
|
|
# Copyright (C) 2024 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/>. #
|
|
# #
|
|
###############################################################################
|
|
|
|
PIDFILE="/var/run/suricata.pid"
|
|
|
|
main() {
|
|
local ret
|
|
|
|
# Suricata becomes unhappy if the PID file exists
|
|
unlink "${PIDFILE}" &>/dev/null
|
|
|
|
while :; do
|
|
# Launch suricata
|
|
/usr/bin/suricata --pidfile "${PIDFILE}" "$@" &>/dev/null
|
|
|
|
# Wait until suricata is done
|
|
ret=$?
|
|
|
|
case "${ret}" in
|
|
# If suricata has been killed by SIGKILL (e.g. by
|
|
# the OOM killer, or if it ran into a SEGV, we will
|
|
# restart the process.
|
|
137|139)
|
|
# Remove the PID file
|
|
unlink "${PIDFILE}" 2>/dev/null
|
|
|
|
sleep 1
|
|
continue
|
|
;;
|
|
|
|
*)
|
|
break
|
|
;;
|
|
esac
|
|
done
|
|
|
|
return ${ret}
|
|
}
|
|
|
|
main "$@" || exit $?
|