Imported Upstream version 2.3
[ossec-hids.git] / src / init / fw-check.sh
1 #!/bin/sh
2
3
4 # Checking which firewall to use.
5 UNAME=`uname`
6 FILE="";
7 EXECUTE="$1";
8
9 if [ "X${UNAME}" = "XFreeBSD" ]; then
10     # Is ipfw enabled?
11     grep 'firewall_enable="YES"' /etc/rc.conf >/dev/null 2>&1
12     if [ $? = 0 ]; then
13         # Firewall is IPFW
14         FILE="ipfw.sh";
15         echo "IPFW";
16     fi    
17
18     # if pf enabled?
19     grep 'pf_enable="YES"' /etc/rc.conf >/dev/null 2>&1
20     if [ $? = 0 ]; then
21         # Firewall is PF
22         FILE="pf.sh";
23         echo "PF";
24     fi    
25
26 # Darwin
27 elif [ "X${UNAME}" = "Darwin" ]; then
28     echo "IPFW";
29     FILE="ipfw_mac.sh";
30         
31 elif [ "X${UNAME}" = "XOpenBSD" ]; then
32     if [ $? = 0 ]; then
33         # Firewall is PF
34         FILE="pf.sh";
35         echo "PF";
36     fi    
37 fi
38
39
40 # If file is set and execute flag is set
41 if [ ! "X$FILE" = "X" ]; then
42     if [ "X$EXECUTE" = "Xexecute" ]; then
43         cp -pr ../active-response/firewall-drop.sh ../active-response/firewalls/default-firewall-drop.sh
44         cp -pr ../active-response/firewalls/$FILE ../active-response/firewall-drop.sh
45     fi
46 fi    
47
48 exit 0;