From 919991eef3719666f3ddcc9bc5378cba5211a527 Mon Sep 17 00:00:00 2001 From: Lars Kruse Date: Wed, 18 Apr 2018 04:04:15 +0200 Subject: [PATCH] plugin ipset: fix shellcheck issues --- plugins/network/ipset | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/plugins/network/ipset b/plugins/network/ipset index ef6ba902..c7bb0a3a 100755 --- a/plugins/network/ipset +++ b/plugins/network/ipset @@ -46,25 +46,33 @@ GPLv2 =cut -[ "$1" = "autoconf" ] && { - [ -e /sbin/ipset -o -n "$(which ipset)" ] && echo 'yes' || echo 'no (ipset binary not present)' - exit 0 +get_ipset_list() { + ipset list -n } -[ "$1" = "config" ] && { + +if [ "$1" = "autoconf" ]; then + if [ -e /sbin/ipset ] || [ -n "$(which ipset)" ]; then + echo 'yes' + else + echo 'no (ipset binary not present)' + fi + exit 0 +fi + +if [ "$1" = "config" ]; then echo graph_title Netfilter IPSets echo graph_category network echo graph_vlabel Members echo graph_args --base 1000 --logarithmic --units=si -} - -ipset list -n | while read list; do - [ "$1" = "config" ] && { + get_ipset_list | while read -r list; do echo "$list.label $list" echo "$list.min 0" - } || { - echo "$list.value $(( $(ipset list "$list" | wc -l) - 7 ))" - } -done; + done + exit 0 +fi +get_ipset_list | while read -r list; do + echo "$list.value $(( $(ipset list "$list" | wc -l) - 7 ))" +done exit 0