]> git.ipfire.org Git - people/ms/network.git/commitdiff
bash-autocompletion: add basic security-policy support
authorJonatan Schlag <jonatan.schlag@ipfire.org>
Fri, 4 Aug 2017 08:32:13 +0000 (10:32 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 4 Aug 2017 10:48:04 +0000 (12:48 +0200)
Signed-off-by: Jonatan Schlag <jonatan.schlag@ipfire.org>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/bash-completion/network

index 5fd6191ad404e763c10957dbe85422db3431053e..668c69959b93f1c1b6596c145babeeee4e85038e 100644 (file)
@@ -343,7 +343,7 @@ _network_settings() {
 _network_vpn() {
        local words=( $@ )
 
-       local commands="ipsec"
+       local commands="ipsec security-policies"
        local cmd="$(_network_find_on_cmdline "${commands}")"
        if [[ -z "${cmd}" ]]; then
                COMPREPLY=( $(compgen -W "${commands}" -- "${cur}") )
@@ -356,6 +356,9 @@ _network_vpn() {
                ipsec)
                        _network_vpn_ipsec ${args}
                        ;;
+               security-policies)
+                       _network_vpn_security_policies ${args}
+                       ;;
                esac
 }
 
@@ -520,6 +523,93 @@ _network_vpn_ipsec_connection_subcommands_security_policy() {
        fi
 }
 
+_network_vpn_security_policies() {
+       local words=( $@ )
+
+       local commands="destroy new $(network raw list-vpn-security-policies-all)"
+       local cmd="$(_network_find_on_cmdline "${commands}")"
+       if [[ -z "${cmd}" ]]; then
+               COMPREPLY=( $(compgen -W "${commands}" -- "${cur}") )
+               return 0
+       fi
+
+
+       local args="${words[@]:1}"
+       case "${cmd}" in
+               destroy)
+                       :
+                       ;;
+               new)
+                       :
+                       ;;
+               *)
+                       if network raw vpn-security-policy-exists ${cmd}; then
+                               _network_vpn_security_policies_subcommands ${cmd} ${args}
+                       fi
+                       ;;
+               esac
+}
+
+_network_vpn_security_policies_subcommands() {
+       local policy=${1}
+       shift
+       local words=( $@ )
+
+       local commands="cipher compression group-type integrity key-exchange lifetime pfs show"
+       local cmd="$(_network_find_on_cmdline "${commands}")"
+       if [[ -z "${cmd}" ]]; then
+               COMPREPLY=( $(compgen -W "${commands}" -- "${cur}") )
+               return 0
+       fi
+
+
+       local args="${words[@]:1}"
+       case "${cmd}" in
+               cipher)
+                       _network_vpn_security_policies_subcommands_cipher ${policy} ${args}
+                       ;;
+               compression)
+                       _network_vpn_security_policies_subcommands_compression ${policy} ${args}
+                       ;;
+               group-type)
+                       _network_vpn_security_policies_subcommands_group_type ${policy} ${args}
+                       ;;
+               integrity)
+                       _network_vpn_security_policies_subcommands_integrity ${policy} ${args}
+                       ;;
+               key-exchange)
+                       _network_vpn_security_policies_subcommands_key_exchange ${policy} ${args}
+                       ;;
+               pfs)
+                       _network_vpn_security_policies_subcommands_pfs ${policy} ${args}
+                       ;;
+               esac
+}
+
+_network_vpn_security_policies_subcommands_cipher() {
+       :
+}
+
+_network_vpn_security_policies_subcommands_compression() {
+       :
+}
+
+_network_vpn_security_policies_subcommands_group_type() {
+       :
+}
+
+_network_vpn_security_policies_subcommands_integrity() {
+       :
+}
+
+_network_vpn_security_policies_subcommands_key_exchange() {
+       :
+}
+
+_network_vpn_security_policies_subcommands_pfs() {
+       :
+}
+
 _network_zone() {
        local words=( $@ )