-
-
Save fasaxc/05a80a48211500e4f2225011a131f92e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
failed=false | |
function felix () { | |
while true; do | |
echo -n a | |
iptables-restore --noflush --verbose <<EOF | |
*filter | |
:felix - | |
--append felix -m comment --comment "FELIX-A" | |
--delete dummy-chain 1 | |
COMMIT | |
EOF | |
echo -n A | |
echo -n b | |
iptables-restore --noflush --verbose <<EOF | |
*filter | |
:felix - | |
--append felix -m comment --comment "FELIX-B" | |
--append dummy-chain | |
COMMIT | |
EOF | |
echo -n B | |
if iptables-save | grep -q FELIX-A; then | |
echo | |
echo "FELIX-B update was clobbered" | |
failed=true | |
return 1 | |
fi | |
echo -n C | |
done | |
} | |
function kube () { | |
while ! ${failed}; do | |
echo -n k | |
iptables-restore --noflush --verbose 2>/dev/null <<EOF | |
*filter | |
:kube - | |
COMMIT | |
EOF | |
if [ $? == "0" ]; then | |
echo -n K | |
else | |
echo -n Z | |
fi | |
done | |
} | |
iptables-restore --noflush --verbose <<EOF | |
*filter | |
:dummy-chain - | |
-A dummy-chain | |
COMMIT | |
EOF | |
kube & | |
kube_pid=$! | |
felix; kill $kube_pid |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment