blob: 6bd4ebf7db9ca6a1883ec2f21b5659b6027fa4b2 (
plain)
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
# Linux ipsec(8) completion (for FreeS/WAN and strongSwan) -*- shell-script -*-
# Complete ipsec.conf conn entries.
#
# Reads a file from stdin in the ipsec.conf(5) format.
_comp_cmd_ipsec__connections()
{
local keyword name
while read -r keyword name; do
if [[ $keyword == [#]* ]]; then continue; fi
[[ $keyword == conn && $name != '%default' ]] && COMPREPLY+=("$name")
done
((${#COMPREPLY[@]})) &&
_comp_compgen -- -W '"${COMPREPLY[@]}"'
}
_comp_cmd_ipsec__freeswan()
{
local cur prev words cword comp_args
_comp_initialize -- "$@" || return
if ((cword == 1)); then
_comp_compgen -- -W 'auto barf eroute klipsdebug look manual pluto
ranbits rsasigkey setup showdefaults showhostkey spi spigrp tncfg
whack'
return
fi
case ${words[1]} in
auto)
_comp_compgen -- -W '--asynchronous --up --add --delete --replace
--down --route --unroute --ready --status --rereadsecrets'
;;
manual)
_comp_compgen -- -W '--up --down --route --unroute --union'
;;
ranbits)
_comp_compgen -- -W '--quick --continuous --bytes'
;;
setup)
_comp_compgen -- -W '--start --stop --restart'
;;
*) ;;
esac
}
_comp_cmd_ipsec__strongswan()
{
local cur prev words cword comp_args
_comp_initialize -- "$@" || return
if ((cword == 1)); then
_comp_compgen -- -W 'down irdumm leases listaacerts listacerts listalgs
listall listcacerts listcainfos listcards listcerts listcrls
listgroups listocsp listocspcerts listpubkeys openac pki pluto pool
purgecerts purgecrls purgeike purgeocsp ready reload rereadaacerts
rereadacerts rereadall rereadcacerts rereadcrls rereadgroups
rereadocspcerts rereadsecrets restart route scdecrypt scencrypt
scepclient secrets start starter status statusall stop stroke
unroute uci up update version whack --confdir --copyright
--directory --help --version --versioncode'
return
fi
case ${words[1]} in
down | route | status | statusall | unroute | up)
local confdir=$(ipsec --confdir)
_comp_cmd_ipsec__connections <"$confdir/ipsec.conf"
;;
list*)
_comp_compgen -- -W '--utc'
;;
restart | start)
_comp_compgen -- -W '--attach-gdb --auto-update --debug --debug-all
--debug-more --nofork'
;;
pki)
_comp_compgen -- -W '--gen --issue --keyid --print --pub --req
--self --signcrl --verify'
;;
pool) ;;
irdumm)
_comp_compgen_filedir 'rb'
;;
*) ;;
esac
}
case "$(ipsec --version 2>/dev/null)" in
*strongSwan*)
complete -F _comp_cmd_ipsec__strongswan ipsec
;;
*)
complete -F _comp_cmd_ipsec__freeswan ipsec
;;
esac
# ex: filetype=sh
|