mirror of
https://github.com/serghey-rodin/vesta.git
synced 2025-08-19 21:04:06 -07:00
Firewall support enable/disable
This commit is contained in:
parent
b15b5e5cbd
commit
6626ba34bf
2 changed files with 105 additions and 0 deletions
57
bin/v-add-sys-firewall
Executable file
57
bin/v-add-sys-firewall
Executable file
|
@ -0,0 +1,57 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# info: add system firewall
|
||||||
|
# opions: 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/
|
||||||
|
|
||||||
|
# Adding default ruleset
|
||||||
|
if [ ! -e "$VESTA/data/firewall/rules.conf" ]; then
|
||||||
|
cp $VESTA/install/rhel/7/* $VESTA/data/firewall/
|
||||||
|
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
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Vesta #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
# Logging
|
||||||
|
log_event "$OK" "$EVENT"
|
||||||
|
|
||||||
|
exit
|
48
bin/v-delete-sys-firewall
Executable file
48
bin/v-delete-sys-firewall
Executable file
|
@ -0,0 +1,48 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# info: delete system firewall
|
||||||
|
# opions: NONE
|
||||||
|
#
|
||||||
|
# The script disables firewall support
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Variable&Function #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
# Includes
|
||||||
|
source $VESTA/func/main.sh
|
||||||
|
source $VESTA/conf/vesta.conf
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Verifications #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
if [ -z "$FIREWALL_SYSTEM" ]; then
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Action #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
# Stopping firewall
|
||||||
|
$BIN/v-stop-firewall
|
||||||
|
|
||||||
|
# Updating FIREWALL_SYSTEM value
|
||||||
|
if [ -z "$(grep FIREWALL_SYSTEM $VESTA/conf/vesta.conf)" ]; then
|
||||||
|
echo "FIREWALL_SYSTEM=''" >> $VESTA/conf/vesta.conf
|
||||||
|
else
|
||||||
|
sed -i "s/FIREWALL_SYSTEM=.*/FIREWALL_SYSTEM=''/g" $VESTA/conf/vesta.conf
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Vesta #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
# Logging
|
||||||
|
log_event "$OK" "$EVENT"
|
||||||
|
|
||||||
|
exit
|
Loading…
Add table
Add a link
Reference in a new issue