Skip to content

Commit 837e5f1

Browse files
committed
Self heal firewall links if missing
1 parent e6c29ad commit 837e5f1

File tree

7 files changed

+42
-0
lines changed

7 files changed

+42
-0
lines changed

bin/v-add-firewall-ban

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ iptables="/sbin/iptables"
2424

2525
# Includes
2626
source $HESTIA/func/main.sh
27+
source $HESTIA/func/firewall.sh
2728
source $HESTIA/conf/hestia.conf
2829

2930

@@ -43,6 +44,9 @@ check_hestia_demo_mode
4344
# Action #
4445
#----------------------------------------------------------#
4546

47+
# Self heal iptables links
48+
heal_iptables_links
49+
4650
# Checking server ip
4751
if [ -e "$HESTIA/data/ips/$ip" ] || [ "$ip" = '127.0.0.1' ]; then
4852
exit

bin/v-add-firewall-chain

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ fi
3232

3333
# Includes
3434
source $HESTIA/func/main.sh
35+
source $HESTIA/func/firewall.sh
3536
source $HESTIA/conf/hestia.conf
3637

3738

@@ -50,6 +51,9 @@ check_hestia_demo_mode
5051
# Action #
5152
#----------------------------------------------------------#
5253

54+
# Self heal iptables links
55+
heal_iptables_links
56+
5357
# Checking known chains
5458
case $chain in
5559
SSH) # Get ssh port by reading ssh config file.

bin/v-delete-firewall-ban

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ iptables="/sbin/iptables"
2424

2525
# Includes
2626
source $HESTIA/func/main.sh
27+
source $HESTIA/func/firewall.sh
2728
source $HESTIA/conf/hestia.conf
2829

2930

@@ -43,6 +44,9 @@ check_hestia_demo_mode
4344
# Action #
4445
#----------------------------------------------------------#
4546

47+
# Self heal iptables links
48+
heal_iptables_links
49+
4650
# Checking ip in banlist
4751
conf="$HESTIA/data/firewall/banlist.conf"
4852
check_ip=$(grep "IP='$ip' CHAIN='$chain'" $conf 2>/dev/null)

bin/v-delete-firewall-chain

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ iptables="/sbin/iptables"
2323

2424
# Includes
2525
source $HESTIA/func/main.sh
26+
source $HESTIA/func/firewall.sh
2627
source $HESTIA/conf/hestia.conf
2728

2829

@@ -42,6 +43,9 @@ check_hestia_demo_mode
4243
# Action #
4344
#----------------------------------------------------------#
4445

46+
# Self heal iptables links
47+
heal_iptables_links
48+
4549
# Deleting chain
4650
chains=$HESTIA/data/firewall/chains.conf
4751
banlist=$HESTIA/data/firewall/banlist.conf

bin/v-stop-firewall

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ modprobe="/sbin/modprobe"
1717
# Includes
1818
source /etc/profile.d/hestia.sh
1919
source $HESTIA/func/main.sh
20+
source $HESTIA/func/firewall.sh
2021
source $HESTIA/conf/hestia.conf
2122

2223

@@ -34,6 +35,9 @@ check_hestia_demo_mode
3435
# Action #
3536
#----------------------------------------------------------#
3637

38+
# Self heal iptables links
39+
heal_iptables_links
40+
3741
# Creating temporary file
3842
tmp=$(mktemp)
3943

bin/v-update-firewall

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ sysctl="/sbin/sysctl"
1818
# Includes
1919
source /etc/profile.d/hestia.sh
2020
source $HESTIA/func/main.sh
21+
source $HESTIA/func/firewall.sh
2122
source $HESTIA/conf/hestia.conf
2223

2324

@@ -32,6 +33,9 @@ is_system_enabled "$FIREWALL_SYSTEM" 'FIREWALL_SYSTEM'
3233
# Action #
3334
#----------------------------------------------------------#
3435

36+
# Self heal iptables links
37+
heal_iptables_links
38+
3539
# Checking local IPv4 rules
3640
rules="$HESTIA/data/firewall/rules.conf"
3741

func/firewall.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
2+
heal_iptables_links() {
3+
packages="iptables iptables-save iptables-restore"
4+
for package in $packages; do
5+
if [ ! -e "/sbin/${package}" ]; then
6+
if which ${package}; then
7+
ln -s "$(which ${package})" /sbin/${package}
8+
elif [ -e "/usr/sbin/${package}" ]; then
9+
ln -s /usr/sbin/${package} /sbin/${package}
10+
elif whereis -B /bin /sbin /usr/bin /usr/sbin -f -b ${package}; then
11+
autoiptables=$(whereis -B /bin /sbin /usr/bin /usr/sbin -f -b ${package} | cut -d '' -f 2)
12+
if [ -x "$autoiptables" ]; then
13+
ln -s "$autoiptables" /sbin/${package}
14+
fi
15+
fi
16+
fi
17+
done
18+
}

0 commit comments

Comments
 (0)