File tree Expand file tree Collapse file tree 4 files changed +18
-22
lines changed
Expand file tree Collapse file tree 4 files changed +18
-22
lines changed Original file line number Diff line number Diff line change 11#! /bin/bash
22# info: add system firewall
33# options: NONE
4- # labels:
4+ # labels: panel
55#
66# example: v-add-sys-firewall
77#
3030# Perform verification if read-only mode is enabled
3131check_hestia_demo_mode
3232
33+
3334# ----------------------------------------------------------#
3435# Action #
3536# ----------------------------------------------------------#
3637
37- # Adding firewall directory
38- mkdir -p $HESTIA /data/firewall/
39-
4038# Adding default ruleset
41- if [ ! -e " $HESTIA /data/firewall/rules.conf " ]; then
42- cp $HESTIA /install/rhel/7/ * $HESTIA /data/firewall /
39+ if [ -z " $( ls -A $ HESTIA /data/firewall 2> /dev/null ) " ]; then
40+ cp -rf $HESTIA_INSTALL_DIR /firewall $HESTIA /data/
4341fi
4442
4543# Updating FIREWAL_SYSTEM value
46- if [ -z " $( grep FIREWALL_SYSTEM $HESTIA /conf/hestia.conf) " ]; then
47- echo " FIREWALL_SYSTEM='iptables'" >> $HESTIA /conf/hestia.conf
48- else
49- sed -i " s/FIREWALL_SYSTEM.*/FIREWALL_SYSTEM='iptables'/g" \
50- $HESTIA /conf/hestia.conf
51- fi
44+ $BIN /v-change-sys-config-value " FIREWALL_SYSTEM" " iptables"
5245
5346# Updating firewall rules
5447$BIN /v-update-firewall
@@ -59,6 +52,7 @@ $BIN/v-update-firewall
5952# ----------------------------------------------------------#
6053
6154# Logging
55+ $BIN /v-log-action " system" " Info" " Firewall" " System firewall enabled."
6256log_event " $OK " " $ARGUMENTS "
6357
6458exit
Original file line number Diff line number Diff line change @@ -35,23 +35,19 @@ check_hestia_demo_mode
3535# Action #
3636# ----------------------------------------------------------#
3737
38+ # Updating FIREWALL_SYSTEM value
39+ $BIN /v-change-sys-config-value " FIREWALL_SYSTEM" " "
40+
3841# Stopping firewall
3942$BIN /v-stop-firewall
4043
41- # Updating FIREWALL_SYSTEM value
42- if [ -z " $( grep FIREWALL_SYSTEM $HESTIA /conf/hestia.conf) " ]; then
43- echo " FIREWALL_SYSTEM=''" >> $HESTIA /conf/hestia.conf
44- else
45- sed -i " s/FIREWALL_SYSTEM=.*/FIREWALL_SYSTEM=''/g" $HESTIA /conf/hestia.conf
46- fi
47-
4844
4945# ----------------------------------------------------------#
5046# Hestia #
5147# ----------------------------------------------------------#
5248
5349# Logging
54- $BIN /v-log-action " system" " Error " " Firewall" " System firewall has been disabled."
50+ $BIN /v-log-action " system" " Warning " " Firewall" " System firewall disabled."
5551log_event " $OK " " $ARGUMENTS "
5652
5753exit
Original file line number Diff line number Diff line change @@ -76,7 +76,7 @@ if [ -d "/etc/sysconfig" ]; then
7676 fi
7777else
7878 /sbin/iptables-save > /etc/iptables.rules
79- iptablesversion=$( iptables --version | head -1 | awk ' {print $2}' | cut -f -2 -d .) ;
79+ iptablesversion=$( iptables --version | head -1 | awk ' {print $2}' | cut -f -2 -d .) ;
8080 sd_unit=" /lib/systemd/system/hestia-iptables.service"
8181 if [ ! -e " $sd_unit " ]; then
8282 echo " [Unit]" >> $sd_unit
9898 echo " " >> $sd_unit
9999 echo " [Install]" >> $sd_unit
100100 echo " WantedBy=multi-user.target" >> $sd_unit
101+ systemctl daemon-reload
101102 fi
102103 systemctl is-enabled hestia-iptables > /dev/null 2>&1 && systemctl disable hestia-iptables > /dev/null 2>&1
104+ if [ -z " $FIREWALL_SYSTEM " ]; then
105+ rm -f $sd_unit
106+ systemctl daemon-reload
107+ fi
103108fi
104109
105110
Original file line number Diff line number Diff line change @@ -185,7 +185,7 @@ if [ -d "/etc/sysconfig" ]; then
185185 fi
186186else
187187 /sbin/iptables-save > /etc/iptables.rules
188- iptablesversion=$( iptables --version | head -1 | awk ' {print $2}' | cut -f -2 -d .) ;
188+ iptablesversion=$( iptables --version | head -1 | awk ' {print $2}' | cut -f -2 -d .) ;
189189 sd_unit=" /lib/systemd/system/hestia-iptables.service"
190190 if [ ! -e " $sd_unit " ]; then
191191 echo " [Unit]" >> $sd_unit
207207 echo " " >> $sd_unit
208208 echo " [Install]" >> $sd_unit
209209 echo " WantedBy=multi-user.target" >> $sd_unit
210+ systemctl daemon-reload
210211 fi
211212 systemctl is-enabled hestia-iptables > /dev/null 2>&1 || systemctl enable hestia-iptables > /dev/null 2>&1
212213fi
You can’t perform that action at this time.
0 commit comments