From: Michael Tremer Date: Tue, 5 Jun 2012 14:43:53 +0000 (+0000) Subject: Add "network zone list-hooks" command. X-Git-Tag: 004~54 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=3871df73ffdec967a69b8ed024fa620a3256f7b9;p=network.git Add "network zone list-hooks" command. --- diff --git a/functions.cli b/functions.cli index a9d8be51..c034fcb5 100644 --- a/functions.cli +++ b/functions.cli @@ -252,6 +252,9 @@ function cli_zone() { remove) cli_zone_remove $@ ;; + list-hooks) + cli_list_hooks zone $@ + ;; ""|*) if [ -n "${action}" ]; then error "Unrecognized argument: '${action}'" @@ -265,6 +268,26 @@ function cli_zone() { fi } +function cli_list_hooks() { + local type=${1} + shift + + if cli_help_requested $@; then + cli_show_man network-zone + exit ${EXIT_OK} + fi + + local hook_dir=$(hook_dir ${type}) + local hook + + for hook in ${hook_dir}/*; do + hook=$(basename ${hook}) + if hook_exists ${type} ${hook}; then + echo "${hook}" + fi + done | sort -u +} + # Removes a zone either immediately, if it is currently down, # or adds a tag that the removal will be done when the zone # is brought down the next time. diff --git a/man/network-zone.8.in b/man/network-zone.8.in index 4703386f..75633c55 100644 --- a/man/network-zone.8.in +++ b/man/network-zone.8.in @@ -4,7 +4,9 @@ network-zone \- Network Configuration Control Program .SH SYNOPSIS -\fBnetwork [OPTIONS] zone create ...\fR +\fBnetwork [OPTIONS] zone [create|remove] ...\fR +.P +\fBnetwork [OPTIONS] zone list-hooks\fR .P \fBnetwork [OPTIONS] zone command ...\fR @@ -38,6 +40,12 @@ to be remove later, after it has been brought down. .RE .PP +\fBlist-hooks\fR +.RS 4 +Outputs a list of all possible hooks for the zones. +.RE +.PP + For all other commands, the name of the zone needs to be passed first: \fBnetwork zone command\fR.