From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jonatan Schlag <jonatan.schlag@ipfire.org> To: network@lists.ipfire.org Subject: [PATCH 2/2] ipsec-connection: add description feature Date: Wed, 16 Aug 2017 11:46:58 +0200 Message-ID: <1502876818-12274-2-git-send-email-jonatan.schlag@ipfire.org> In-Reply-To: <1502876818-12274-1-git-send-email-jonatan.schlag@ipfire.org> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============2794310499846353227==" List-Id: <network.lists.ipfire.org> --===============2794310499846353227== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Signed-off-by: Jonatan Schlag <jonatan.schlag(a)ipfire.org> --- src/bash-completion/network | 5 ++++- src/functions/functions.description | 3 +++ src/functions/functions.ipsec | 11 +++++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/bash-completion/network b/src/bash-completion/network index a25e43b..1f89e40 100644 --- a/src/bash-completion/network +++ b/src/bash-completion/network @@ -413,7 +413,7 @@ _network_vpn_ipsec_connection_subcommands() { shift local words=3D( $@ ) =20 - local commands=3D"authentication color down inactivity-timeout local mode p= eer remote security-policy show up" + local commands=3D"authentication color description down inactivity-timeout = local mode peer remote security-policy show up" local cmd=3D"$(_network_find_on_cmdline "${commands}")" if [[ -z "${cmd}" ]]; then COMPREPLY=3D( $(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} "loc= al" ${args} ;; diff --git a/src/functions/functions.description b/src/functions/functions.de= scription index 0db8ede..728ec2c 100644 --- a/src/functions/functions.description +++ b/src/functions/functions.description @@ -25,6 +25,9 @@ description_format_filename() { local name=3D${2} =20 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 6a91d39..e455e05 100644 --- a/src/functions/functions.ipsec +++ b/src/functions/functions.ipsec @@ -91,6 +91,9 @@ cli_ipsec_connection() { color) color_cli "ipsec-connection" "${connection}" "$@" ;; + description) + description_cli "ipsec-connection" ${connection} $@ + ;; show) cli_ipsec_connection_show "${connection}" exit $? @@ -184,6 +187,13 @@ ipsec_connection_get_color() { color_read "ipsec-connection" ${name} } =20 +ipsec_connection_get_description_title() { + assert [ $# -eq 1 ] + + local name=3D${1} + description_title_read $(description_format_filename "ipsec-connection" "${= name}") +} + cli_ipsec_connection_show() { local connection=3D"${1}" =20 @@ -198,6 +208,7 @@ cli_ipsec_connection_show() { cli_space =20 cli_print_fmt1 1 "Color" "$(cli_color_bar $(ipsec_connection_get_color ${co= nnection}))" + cli_print_fmt1 1 "Description" "$(ipsec_connection_get_description_title ${= connection})" cli_space =20 # Peer --=20 2.6.3 --===============2794310499846353227==--