Skip to content

Commit 302cb1e

Browse files
authored
Add --wait to iptables-restore (hestiacp#2100)
By default iptables exits with a failure with --wait=xxx xxx in seconds it wait for a max of xxx seconds before it returns an exit code. Adding a waiting time for about 10 seconds does not affect any normal boot setup after lock has been obtained it will continue with the restore.
1 parent 9b3d272 commit 302cb1e

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ All notable changes to this project will be documented in this file.
88

99
### Bugfixes
1010
- Improve the hostname check to prevent invalid hostnames or the use of an ip address (RFC1178).
11+
- Add small wait for /usr/bin/iptables-restore [Forum](https://forum.hestiacp.com/t/clean-install-arm64-does-not-start-after-reboot-v-start-service-iptables/4395/7)
1112

1213
## [1.4.12] - Service release
1314

bin/v-stop-firewall

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ if [ -d "/etc/sysconfig" ]; then
7676
fi
7777
else
7878
/sbin/iptables-save > /etc/iptables.rules
79+
iptablesversion=$(iptables --version | head -1 | awk '{print $2}' | cut -f -2 -d .);
7980
sd_unit="/lib/systemd/system/hestia-iptables.service"
8081
if [ ! -e "$sd_unit" ]; then
8182
echo "[Unit]" >> $sd_unit
@@ -89,7 +90,11 @@ else
8990
echo "Type=oneshot" >> $sd_unit
9091
echo "RemainAfterExit=yes" >> $sd_unit
9192
echo "ExecStartPre=-${HESTIA}/bin/v-update-firewall-ipset" >> $sd_unit
92-
echo "ExecStart=/sbin/iptables-restore /etc/iptables.rules" >> $sd_unit
93+
if [ "$iptablesversion" = "v1.6" ]; then
94+
echo "ExecStart=/sbin/iptables-restore /etc/iptables.rules" >> $sd_unit
95+
else
96+
echo "ExecStart=/sbin/iptables-restore --wait=10 /etc/iptables.rules" >> $sd_unit
97+
fi
9398
echo "" >> $sd_unit
9499
echo "[Install]" >> $sd_unit
95100
echo "WantedBy=multi-user.target" >> $sd_unit

bin/v-update-firewall

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ if [ -d "/etc/sysconfig" ]; then
185185
fi
186186
else
187187
/sbin/iptables-save > /etc/iptables.rules
188+
iptablesversion=$(iptables --version | head -1 | awk '{print $2}' | cut -f -2 -d .);
188189
sd_unit="/lib/systemd/system/hestia-iptables.service"
189190
if [ ! -e "$sd_unit" ]; then
190191
echo "[Unit]" >> $sd_unit
@@ -198,7 +199,11 @@ else
198199
echo "Type=oneshot" >> $sd_unit
199200
echo "RemainAfterExit=yes" >> $sd_unit
200201
echo "ExecStartPre=-${HESTIA}/bin/v-update-firewall-ipset" >> $sd_unit
201-
echo "ExecStart=/sbin/iptables-restore /etc/iptables.rules" >> $sd_unit
202+
if [ "$iptablesversion" = "v1.6" ]; then
203+
echo "ExecStart=/sbin/iptables-restore /etc/iptables.rules" >> $sd_unit
204+
else
205+
echo "ExecStart=/sbin/iptables-restore --wait=10 /etc/iptables.rules" >> $sd_unit
206+
fi
202207
echo "" >> $sd_unit
203208
echo "[Install]" >> $sd_unit
204209
echo "WantedBy=multi-user.target" >> $sd_unit

0 commit comments

Comments
 (0)