-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathget_firewall.sh
More file actions
35 lines (33 loc) · 878 Bytes
/
get_firewall.sh
File metadata and controls
35 lines (33 loc) · 878 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# scriptlet:_common/cmd_exists.sh
##
# Get which firewall is enabled,
# or "none" if none located
function get_enabled_firewall() {
if [ "$(systemctl is-active firewalld)" == "active" ]; then
echo "firewalld"
elif [ "$(systemctl is-active ufw)" == "active" ]; then
echo "ufw"
elif [ "$(systemctl is-active iptables)" == "active" ]; then
echo "iptables"
else
echo "none"
fi
}
##
# Get which firewall is available on the local system,
# or "none" if none located
#
# CHANGELOG:
# 2025.12.15 - Use cmd_exists to fix regression bug
# 2025.04.10 - Switch from "systemctl list-unit-files" to "which" to support older systems
function get_available_firewall() {
if cmd_exists firewall-cmd; then
echo "firewalld"
elif cmd_exists ufw; then
echo "ufw"
elif systemctl list-unit-files iptables.service &>/dev/null; then
echo "iptables"
else
echo "none"
fi
}