]> git.ipfire.org Git - people/stevee/network.git/commitdiff
ipsec-connection: add color support
authorJonatan Schlag <jonatan.schlag@ipfire.org>
Wed, 16 Aug 2017 09:46:57 +0000 (11:46 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 16 Aug 2017 12:32:28 +0000 (14:32 +0200)
Signed-off-by: Jonatan Schlag <jonatan.schlag@ipfire.org>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/bash-completion/network
src/functions/functions.colors
src/functions/functions.ipsec

index 15bb9e8addf4f6b7342c413d5d9076b89a4b38d8..807f0039b054d59a05d0d9eb797f2b47a4651a22 100644 (file)
@@ -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}
                        ;;
index 121d73661a53f4a12751ca92891a55dcff8d1a99..816af487fe988d5bc12b8e6380e64323fff9dd17 100644 (file)
@@ -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"
                        ;;
index 4a8bb6006ab4047d3b2f616bfcd6708021907e60..73c7e8739a1cd57622255288109a521625676f12 100644 (file)
@@ -83,6 +83,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 $?
@@ -127,6 +130,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}"
 
@@ -140,6 +151,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}"