| 1 |
#!/bin/bash |
| 2 |
|
| 3 |
tmpfile1=$(mktemp -p .) |
| 4 |
if [ ! -w "$tmpfile1" ] ; then |
| 5 |
# cwd might be readonly, mark as skip. |
| 6 |
echo "Failed to create tmp file" >&2 |
| 7 |
exit 77 |
| 8 |
fi |
| 9 |
|
| 10 |
cleanup() |
| 11 |
{ |
| 12 |
rm -f "$tmpfile1" "$tmpfile2" |
| 13 |
} |
| 14 |
|
| 15 |
trap cleanup EXIT |
| 16 |
|
| 17 |
set -e |
| 18 |
tmpfile2=$(mktemp -p .) |
| 19 |
|
| 20 |
RULESET1="add table x" |
| 21 |
RULESET2="include \"$tmpfile1\"" |
| 22 |
|
| 23 |
echo "$RULESET1" > $tmpfile1 |
| 24 |
echo "$RULESET2" > $tmpfile2 |
| 25 |
|
| 26 |
$NFT -f $tmpfile2 |
| 27 |
if [ $? -ne 0 ] ; then |
| 28 |
echo "E: unable to load good ruleset" >&2 |
| 29 |
exit 1 |
| 30 |
fi |