# Firewall Setup - Enable SSH
#

firewallsetup() {
SECFILE=/etc/slossec.conf
[ -f "$SECFILE" ] && source ${SECFILE} 
if [[ $firewall -eq 1 ]] ; then
    $DIALOG --backtitle "$BT" --title "Firewall" --infobox "Firewall Setup" $H1 $W1
    sleep $autoTO
    if ! rpm -q --quiet firewalld ; then
        yum -y install firewalld
        if [ $? -ne 0 ] ; then
            log "SLOSSecurity: Failed to install firewall pkg's"
            return
        fi 
    fi
    
    sleep .1
    systemctl restart firewalld 
    if [ $? -ne 0 ] ; then
        log "SLOSSecurity: Failed to start firewall service"
        return
    fi 
    /usr/bin/firewall-cmd --permanent --add-service=ssh 2>/dev/null
else
    log "SLOSSecurity: Firewall Setup not performed"
    return
fi

sed -i "s/firewall=1/firewall=0/g" $SECFILE 2>/dev/null
show "SLOSSecurity: Firewall Setup Completed"

}

firewallsetup
