From: Jonatan Schlag Date: Wed, 16 Aug 2017 09:46:58 +0000 (+0200) Subject: ipsec-connection: add description feature X-Git-Tag: 010~251 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=dc5dcfaff69e75c384e6472e92e709e916102e09;p=network.git ipsec-connection: add description feature Signed-off-by: Jonatan Schlag Signed-off-by: Michael Tremer --- diff --git a/src/bash-completion/network b/src/bash-completion/network index 807f0039..71bf2452 100644 --- a/src/bash-completion/network +++ b/src/bash-completion/network @@ -413,7 +413,7 @@ _network_vpn_ipsec_connection_subcommands() { shift local words=( $@ ) - local commands="authentication color down inactivity-timeout local mode peer remote security-policy show up" + local commands="authentication color description down inactivity-timeout local mode peer remote security-policy show up" local cmd="$(_network_find_on_cmdline "${commands}")" if [[ -z "${cmd}" ]]; then COMPREPLY=( $(compgen -W "${commands}" -- "${cur}") ) @@ -429,6 +429,9 @@ _network_vpn_ipsec_connection_subcommands() { color) _network_color ${args} ;; + description) + _network_description ${args} + ;; local) _network_vpn_ipsec_connection_subcommands_local_remote ${connection} "local" ${args} ;; diff --git a/src/functions/functions.description b/src/functions/functions.description index 0db8ede8..728ec2ca 100644 --- a/src/functions/functions.description +++ b/src/functions/functions.description @@ -25,6 +25,9 @@ description_format_filename() { local name=${2} case ${type} in + ipsec-connection) + echo "${NETWORK_IPSEC_CONNS_DIR}/${name}/description" + ;; zone) echo "$(zone_dir ${name})/description" ;; diff --git a/src/functions/functions.ipsec b/src/functions/functions.ipsec index 73c7e873..6c2a0df8 100644 --- a/src/functions/functions.ipsec +++ b/src/functions/functions.ipsec @@ -86,6 +86,9 @@ cli_ipsec_connection() { color) color_cli "ipsec-connection" "${connection}" "$@" ;; + description) + description_cli "ipsec-connection" ${connection} $@ + ;; show) cli_ipsec_connection_show "${connection}" exit $? @@ -138,6 +141,13 @@ ipsec_connection_get_color() { color_read "ipsec-connection" ${name} } +ipsec_connection_get_description_title() { + assert [ $# -eq 1 ] + + local name=${1} + description_title_read $(description_format_filename "ipsec-connection" "${name}") +} + cli_ipsec_connection_show() { local connection="${1}" @@ -152,6 +162,7 @@ cli_ipsec_connection_show() { cli_space cli_print_fmt1 1 "Color" "$(cli_color_bar $(ipsec_connection_get_color ${connection}))" + cli_print_fmt1 1 "Description" "$(ipsec_connection_get_description_title ${connection})" cli_space # Peer