From be3701c55807336b9145994e621680f384090cbf Mon Sep 17 00:00:00 2001 From: Evgeny Zinoviev Date: Thu, 23 Mar 2023 07:35:02 +0300 Subject: openwrt utils upd --- misc/openwrt/setup-routing.sh | 49 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 misc/openwrt/setup-routing.sh (limited to 'misc') diff --git a/misc/openwrt/setup-routing.sh b/misc/openwrt/setup-routing.sh new file mode 100644 index 0000000..97af514 --- /dev/null +++ b/misc/openwrt/setup-routing.sh @@ -0,0 +1,49 @@ +#!/bin/sh + +list_ipset() { + skip=1 + while read -r line; do + if [ "$line" = "Members:" ]; then skip=0; continue; fi; + [ "$skip" = "1" ] && continue + echo "$line" + done +} + +case "$1" in + dhcp-leases) + cat /tmp/dhcp.leases + ;; + + ipset-add) + ipset add "$2" "$3" + ;; + + ipset-del) + ipset del "$2" "$3" + ;; + +# ipset_list) +# ipset list "$2" | list_ipset +# ;; + + ipset-list-all) + shift + while [ -n "$1" ]; do + echo ">$1" + skip=1 + ipset list "$1" | list_ipset + shift + done + ;; + +# rule-show) +# ;; +# +# route-show) +# ;; + + *) + 2>&1 echo "error: invalid command" + exit 1 + ;; +esac \ No newline at end of file -- cgit v1.2.3