-
Notifications
You must be signed in to change notification settings - Fork 1
/
completion.sh
173 lines (137 loc) · 3.2 KB
/
completion.sh
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
#! /bin/bash
. /etc/freeradius-bash-admin.conf
_get_username() {
_mysql_silent "
SELECT
username
FROM radcheck
WHERE username LIKE '$1%'
"
}
_get_groupname() {
_mysql_silent "
SELECT
groupname
FROM radgroupcheck
WHERE groupname LIKE '$1%'
"
}
_get_nas_shortname() {
_mysql_silent "
SELECT
shortname
FROM nas
WHERE shortname LIKE '$1%'
"
}
_radius_group() {
local CUR PREV OPTS
COMPREPLY=()
CUR="${COMP_WORDS[COMP_CWORD]}"
PREV="${COMP_WORDS[COMP_CWORD-1]}"
case "$PREV" in
radius-group)
OPTS="add delete help prepopulate show update"
COMPREPLY=( $(compgen -W "$OPTS" $CUR) )
return 0
;;
show|update|delete)
COMPREPLY=( $(compgen -W "$(_get_groupname $CUR)" $CUR) )
return 0
;;
esac
}
complete -F _radius_group radius-group
_radius_guest() {
local CUR PREV OPTS
COMPREPLY=()
CUR="${COMP_WORDS[COMP_CWORD]}"
PREV="${COMP_WORDS[COMP_CWORD-1]}"
case "$PREV" in
radius-guest)
OPTS="add count delete-expired show-expired"
COMPREPLY=( $(compgen -W "$OPTS" $CUR) )
return 0
;;
esac
}
complete -F _radius_guest radius-guest
_radius_nas() {
local CUR PREV OPTS
COMPREPLY=()
CUR="${COMP_WORDS[COMP_CWORD]}"
PREV="${COMP_WORDS[COMP_CWORD-1]}"
case "$PREV" in
radius-nas)
OPTS="add show update delete help"
COMPREPLY=( $(compgen -W "$OPTS" $CUR) )
return 0
;;
show|update|delete)
COMPREPLY=( $(compgen -W "$(_get_nas_shortname $CUR)" $CUR) )
return 0
;;
esac
}
complete -F _radius_nas radius-nas
_radius_clean() {
local CUR PREV OPTS
COMPREPLY=()
CUR="${COMP_WORDS[COMP_CWORD]}"
PREV="${COMP_WORDS[COMP_CWORD-1]}"
case "$PREV" in
radius-clean)
OPTS="radpostauth"
COMPREPLY=( $(compgen -W "$OPTS" $CUR) )
return 0
;;
esac
}
complete -F _radius_clean radius-clean
_radius_install_uninstall() {
local CUR PREV OPTS
COMPREPLY=()
CUR="${COMP_WORDS[COMP_CWORD]}"
PREV="${COMP_WORDS[COMP_CWORD-1]}"
case "$PREV" in
radius-install|radius-uninstall)
OPTS="all common infouser infogroup nas radacct radcheck radgroupcheck radgroupreply radreply radusergroup radpostauth cui ippool wimax"
COMPREPLY=( $(compgen -W "$OPTS" $CUR) )
return 0
;;
esac
}
complete -F _radius_install_uninstall radius-install radius-uninstall
_radius_log() {
local CUR PREV OPTS
COMPREPLY=()
CUR="${COMP_WORDS[COMP_CWORD]}"
PREV="${COMP_WORDS[COMP_CWORD-1]}"
case "$PREV" in
radius-log)
OPTS="last-logins user-count user-log nas-count db-values db-layout log-file"
COMPREPLY=( $(compgen -W "$OPTS" $CUR) )
return 0
;;
esac
}
complete -F _radius_log radius-log
_radius_user() {
local CUR PREV OPTS
COMPREPLY=()
CUR="${COMP_WORDS[COMP_CWORD]}"
PREV="${COMP_WORDS[COMP_CWORD-1]}"
case "$PREV" in
radius-user)
OPTS="add delete help password show update"
COMPREPLY=( $(compgen -W "$OPTS" $CUR) )
return 0
;;
show|update|delete)
COMPREPLY=( $(compgen -W "$(_get_username $CUR)" $CUR) )
return 0
;;
esac
}
complete -F _radius_user radius-user
# vim: set ts=2 sw=2 sts=2 et :