]> git.ipfire.org Git - people/stevee/network.git/commitdiff
zone: add new command config list
authorJonatan Schlag <jonatan.schlag@ipfire.org>
Mon, 10 Jul 2017 13:33:47 +0000 (15:33 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 10 Jul 2017 18:58:36 +0000 (19:58 +0100)
With the new command
network <zone> config list
a user can get all configured configs with id and hook.

Fixes: #11407
Signed-off-by: Jonatan Schlag <jonatan.schlag@ipfire.org>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/functions/functions.zone

index d1212252cd5d17914c8c2f6d2fdd972096338212..ff6d945c6eb55e5dece74a5de3cfa75c5ad0aae1 100644 (file)
@@ -560,6 +560,9 @@ zone_config() {
                edit)
                        zone_config_edit "${zone}" "$@"
                        ;;
+               list)
+                       zone_config_list "${zone}" "$@"
+                       ;;
                *)
                        # Check is we get a valid id
                        # TODO This could be also a valid hid
@@ -613,6 +616,30 @@ zone_config_edit() {
        zone_config_cmd "edit" "$@"
 }
 
+zone_config_list() {
+       # This function list in an nice way all configs of a zone
+       local zone=${1}
+       assert isset zone
+
+       # Print a nice header
+       local format="%-3s %-20s"
+       print "${format}" "ID" "HOOK"
+
+       local config
+       local hook
+       local id
+
+       # Print for all config:
+       # id and hook
+       # TODO: Add hids here
+       for config in $(zone_configs_list "${zone}"); do
+               id=${config##*.}
+               hook=$(zone_config_get_hook "${zone}" "${config}")
+               assert isset hook
+               print "${format}" "${id}" "${hook}"
+       done
+}
+
 zone_config_show() {
        zone_config_cmd "show" "$@"
 }