23 |
- |
1 |
# -*- Mode: sh -*-
|
|
|
2 |
# URL: https://community.zarafa.com/pg/plugins/project/433/developer/John/bash-completion
|
|
|
3 |
#
|
|
|
4 |
# 2012-07-02 Retrieved z-b-c
|
|
|
5 |
# 2012-07-08 Jan Engelhardt
|
|
|
6 |
# Remove use of @() extglob syntax since it might not be active
|
|
|
7 |
# after all
|
|
|
8 |
#
|
|
|
9 |
# bash completion for Zarafa admin command
|
|
|
10 |
|
|
|
11 |
_zarafa__hosts()
|
|
|
12 |
{
|
|
|
13 |
local host_completes
|
|
|
14 |
host_completes='file:///var/run/zarafa http://localhost:236/zarafa https://localhost:237/zarafa'
|
|
|
15 |
COMPREPLY=( $( compgen -W "$host_completes" -- ${COMP_WORDS[COMP_CWORD]} ) )
|
|
|
16 |
return 0
|
|
|
17 |
}
|
|
|
18 |
|
|
|
19 |
_zarafa__userlist()
|
|
|
20 |
{
|
|
|
21 |
# what todo with maybe passed --host ?
|
|
|
22 |
# what todo with maybe passed -I company, --type ... ?
|
|
|
23 |
|
|
|
24 |
local users
|
|
|
25 |
users=$(zarafa-admin -l | grep -v ^User | grep -v username | grep -v SYSTEM | grep -v -- -- | awk {'print $1'})
|
|
|
26 |
COMPREPLY=( $( compgen -W "$users" -- ${COMP_WORDS[COMP_CWORD]} ) )
|
|
|
27 |
return 0
|
|
|
28 |
}
|
|
|
29 |
|
|
|
30 |
_zarafa__grouplist()
|
|
|
31 |
{
|
|
|
32 |
# what todo with maybe passed --host ?
|
|
|
33 |
# what todo with maybe passed -I company, --type ... ?
|
|
|
34 |
|
|
|
35 |
local groups
|
|
|
36 |
groups=$(zarafa-admin -L | grep -v ^Group | grep -v groupname | grep -v Everyone | grep -v -- -- | awk {'print $1'})
|
|
|
37 |
COMPREPLY=( $( compgen -W "$groups" -- ${COMP_WORDS[COMP_CWORD]} ) )
|
|
|
38 |
return 0
|
|
|
39 |
}
|
|
|
40 |
|
|
|
41 |
_zarafa__companylist()
|
|
|
42 |
{
|
|
|
43 |
# what todo with maybe passed --host ?
|
|
|
44 |
|
|
|
45 |
local users
|
|
|
46 |
users=$(zarafa-admin --list-companies | tail -n +4 | awk {'print $1'})
|
|
|
47 |
COMPREPLY=( $( compgen -W "$users" -- ${COMP_WORDS[COMP_CWORD]} ) )
|
|
|
48 |
return 0
|
|
|
49 |
}
|
|
|
50 |
|
|
|
51 |
_zarafa_stats_options()
|
|
|
52 |
{
|
|
|
53 |
list='--system --session --users --company --top --user -u --host -h'
|
|
|
54 |
COMPREPLY=( $( compgen -W "$list" -- ${COMP_WORDS[COMP_CWORD]} ) )
|
|
|
55 |
}
|
|
|
56 |
complete -F _zarafa_stats_options zarafa-stats
|
|
|
57 |
|
|
|
58 |
_zarafa_admin_options()
|
|
|
59 |
{
|
|
|
60 |
local cur prev short_actions long_actions possiblelist
|
|
|
61 |
|
|
|
62 |
short_actions='-V -l -L -s -c -u -d -U -P -p -f -e -a -h -g -G -b -B -i -I -n'
|
|
|
63 |
long_actions='--create-store --remove-store --hook-store --unhook-store --copyto-public --details --type --help --host --sync --qh --qs --qw --qo --udqh --udqs --udqw --udqo --lang --mr-accept --mr-decline-conflict --mr-decline-recurring --add-sendas --del-sendas --list-sendas --list-orphans --create-company --update-company --delete-company --list-companies --add-to-viewlist --del-from-viewlist --list-view --add-to-adminlist --del-from-adminlist --list-admin --set-system-admin --add-userquota-recipient --del-userquota-recipient --list-userquota-recipient --add-companyquota-recipient --del-companyquota-recipient --list-companyquota-recipient --purge-softdelete --purge-deferred --config --enable-feature --disable-feature --clear-cache --user-count'
|
|
|
64 |
|
|
|
65 |
COMPREPLY=()
|
|
|
66 |
cur=${COMP_WORDS[COMP_CWORD]}
|
|
|
67 |
prev=${COMP_WORDS[COMP_CWORD-1]}
|
|
|
68 |
|
|
|
69 |
case "$prev" in
|
|
|
70 |
-h|--host)
|
|
|
71 |
# host completion is quite senseless, since you need admin rights, and no ssl cert can be used in zarafa-admin
|
|
|
72 |
_zarafa__hosts
|
|
|
73 |
return 0
|
|
|
74 |
;;
|
|
|
75 |
|
|
|
76 |
--qo|--qdqo|--mr-*|-a|-n)
|
|
|
77 |
possiblelist="yes no"
|
|
|
78 |
;;
|
|
|
79 |
|
|
|
80 |
--config)
|
|
|
81 |
_filedir
|
|
|
82 |
return 0
|
|
|
83 |
;;
|
|
|
84 |
|
|
|
85 |
--lang|--create-company|-c|-U|-p|-f|-e|-g|--qh|--qs|--qw|--udqh|--udqs|--udqw|--list-admin|--list-userquota-recipient|--list-companyquota-recipient|--purge-softdelete)
|
|
|
86 |
# opt req, no hints
|
|
|
87 |
return 0
|
|
|
88 |
;;
|
|
|
89 |
|
|
|
90 |
-G|-i)
|
|
|
91 |
_zarafa__grouplist
|
|
|
92 |
return 0
|
|
|
93 |
;;
|
|
|
94 |
|
|
|
95 |
-I|--list-view|--add-to-viewlist|--del-from-viewlist)
|
|
|
96 |
_zarafa__companylist
|
|
|
97 |
return 0
|
|
|
98 |
;;
|
|
|
99 |
|
|
|
100 |
--details|--unhook-store|--create-store|-u|-d|-b|-B|--list-sendas|--add-sendas|--del-sendas|--add-to-adminlist|--del-from-adminlist|--set-system-admin|--add-userquota-recipient|--del-userquota-recipient|--add-companyquota-recipient|--del-companyquota-recipient)
|
|
|
101 |
_zarafa__userlist
|
|
|
102 |
return 0
|
|
|
103 |
;;
|
|
|
104 |
|
|
|
105 |
--type)
|
|
|
106 |
possiblelist="user group company"
|
|
|
107 |
;;
|
|
|
108 |
|
|
|
109 |
--enable-feature|--disable-feature)
|
|
|
110 |
possiblelist="imap pop3"
|
|
|
111 |
;;
|
|
|
112 |
esac
|
|
|
113 |
|
|
|
114 |
if [ -z "$possiblelist" ]; then
|
|
|
115 |
possiblelist="$short_actions $long_actions"
|
|
|
116 |
fi
|
|
|
117 |
|
|
|
118 |
COMPREPLY=( $( compgen -W "$possiblelist" -- "$cur" ) )
|
|
|
119 |
return 0
|
|
|
120 |
}
|
|
|
121 |
complete -F _zarafa_admin_options $filenames zarafa-admin
|
|
|
122 |
|
|
|
123 |
_zarafa_backup_options()
|
|
|
124 |
{
|
|
|
125 |
local cur short_actions long_actions possiblelist
|
|
|
126 |
|
|
|
127 |
short_actions='-a -p -P -u -h -o -c -s -i -J -N -v'
|
|
|
128 |
long_actions='--all --user --public --company --company-public --store --skip-junk --skip-public --output --host --config --verbose --help'
|
|
|
129 |
|
|
|
130 |
COMPREPLY=()
|
|
|
131 |
cur=${COMP_WORDS[COMP_CWORD]}
|
|
|
132 |
prev=${COMP_WORDS[COMP_CWORD-1]}
|
|
|
133 |
|
|
|
134 |
case "$prev" in
|
|
|
135 |
-h|--host)
|
|
|
136 |
_zarafa__hosts
|
|
|
137 |
return 0
|
|
|
138 |
;;
|
|
|
139 |
|
|
|
140 |
# actually the (.*).zbk.index part ?
|
|
|
141 |
-u|--user|-f|--from)
|
|
|
142 |
_zarafa__userlist
|
|
|
143 |
;;
|
|
|
144 |
|
|
|
145 |
-s|--company|-P|--company-public)
|
|
|
146 |
_zarafa__companylist
|
|
|
147 |
;;
|
|
|
148 |
|
|
|
149 |
-i|--restorefile|-c|--config)
|
|
|
150 |
_filedir
|
|
|
151 |
return 0
|
|
|
152 |
;;
|
|
|
153 |
|
|
|
154 |
-o|--output)
|
|
|
155 |
_filedir -d
|
|
|
156 |
return 0
|
|
|
157 |
;;
|
|
|
158 |
|
|
|
159 |
-i|--store)
|
|
|
160 |
# opt req, no hints
|
|
|
161 |
return 0
|
|
|
162 |
;;
|
|
|
163 |
|
|
|
164 |
# empty parameters, ok with help and read??
|
|
|
165 |
--all|--public|--skip-junk|--skip-public|--verbose|--help)
|
|
|
166 |
;;
|
|
|
167 |
-a|-p|-J|-N|-v)
|
|
|
168 |
;;
|
|
|
169 |
esac
|
|
|
170 |
|
|
|
171 |
if [ -z "$possiblelist" ]; then
|
|
|
172 |
possiblelist="$short_actions $long_actions"
|
|
|
173 |
fi
|
|
|
174 |
|
|
|
175 |
COMPREPLY=( $( compgen -W "$possiblelist" -- "$cur" ) )
|
|
|
176 |
return 0
|
|
|
177 |
}
|
|
|
178 |
complete -F _zarafa_backup_options $filenames zarafa-backup
|
|
|
179 |
|
|
|
180 |
_zarafa_restore_options()
|
|
|
181 |
{
|
|
|
182 |
local cur short_actions long_actions possiblelist
|
|
|
183 |
|
|
|
184 |
short_actions='-u -f -h -c -i -r -p -a -b -v'
|
|
|
185 |
long_actions='--user --public --from --restorefile --recurse --not-before --not-after --host --config --verbose --help'
|
|
|
186 |
|
|
|
187 |
COMPREPLY=()
|
|
|
188 |
cur=${COMP_WORDS[COMP_CWORD]}
|
|
|
189 |
prev=${COMP_WORDS[COMP_CWORD-1]}
|
|
|
190 |
|
|
|
191 |
case "$prev" in
|
|
|
192 |
-h|--host)
|
|
|
193 |
_zarafa__hosts
|
|
|
194 |
return 0
|
|
|
195 |
;;
|
|
|
196 |
|
|
|
197 |
# actually the (.*).zbk.index part ?
|
|
|
198 |
-u|--user|-f|--from)
|
|
|
199 |
_zarafa__userlist
|
|
|
200 |
;;
|
|
|
201 |
|
|
|
202 |
-i|--restorefile|-c|--config|-a)
|
|
|
203 |
_filedir
|
|
|
204 |
return 0
|
|
|
205 |
;;
|
|
|
206 |
|
|
|
207 |
--not-before|-b)
|
|
|
208 |
# opt req, no hints
|
|
|
209 |
return 0
|
|
|
210 |
;;
|
|
|
211 |
|
|
|
212 |
# empty parameters, ok with help and read??
|
|
|
213 |
--help|--public|--recurse|--verbose)
|
|
|
214 |
;;
|
|
|
215 |
-p|-r|-v)
|
|
|
216 |
;;
|
|
|
217 |
esac
|
|
|
218 |
|
|
|
219 |
if [ -z "$POSSIBLELIST" ]; then
|
|
|
220 |
possiblelist="$short_actions $long_actions"
|
|
|
221 |
fi
|
|
|
222 |
|
|
|
223 |
COMPREPLY=( $( compgen -W "$possiblelist" -- "$cur" ) )
|
|
|
224 |
|
|
|
225 |
return 0
|
|
|
226 |
}
|
|
|
227 |
complete -F _zarafa_restore_options $filenames zarafa-restore
|
|
|
228 |
|
|
|
229 |
_zarafa_dagent_options()
|
|
|
230 |
{
|
|
|
231 |
local cur short_actions long_actions possiblelist
|
|
|
232 |
|
|
|
233 |
short_actions='-c -j -f -d -h -a -F -P -p -q -s -v -e -n -C -V -r -R -l -N'
|
|
|
234 |
long_actions='--help --config --junk --file --host --daemonize --listen --folder --public --create --read --do-not-notify --add-imap-data'
|
|
|
235 |
|
|
|
236 |
COMPREPLY=()
|
|
|
237 |
cur=${COMP_WORDS[COMP_CWORD]}
|
|
|
238 |
prev=${COMP_WORDS[COMP_CWORD-1]}
|
|
|
239 |
|
|
|
240 |
case "$prev" in
|
|
|
241 |
-h|--host)
|
|
|
242 |
_zarafa__hosts
|
|
|
243 |
return 0
|
|
|
244 |
;;
|
|
|
245 |
|
|
|
246 |
-f|--file|-c|--config|-a)
|
|
|
247 |
_filedir
|
|
|
248 |
return 0
|
|
|
249 |
;;
|
|
|
250 |
|
|
|
251 |
-P|--public|-F|--folder|-p)
|
|
|
252 |
# opt req, no hints
|
|
|
253 |
return 0
|
|
|
254 |
;;
|
|
|
255 |
|
|
|
256 |
# empty parameters, ok with help and read??
|
|
|
257 |
--help|--junk|--daemonize|--listen|--read|--do-not-notify)
|
|
|
258 |
;;
|
|
|
259 |
-j|-d|-q|-s|-v|-e|-n|-r|-l|-R|-N)
|
|
|
260 |
;;
|
|
|
261 |
esac
|
|
|
262 |
|
|
|
263 |
if [ -z "$possiblelist" ]; then
|
|
|
264 |
possiblelist="$short_actions $long_actions"
|
|
|
265 |
fi
|
|
|
266 |
|
|
|
267 |
COMPREPLY=( $( compgen -W "$possiblelist" -- "$cur" ) )
|
|
|
268 |
|
|
|
269 |
return 0
|
|
|
270 |
}
|
|
|
271 |
complete -F _zarafa_dagent_options $filenames zarafa-dagent
|
|
|
272 |
|
|
|
273 |
_zarafa_fsck_options()
|
|
|
274 |
{
|
|
|
275 |
local cur short_actions long_actions possiblelist
|
|
|
276 |
|
|
|
277 |
short_actions='-u -p -P -h -a'
|
|
|
278 |
long_actions='--help --host --pass --user --calendar --contact --task --all --autofix --autodel --checkonly'
|
|
|
279 |
|
|
|
280 |
COMPREPLY=()
|
|
|
281 |
cur=${COMP_WORDS[COMP_CWORD]}
|
|
|
282 |
prev=${COMP_WORDS[COMP_CWORD-1]}
|
|
|
283 |
|
|
|
284 |
case "$prev" in
|
|
|
285 |
-h|--host)
|
|
|
286 |
_zarafa__hosts
|
|
|
287 |
return 0
|
|
|
288 |
;;
|
|
|
289 |
|
|
|
290 |
-u|--user)
|
|
|
291 |
_zarafa__userlist
|
|
|
292 |
return 0
|
|
|
293 |
;;
|
|
|
294 |
|
|
|
295 |
-p|--pass)
|
|
|
296 |
# opt req, no hints
|
|
|
297 |
return 0
|
|
|
298 |
;;
|
|
|
299 |
|
|
|
300 |
# empty parameters
|
|
|
301 |
--calendar|--contact|--task|--all|--autofix|--autodel|--checkonly)
|
|
|
302 |
;;
|
|
|
303 |
-P|-a)
|
|
|
304 |
;;
|
|
|
305 |
esac
|
|
|
306 |
|
|
|
307 |
if [ -z "$possiblelist" ]; then
|
|
|
308 |
possiblelist="$short_actions $long_actions"
|
|
|
309 |
fi
|
|
|
310 |
|
|
|
311 |
COMPREPLY=( $( compgen -W "$possiblelist" -- "$cur" ) )
|
|
|
312 |
|
|
|
313 |
return 0
|
|
|
314 |
}
|
|
|
315 |
complete -F _zarafa_fsck_options zarafa-fsck
|
|
|
316 |
|
|
|
317 |
_zarafa_passwd_options()
|
|
|
318 |
{
|
|
|
319 |
local cur short_actions long_actions possiblelist
|
|
|
320 |
|
|
|
321 |
short_actions='-u -p -h -o -V'
|
|
|
322 |
long_actions='--help --host'
|
|
|
323 |
|
|
|
324 |
COMPREPLY=()
|
|
|
325 |
cur=${COMP_WORDS[COMP_CWORD]}
|
|
|
326 |
prev=${COMP_WORDS[COMP_CWORD-1]}
|
|
|
327 |
|
|
|
328 |
case "$prev" in
|
|
|
329 |
-h|--host)
|
|
|
330 |
_zarafa__hosts
|
|
|
331 |
return 0
|
|
|
332 |
;;
|
|
|
333 |
|
|
|
334 |
-u|-a)
|
|
|
335 |
_zarafa__userlist
|
|
|
336 |
return 0
|
|
|
337 |
;;
|
|
|
338 |
|
|
|
339 |
-p|-o|-V)
|
|
|
340 |
# empty parameters
|
|
|
341 |
;;
|
|
|
342 |
esac
|
|
|
343 |
|
|
|
344 |
if [ -z "$possiblelist" ]; then
|
|
|
345 |
possiblelist="$short_actions $long_actions"
|
|
|
346 |
fi
|
|
|
347 |
|
|
|
348 |
COMPREPLY=( $( compgen -W "$possiblelist" -- "$cur" ) )
|
|
|
349 |
|
|
|
350 |
return 0
|
|
|
351 |
}
|
|
|
352 |
complete -F _zarafa_passwd_options zarafa-passwd
|
|
|
353 |
|
|
|
354 |
_zarafa_archiver_options()
|
|
|
355 |
{
|
|
|
356 |
local cur short_actions long_actions possiblelist
|
|
|
357 |
|
|
|
358 |
short_actions='-u -l -A -w -c'
|
|
|
359 |
long_actions='--list --archive --local-only --attach-to --detach-from --archive-folder --archive-server --no-folder --write --config --help'
|
|
|
360 |
|
|
|
361 |
COMPREPLY=()
|
|
|
362 |
cur=${COMP_WORDS[COMP_CWORD]}
|
|
|
363 |
prev=${COMP_WORDS[COMP_CWORD-1]}
|
|
|
364 |
|
|
|
365 |
case "$prev" in
|
|
|
366 |
-u|--attach-to|--detach-from)
|
|
|
367 |
_zarafa__userlist
|
|
|
368 |
return 0
|
|
|
369 |
;;
|
|
|
370 |
|
|
|
371 |
--archive-server)
|
|
|
372 |
_zarafa__hosts
|
|
|
373 |
return 0
|
|
|
374 |
;;
|
|
|
375 |
|
|
|
376 |
-l|-w|-c|--list|--local-only|--archive-folder|--no-folder|--writable|--config|--help)
|
|
|
377 |
# empty parameters
|
|
|
378 |
;;
|
|
|
379 |
esac
|
|
|
380 |
|
|
|
381 |
if [ -z "$possiblelist" ]; then
|
|
|
382 |
possiblelist="$short_actions $long_actions"
|
|
|
383 |
fi
|
|
|
384 |
|
|
|
385 |
COMPREPLY=( $( compgen -W "$possiblelist" -- "$cur" ) )
|
|
|
386 |
|
|
|
387 |
return 0
|
|
|
388 |
}
|
|
|
389 |
complete -F _zarafa_archiver_options zarafa-archiver
|