]> git.ipfire.org Git - people/ms/network.git/commitdiff
Extend "network status"
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 21 Sep 2018 13:19:58 +0000 (15:19 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 21 Sep 2018 13:19:58 +0000 (15:19 +0200)
This now takes ports, devices and PHYs and prints the appropriate
status.

This is very handy and just a shortcut.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/network

index ae4016d68fc23030906d96c191631fbc25507f9b..d759700f3e3e405420d2136e381d29e56e47200c 100644 (file)
@@ -1108,11 +1108,40 @@ cli_status() {
        local log_disable_stdout=${LOG_DISABLE_STDOUT}
        LOG_DISABLE_STDOUT="true"
 
-       local zones=$(zones_get "$@")
+       local arguments=( $@ )
 
-       local zone
-       for zone in ${zones}; do
-               zone_status ${zone}
+       # Show all zones when no arguments are given
+       if ! isset arguments; then
+               local zone
+               for zone in $(zones_get_all); do
+                       zone_status "${zone}"
+               done
+
+               return ${EXIT_OK}
+       fi
+
+       local arg
+       for arg in ${arguments[@]}; do
+               # Is this a zone?
+               if zone_exists "${arg}"; then
+                       zone_status "${arg}"
+
+               # Is this a port?
+               elif port_exists "${arg}"; then
+                       port_status "${arg}"
+
+               # Is this a PHY?
+               elif phy_exists "${arg}"; then
+                       cli_device_status "${arg}"
+
+               # Is this a device?
+               elif device_exists "${arg}"; then
+                       cli_device_status "${arg}"
+
+               # Unknown argument
+               else
+                       error "Unknown argument: ${arg}"
+               fi
        done
 
        # Reset logging.