#!/bin/sh ############################################################################### # # # IPFire.org - A linux based firewall # # Copyright (C) 2007-2022 IPFire Team # # # # 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 . # # # ############################################################################### . /etc/sysconfig/rc . ${rc_functions} PATH=/usr/local/sbin:/usr/local/bin:/bin:/usr/bin:/sbin:/usr/sbin; export PATH eval $(/usr/local/bin/readhash /var/ipfire/suricata/settings) eval $(/usr/local/bin/readhash /var/ipfire/ethernet/settings) # Name of the firewall chains. IPS_INPUT_CHAIN="IPS_INPUT" IPS_FORWARD_CHAIN="IPS_FORWARD" IPS_OUTPUT_CHAIN="IPS_OUTPUT" # Optional options for the Netfilter queue. NFQ_OPTS="--queue-bypass " # Array containing the 4 possible network zones. network_zones=( red green blue orange ovpn ) # Array to store the network zones weather the IPS is enabled for. enabled_ips_zones=() # PID file of suricata. PID_FILE="/var/run/suricata.pid" # Function to get the amount of CPU cores of the system. function get_cpu_count { CPUCOUNT=0 # Loop through "/proc/cpuinfo" and count the amount of CPU cores. while read line; do [ "$line" ] && [ -z "${line%processor*}" ] && ((CPUCOUNT++)) done /dev/null 2>/dev/null evaluate_retval # Allow reading the pidfile. chmod 644 $PID_FILE # Flush the firewall chain flush_fw_chain # Generate firewall rules generate_fw_rules fi ;; stop) boot_mesg "Stopping Intrusion Detection System..." killproc -p $PID_FILE /var/run # Flush firewall chain. flush_fw_chain # Sometimes suricata not correct shutdown. So killall. killall -KILL /usr/bin/suricata 2>/dev/null # Remove suricata control socket. rm /var/run/suricata/* >/dev/null 2>/dev/null # Trash remain pid file if still exists. rm -f $PID_FILE >/dev/null 2>/dev/null # Don't report returncode of rm if suricata was not started exit 0 ;; status) statusproc /usr/bin/suricata ;; restart) $0 stop $0 start ;; reload) # Send SIGUSR2 to the suricata process to perform a reload # of the ruleset. kill -USR2 $(pidof suricata) # Flush the firewall chain. flush_fw_chain # Generate firewall rules. generate_fw_rules ;; *) echo "Usage: $0 {start|stop|restart|reload|status}" exit 1 ;; esac chmod 644 /var/log/suricata/* 2>/dev/null