I am working on a worklet to report back in the Activity log and then take after if the firewall is enabled on some CentOS boxes. But for some reason I cannot get the echos to appear in the activity log. Below is what I have.
#!/bin/bash
if [[ `firewall-cmd --state` = running ]]
then
firewall_state=active
else
firewall_state=inactive
fi
echo "Firewall State: $firewall_state" 1>&2
if [[ `systemctl is-enabled firewalld` = enabled ]]
then
firewall_status=enabled
elif [[ `systemctl is-enabled firewalld` = masked ]]
then
firewall_status=masked
elif [[ `systemctl is-enabled firewalld` = disabled ]]
then
firewall_status=disabled
else
firewall_status=unknown
fi
echo "Firewall Status: $firewall_status" 1>&2
if [ "$firewall_state" = "active" ] || [ "firewall_status" = "enabled" ]
then
exit 1
else
exit 0