File: //snap/docker/current/bin/ip6tables
#!/usr/bin/env bash
# If kernel support is missing, automatically assume xtables
USE_NFTABLES="$(nft list ruleset > /dev/null 2> /dev/null && echo true || echo false)"
# Otherwise resolve the iptables symlink from the host and use
# xtables if it is pointing to xtables-legacy-multi or the
# pre-nftables xtables binary
if [ "$USE_NFTABLES" == "true" ]; then
if readlink -f /var/lib/snapd/hostfs/sbin/ip6tables 2>/dev/null | grep -q "xtables-legacy-multi$"; then
USE_NFTABLES=false
fi
if readlink -f /var/lib/snapd/hostfs/sbin/ip6tables 2>/dev/null | grep -q "xtables-multi$"; then
USE_NFTABLES=false
fi
# If it's not a symlink then it is pure a pure xtables implementation
if readlink -f /var/lib/snapd/hostfs/sbin/ip6tables 2>/dev/null | grep -q "^/var/lib/snapd/hostfs/sbin/ip6tables$"; then
USE_NFTABLES=false
fi
fi
if [ "$USE_NFTABLES" == "true" ]; then
BIN=xtables-nft-multi
else
BIN=xtables-legacy-multi
fi
exec "$BIN" ip6tables "$@"