-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathzabbix-utils-completion
More file actions
29 lines (26 loc) · 1015 Bytes
/
zabbix-utils-completion
File metadata and controls
29 lines (26 loc) · 1015 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#
# Bash completion, common file for Zabbix utilities get and sender
#
_zabbix-utils-tls-connect()
{
cur=$1
local util=$2
local tls_connect_options="unencrypted psk cert"
local cert_opts="--tls-ca-file|--tls-crl-file|--tls-cert-file|--tls-key-file"
local psk_opts="--tls-psk-identity|--tls-psk-file"
[[ $util = get ]] && cert_opts="$cert_opts|--tls-agent-cert-issuer|--tls-agent-cert-subject"
[[ $util = sender ]] && cert_opts="$cert_opts|--tls-server-cert-issuer|--tls-server-cert-subject"
# we skip the current parameter and the one before it, because it can not be any of the encryption parameters
# at most it can be the value for an encryption parameter
for (( i=1; i<=${#COMP_WORDS[@]-2}; ++i )) ; do
local option=${COMP_WORDS[$i]}
if [[ $option == @($psk_opts) ]]; then
COMPREPLY=( $(compgen -W "psk" -- ${cur}) )
return 0
elif [[ $option == @($cert_opts) ]]; then
COMPREPLY=( $(compgen -W "cert" -- ${cur}) )
return 0
fi
done
COMPREPLY=( $(compgen -W "${tls_connect_options}" -- ${cur}) )
}