File tree Expand file tree Collapse file tree 1 file changed +14
-4
lines changed
meta-balena-common/recipes-connectivity/networkmanager/balena-files Expand file tree Collapse file tree 1 file changed +14
-4
lines changed Original file line number Diff line number Diff line change 58
58
exit 0
59
59
fi
60
60
61
- # Safeguard, this should never happen
62
- # Exactly 0 or 1 rule should match, bail out if there are more & investigate
63
- if [ " $( echo " ${FW_RULE_ARGS} " | wc -l) " -gt 1 ]
61
+ # Sometimes on NetworkManager restart a new rule is added
62
+ # but the old one is not properly cleand up
63
+ # Remove the duplicates here as the rules are all the same
64
+ DUPS=0
65
+ while [ " $( echo " ${FW_RULE_ARGS} " | wc -l) " -gt 1 ]
66
+ do
67
+ DUPS=$(( "${DUPS} " + 1 ))
68
+ FIRST_FW_RULE_ARGS=" $( echo " ${FW_RULE_ARGS} " | head -n 1) "
69
+ ${IPTABLES} -D ${FIRST_FW_RULE_ARGS# -A }
70
+ FW_RULE_ARGS=$( ${IPTABLES} -S FORWARD | grep " sh-fw-${IFNAME} " | grep " ${FW_RULE_COMMENT} " )
71
+ done
72
+
73
+ if [ " ${DUPS} " -gt 0 ]
64
74
then
65
- fail " More than one rule matched when looking for '${FW_RULE_COMMENT} ', bailing out "
75
+ info " Removed ${DUPS} duplicate '${FW_RULE_COMMENT} ' rules "
66
76
fi
67
77
68
78
# If the rule is already last, this will do nothing
You can’t perform that action at this time.
0 commit comments