forked from hestiacp/hestiacp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathv-add-sys-firewall
More file actions
executable file
·57 lines (41 loc) · 1.49 KB
/
v-add-sys-firewall
File metadata and controls
executable file
·57 lines (41 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/bin/bash
# info: add system firewall
# options: NONE
#
# The script enables firewall
#----------------------------------------------------------#
# Variable&Function #
#----------------------------------------------------------#
# Includes
source $HESTIA/func/main.sh
source $HESTIA/conf/hestia.conf
#----------------------------------------------------------#
# Verifications #
#----------------------------------------------------------#
if [ "$FIREWALL_SYSTEM" = 'iptables' ]; then
exit
fi
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
# Adding firewall directory
mkdir -p $HESTIA/data/firewall/
# Adding default ruleset
if [ ! -e "$HESTIA/data/firewall/rules.conf" ]; then
cp $HESTIA/install/rhel/7/* $HESTIA/data/firewall/
fi
# Updating FIREWAL_SYSTEM value
if [ -z "$(grep FIREWALL_SYSTEM $HESTIA/conf/hestia.conf)" ]; then
echo "FIREWALL_SYSTEM='iptables'" >> $HESTIA/conf/hestia.conf
else
sed -i "s/FIREWALL_SYSTEM.*/FIREWALL_SYSTEM='iptables'/g" \
$HESTIA/conf/hestia.conf
fi
# Updating firewall rules
$BIN/v-update-firewall
#----------------------------------------------------------#
# Hestia #
#----------------------------------------------------------#
# Logging
log_event "$OK" "$ARGUMENTS"
exit