From 445ca0a9d60e57d1fd725ab448ee7a94f27fec6f Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Thu, 19 Sep 2024 05:18:25 +0200 Subject: [PATCH] board/common: restore 'show' script from 493be97 sync with present The intention is to provide a similar set of commands as klish admin-exec. However, instead of trying to make the Linux tools more accessible, we now make the Infix tooling more accessible. E.g., instead of "show ip route" mapping to "ip route show", we map it to: sysrepocfg -f json -X -d operational -x "/ietf-routing:routing/ribs" | \ /usr/libexec/statd/cli-pretty "show-routing-table" As a spin-off we alos get a much more readable infix.xml for klish: - Relocate logic to shell script wrapper 'show' - Introduce Cisco style "show ip route" and "show ipv6 route" Signed-off-by: Joachim Wiberg --- board/common/rootfs/usr/bin/show | 366 +++++++++++++++++++++++++++ src/klish-plugin-infix/xml/infix.xml | 30 ++- 2 files changed, 389 insertions(+), 7 deletions(-) create mode 100755 board/common/rootfs/usr/bin/show diff --git a/board/common/rootfs/usr/bin/show b/board/common/rootfs/usr/bin/show new file mode 100755 index 00000000..b83216a2 --- /dev/null +++ b/board/common/rootfs/usr/bin/show @@ -0,0 +1,366 @@ +#!/bin/sh +# Displays basic information about the system +# shellcheck disable=SC2048,SC2086 +. /etc/os-release + +bopt="-c" +opt="-br" +all="" +plain="" + +h1() +{ + STR="$*" + if [ -n "$plain" ]; then + echo "$STR" | tr '[:lower:]' '[:upper:]' + else + printf "\033[7m%-${COLUMNS}s\033[0m\n" "$STR" + fi +} + +h2() +{ + STR="$*" + if [ -n "$plain" ]; then + echo "$STR" + echo "$STR" | sed 's/./-/g' + else + printf "\033[1m%-${COLUMNS}s\033[0m\n" "$STR" + fi +} + +dm() +{ + if [ -n "$plain" ]; then + echo "${*}" + else + printf "\033[2m%s\033[0m\n" "$*" + fi +} + +ul() +{ + if [ -n "$plain" ]; then + printf "__%s__" "$*" + else + printf "\033[4%s\033[0m" "$*" + fi +} + +em() +{ + if [ -n "$plain" ]; then + printf "**%s**" "$*" + else + printf "\033[5m%s\033[0m" "$*" + fi +} + +usage() +{ + cat < - if [ "$KLISH_PARAM_ip" != "ipv4" ]; then - if [ "$KLISH_PARAM_ip" != "ipv6" ]; then - KLISH_PARAM_ip=ipv4 - fi - fi - sysrepocfg -f json -X -d operational -x "/ietf-routing:routing/ribs" | \ - /usr/libexec/statd/cli-pretty "show-routing-table" -i "$KLISH_PARAM_ip" + case $KLISH_PARAM_ip in + ipv4) + KLISH_PARAM_ip=ip + ;; + ipv6) + KLISH_PARAM_ip=ipv6 + ;; + esac + show -p $KLISH_PARAM_ip route @@ -383,6 +385,20 @@ mctl + + + show -p ip route + + + + + + ip -color -6 addr + + + + show -p ipv6 route +