diff --git a/board/common/rootfs/usr/bin/show b/board/common/rootfs/usr/bin/show index af6517ec..82a5ee9c 100755 --- a/board/common/rootfs/usr/bin/show +++ b/board/common/rootfs/usr/bin/show @@ -70,6 +70,7 @@ options: -p Show plain output, no bells or whistles commands: + dhcp Show DHCP server port PORT Show port configuration and link information ports Show ports available for bridging vlans Show port groups in bridge @@ -88,6 +89,41 @@ commands: EOF } +is_dhcp_running() +{ + sysrepocfg -X -f json -m infix-dhcp-server | jq -r ' + ."infix-dhcp-server:dhcp-server".enabled as $global | + if ."infix-dhcp-server:dhcp-server".subnet? then + (."infix-dhcp-server:dhcp-server".subnet[] | + select(.enabled != false)) | + if $global != false and . then "true" else "false" end + else "false" end + ' 2>/dev/null | grep -q true +} + +dhcp() +{ + if ! is_dhcp_running; then + echo "DHCP server not enabled." + exit 0 + fi + + case $1 in + detail) + sysrepocfg -f json -X -d operational -m infix-dhcp-server | \ + jq -C . + ;; + stat*) + sysrepocfg -f json -X -d operational -m infix-dhcp-server | \ + /usr/libexec/statd/cli-pretty "show-dhcp-server" -s + ;; + *) + sysrepocfg -f json -X -d operational -m infix-dhcp-server | \ + /usr/libexec/statd/cli-pretty "show-dhcp-server" + ;; + esac +} + # Usage 1: show port eth0 # Usage 2: show port # Usage 3: show ports @@ -295,6 +331,9 @@ case $cmd in help) usage ;; + dhcp | dhcp-server) + dhcp $* + ;; port*) ports $* ;; diff --git a/src/klish-plugin-infix/xml/infix.xml b/src/klish-plugin-infix/xml/infix.xml index 451b5c85..d7cbd840 100644 --- a/src/klish-plugin-infix/xml/infix.xml +++ b/src/klish-plugin-infix/xml/infix.xml @@ -303,24 +303,15 @@ - - sysrepocfg -f json -X -d operational -m infix-dhcp-server | \ - /usr/libexec/statd/cli-pretty "show-dhcp-server" - + show dhcp - - sysrepocfg -f json -X -d operational -m infix-dhcp-server | \ - /usr/libexec/statd/cli-pretty "show-dhcp-server" -s - + show dhcp stat - - sysrepocfg -f json -X -d operational -m infix-dhcp-server | \ - jq -C . - + show dhcp detail