Skip to content

Commit 6626ba3

Browse files
committed
Firewall support enable/disable
1 parent b15b5e5 commit 6626ba3

File tree

2 files changed

+105
-0
lines changed

2 files changed

+105
-0
lines changed

bin/v-add-sys-firewall

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#!/bin/bash
2+
# info: add system firewall
3+
# opions: NONE
4+
#
5+
# The script enables firewall
6+
7+
8+
#----------------------------------------------------------#
9+
# Variable&Function #
10+
#----------------------------------------------------------#
11+
12+
# Includes
13+
source $VESTA/func/main.sh
14+
source $VESTA/conf/vesta.conf
15+
16+
17+
#----------------------------------------------------------#
18+
# Verifications #
19+
#----------------------------------------------------------#
20+
21+
if [ "$FIREWALL_SYSTEM" = 'iptables' ]; then
22+
exit
23+
fi
24+
25+
26+
#----------------------------------------------------------#
27+
# Action #
28+
#----------------------------------------------------------#
29+
30+
# Adding firewall directory
31+
mkdir -p $VESTA/data/firewall/
32+
33+
# Adding default ruleset
34+
if [ ! -e "$VESTA/data/firewall/rules.conf" ]; then
35+
cp $VESTA/install/rhel/7/* $VESTA/data/firewall/
36+
fi
37+
38+
# Updating FIREWAL_SYSTEM value
39+
if [ -z "$(grep FIREWALL_SYSTEM $VESTA/conf/vesta.conf)" ]; then
40+
echo "FIREWALL_SYSTEM='iptables'" >> $VESTA/conf/vesta.conf
41+
else
42+
sed -i "s/FIREWALL_SYSTEM.*/FIREWALL_SYSTEM='iptables'/g" \
43+
$VESTA/conf/vesta.conf
44+
fi
45+
46+
# Updating firewall rules
47+
$BIN/v-update-firewall
48+
49+
50+
#----------------------------------------------------------#
51+
# Vesta #
52+
#----------------------------------------------------------#
53+
54+
# Logging
55+
log_event "$OK" "$EVENT"
56+
57+
exit

bin/v-delete-sys-firewall

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/bin/bash
2+
# info: delete system firewall
3+
# opions: NONE
4+
#
5+
# The script disables firewall support
6+
7+
8+
#----------------------------------------------------------#
9+
# Variable&Function #
10+
#----------------------------------------------------------#
11+
12+
# Includes
13+
source $VESTA/func/main.sh
14+
source $VESTA/conf/vesta.conf
15+
16+
17+
#----------------------------------------------------------#
18+
# Verifications #
19+
#----------------------------------------------------------#
20+
21+
if [ -z "$FIREWALL_SYSTEM" ]; then
22+
exit
23+
fi
24+
25+
26+
#----------------------------------------------------------#
27+
# Action #
28+
#----------------------------------------------------------#
29+
30+
# Stopping firewall
31+
$BIN/v-stop-firewall
32+
33+
# Updating FIREWALL_SYSTEM value
34+
if [ -z "$(grep FIREWALL_SYSTEM $VESTA/conf/vesta.conf)" ]; then
35+
echo "FIREWALL_SYSTEM=''" >> $VESTA/conf/vesta.conf
36+
else
37+
sed -i "s/FIREWALL_SYSTEM=.*/FIREWALL_SYSTEM=''/g" $VESTA/conf/vesta.conf
38+
fi
39+
40+
41+
#----------------------------------------------------------#
42+
# Vesta #
43+
#----------------------------------------------------------#
44+
45+
# Logging
46+
log_event "$OK" "$EVENT"
47+
48+
exit

0 commit comments

Comments
 (0)