I'm in the process to enable the firewall on a VM. Initially the firewall is in a masked state. I use two functions
function status_firewall() {
RET_VAL=" "
STATUS=$(systemctl status firewalld)
MASKED=$(grep -e "masked" <<< $STATUS)
M_RET=$?
DEAD=$(grep -e "dead" <<< $STATUS)
D_RET=$?
logging "M_RET and D_RET: $M_RET, $D_RET"
if [ "${M_RET}" -eq "0" ]; then
RET_VAL=1
elif [ "${D_RET}" -eq "0" ]; then
RET_VAL=2
else
RET_VAL=0
fi
echo ${RET_VAL}
}
Run Code Online (Sandbox Code Playgroud)
echo statement prints value "1" if firewall is masked …