Commit bbafb86e authored by Brad Davidson's avatar Brad Davidson Committed by Brad Davidson

Don't use iptables-save/iptables-restore if it will corrupt rules

parent 9e13aad4
...@@ -999,6 +999,19 @@ openrc_start() { ...@@ -999,6 +999,19 @@ openrc_start() {
$SUDO ${FILE_K3S_SERVICE} restart $SUDO ${FILE_K3S_SERVICE} restart
} }
has_working_xtables() {
if command -v "$1-save" 1> /dev/null && command -v "$1-restore" 1> /dev/null; then
if $SUDO $1-save 2>/dev/null | grep -q '^-A CNI-HOSTPORT-MASQ -j MASQUERADE$'; then
warn "Host $1-save/$1-restore tools are incompatible with existing rules"
else
return 0
fi
else
info "Host $1-save/$1-restore tools not found"
fi
return 1
}
# --- startup systemd or openrc service --- # --- startup systemd or openrc service ---
service_enable_and_start() { service_enable_and_start() {
if [ -f "/proc/cgroups" ] && [ "$(grep memory /proc/cgroups | while read -r n n n enabled; do echo $enabled; done)" -eq 0 ]; if [ -f "/proc/cgroups" ] && [ "$(grep memory /proc/cgroups | while read -r n n n enabled; do echo $enabled; done)" -eq 0 ];
...@@ -1019,14 +1032,11 @@ service_enable_and_start() { ...@@ -1019,14 +1032,11 @@ service_enable_and_start() {
return return
fi fi
if command -v iptables-save 1> /dev/null && command -v iptables-restore 1> /dev/null for XTABLES in iptables ip6tables; do
then if has_working_xtables ${XTABLES}; then
$SUDO iptables-save | grep -v KUBE- | grep -iv flannel | $SUDO iptables-restore $SUDO ${XTABLES}-save 2>/dev/null | grep -v KUBE- | grep -iv flannel | $SUDO ${XTABLES}-restore
fi fi
if command -v ip6tables-save 1> /dev/null && command -v ip6tables-restore 1> /dev/null done
then
$SUDO ip6tables-save | grep -v KUBE- | grep -iv flannel | $SUDO ip6tables-restore
fi
[ "${HAS_SYSTEMD}" = true ] && systemd_start [ "${HAS_SYSTEMD}" = true ] && systemd_start
[ "${HAS_OPENRC}" = true ] && openrc_start [ "${HAS_OPENRC}" = true ] && openrc_start
......
ff8b7b4028299c878180c1288efa73205c54c7c3fbc2d313fcc666374526d221 install.sh 8c71108b5602b40ab6a9e60fe66403302b458046cb8afd1980d3c183d25278ac install.sh
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment