add more utility to script

This commit is contained in:
Marek Küthe 2023-01-31 08:07:59 +01:00
parent b536c01ffe
commit f2a4b63833
No known key found for this signature in database
GPG Key ID: 7E869146699108C7
1 changed files with 13 additions and 2 deletions

View File

@ -6,7 +6,11 @@ if ! jq --version &> /dev/null; then
fi
if [ ! "$1" ]; then
echo "Please specify format: [bird|babeld]"
echo "Please specify format: (bird|babeld) [options]"
echo ""
echo "Options:"
echo "babeld - [with-deny]"
echo "bird - [prefix-list]"
exit 1
fi
@ -21,9 +25,16 @@ for file in *.json; do
maxlen=64
fi
if [ "$1" == "bird" ]; then
filter="$filter$prefix{$prefixlen,$maxlen},\n"
ending="{$prefixlen,$maxlen}"
if [ "$2" == "prefix-list" ]; then
ending=+
fi
filter="$filter$prefix$ending,\n"
elif [ "$1" == "babeld" ]; then
filter="${filter}in ip $prefix le $maxlen allow\n"
if [ "$2" == "with-deny" ]; then
filter="${filter}in ip $prefix deny\n"
fi
fi
done
done