myvesta/bin/v-add-sys-firewall
2017-01-23 07:30:28 -05:00

64 lines
1.7 KiB
Bash
Executable File

#!/bin/bash
# info: add system firewall
# options: NONE
#
# The script enables firewall
#----------------------------------------------------------#
# Variable&Function #
#----------------------------------------------------------#
# Includes
source $VESTA/func/main.sh
source $VESTA/conf/vesta.conf
#----------------------------------------------------------#
# Verifications #
#----------------------------------------------------------#
if [ "$FIREWALL_SYSTEM" = 'iptables' ]; then
exit
fi
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
# Adding firewall directory
mkdir -p $VESTA/data/firewall/
mkdir -p $VESTA/data/firewallv6/
# Adding default ruleset
if [ ! -e "$VESTA/data/firewall/rules.conf" ]; then
cp $VESTA/install/rhel/7/firewall/* $VESTA/data/firewall/
fi
if [ ! -e "$VESTA/data/firewallv6/rules.conf" ]; then
cp $VESTA/install/rhel/7/firewallv6/* $VESTA/data/firewallv6/
fi
# Updating FIREWAL_SYSTEM value
if [ -z "$(grep FIREWALL_SYSTEM $VESTA/conf/vesta.conf)" ]; then
echo "FIREWALL_SYSTEM='iptables'" >> $VESTA/conf/vesta.conf
else
sed -i "s/FIREWALL_SYSTEM.*/FIREWALL_SYSTEM='iptables'/g" \
$VESTA/conf/vesta.conf
fi
# Updating firewall rules
$BIN/v-update-firewall
$BIN/v-update-firewall-ipv6
#----------------------------------------------------------#
# Vesta #
#----------------------------------------------------------#
# Logging
log_event "$OK" "$ARGUMENTS"
exit