| 1 |
#!/bin/bash |
| 2 |
|
| 3 |
set -e |
| 4 |
|
| 5 |
tmpdir=$(mktemp -d) |
| 6 |
if [ ! -d $tmpdir ] ; then |
| 7 |
echo "Failed to create tmp directory" >&2 |
| 8 |
exit 0 |
| 9 |
fi |
| 10 |
|
| 11 |
tmpfile=$(mktemp) |
| 12 |
if [ ! -w $tmpfile ] ; then |
| 13 |
echo "Failed to create tmp file" >&2 |
| 14 |
exit 0 |
| 15 |
fi |
| 16 |
|
| 17 |
# cleanup if aborted |
| 18 |
trap "rm -rf $tmpdir $tmpfile" EXIT |
| 19 |
|
| 20 |
RULESET1="add table x" |
| 21 |
RULESET2="add table y" |
| 22 |
RULESET3="include \"$tmpdir/*\"" |
| 23 |
|
| 24 |
echo "$RULESET1" > $tmpdir/table_x |
| 25 |
echo "$RULESET2" > $tmpdir/table_y |
| 26 |
echo "$RULESET3" > $tmpfile |
| 27 |
|
| 28 |
$NFT -f $tmpfile |
| 29 |
|
| 30 |
if [ $? -ne 0 ] ; then |
| 31 |
echo "E: unable to load good ruleset" >&2 |
| 32 |
exit 1 |
| 33 |
fi |