* [PATCH 1/2] ipsec-connection: add color support
@ 2017-08-16 9:46 Jonatan Schlag
2017-08-16 9:46 ` [PATCH 2/2] ipsec-connection: add description feature Jonatan Schlag
0 siblings, 1 reply; 2+ messages in thread
From: Jonatan Schlag @ 2017-08-16 9:46 UTC (permalink / raw)
To: network
[-- Attachment #1: Type: text/plain, Size: 2854 bytes --]
Signed-off-by: Jonatan Schlag <jonatan.schlag(a)ipfire.org>
---
src/bash-completion/network | 5 ++++-
src/functions/functions.colors | 3 +++
src/functions/functions.ipsec | 14 ++++++++++++++
3 files changed, 21 insertions(+), 1 deletion(-)
diff --git a/src/bash-completion/network b/src/bash-completion/network
index 5ddc8db..a25e43b 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 down inactivity-timeout local mode peer remote security-policy show up"
+ local commands="authentication color 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}") )
@@ -426,6 +426,9 @@ _network_vpn_ipsec_connection_subcommands() {
authentication)
_network_vpn_ipsec_connection_subcommands_authentication ${connection} ${args}
;;
+ color)
+ _network_color ${args}
+ ;;
local)
_network_vpn_ipsec_connection_subcommands_local_remote ${connection} "local" ${args}
;;
diff --git a/src/functions/functions.colors b/src/functions/functions.colors
index 121d736..816af48 100644
--- a/src/functions/functions.colors
+++ b/src/functions/functions.colors
@@ -151,6 +151,9 @@ color_format_filename() {
local type=${1}
local name=${2}
case ${type} in
+ ipsec-connection)
+ echo "${NETWORK_IPSEC_CONNS_DIR}/${name}/color"
+ ;;
zone)
echo "$(zone_dir ${name})/color"
;;
diff --git a/src/functions/functions.ipsec b/src/functions/functions.ipsec
index 7283836..6a91d39 100644
--- a/src/functions/functions.ipsec
+++ b/src/functions/functions.ipsec
@@ -88,6 +88,9 @@ cli_ipsec_connection() {
authentication|down|disable|dpd|enable|inactivity_timeout|local|mode|peer|pool|remote|security_policy|start_action|up)
ipsec_connection_${key} ${connection} $@
;;
+ color)
+ color_cli "ipsec-connection" "${connection}" "$@"
+ ;;
show)
cli_ipsec_connection_show "${connection}"
exit $?
@@ -173,6 +176,14 @@ cli_ipsec_connection_destroy() {
ipsec_strongswan_autostart
}
+ipsec_connection_get_color() {
+ # This function return the color of a zone
+ assert [ $# -eq 1 ]
+
+ local name=${1}
+ color_read "ipsec-connection" ${name}
+}
+
cli_ipsec_connection_show() {
local connection="${1}"
@@ -186,6 +197,9 @@ cli_ipsec_connection_show() {
cli_headline 0 "IPsec VPN Connection: ${connection}"
cli_space
+ cli_print_fmt1 1 "Color" "$(cli_color_bar $(ipsec_connection_get_color ${connection}))"
+ cli_space
+
# Peer
if isset PEER; then
cli_print_fmt1 1 "Peer" "${PEER}"
--
2.6.3
^ permalink raw reply [flat|nested] 2+ messages in thread
* [PATCH 2/2] ipsec-connection: add description feature
2017-08-16 9:46 [PATCH 1/2] ipsec-connection: add color support Jonatan Schlag
@ 2017-08-16 9:46 ` Jonatan Schlag
0 siblings, 0 replies; 2+ messages in thread
From: Jonatan Schlag @ 2017-08-16 9:46 UTC (permalink / raw)
To: network
[-- Attachment #1: Type: text/plain, Size: 2751 bytes --]
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=( $@ )
- 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 0db8ede..728ec2c 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 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}
}
+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}"
@@ -198,6 +208,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
--
2.6.3
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-08-16 9:46 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-16 9:46 [PATCH 1/2] ipsec-connection: add color support Jonatan Schlag
2017-08-16 9:46 ` [PATCH 2/2] ipsec-connection: add description feature Jonatan Schlag
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox