]>
Commit | Line | Data |
---|---|---|
70e104c4 | 1 | #compdef timedatectl udevadm systemd-analyze systemd-cat systemd-ask-password systemd-cgls systemd-cgtop systemd-delta systemd-detect-virt systemd-inhibit systemd-machine-id-setup systemd-notify systemd-nspawn systemd-tmpfiles systemd-tty-ask-password-agent machinectl |
553b9323 DW |
2 | |
3 | _ctls() | |
4 | { | |
5 | local curcontext="$curcontext" state lstate line | |
6 | case "$service" in | |
553b9323 DW |
7 | timedatectl) |
8 | _arguments -s \ | |
9 | {-h,--help}'[Show this help]' \ | |
10 | '--version[Show package version]' \ | |
11 | '--adjust-system-clock[Adjust system clock when changing local RTC mode]' \ | |
12 | '--no-pager[Do not pipe output into a pager]' \ | |
13 | '--no-ask-password[Do not prompt for password]' \ | |
14 | {-H,--host=}'[Operate on remote host]:userathost:_hosts_or_user_at_host' \ | |
15 | '*::timedatectl commands:_timedatectl_command' | |
16 | ;; | |
17 | udevadm) | |
18 | _arguments \ | |
19 | '--debug[Print debug messages to stderr]' \ | |
20 | '--version[Print version number]' \ | |
21 | '--help[Print help text]' \ | |
22 | '*::udevadm commands:_udevadm_command' | |
23 | ;; | |
24 | systemd-analyze) | |
25 | _arguments \ | |
26 | {-h,--help}'[Show help text.]' \ | |
27 | '--user[Shows performance data of user sessions instead of the system manager.]' \ | |
1700761b SP |
28 | '--order[When generating graph for dot, show only order]' \ |
29 | '--require[When generating graph for dot, show only requirement]' \ | |
553b9323 DW |
30 | '*::systemd-analyze commands:_systemd_analyze_command' |
31 | ;; | |
32 | systemd-ask-password) | |
33 | _arguments \ | |
34 | {-h,--help}'[Show this help]' \ | |
35 | '--icon=[Icon name]' \ | |
36 | '--timeout=[Timeout in sec]' \ | |
37 | '--no-tty[Ask question via agent even on TTY]' \ | |
38 | '--accept-cached[Accept cached passwords]' \ | |
39 | '--multiple[List multiple passwords if available]' | |
40 | ;; | |
41 | systemd-cat) | |
42 | _arguments \ | |
43 | {-h,--help}'[Show this help]' \ | |
44 | '--version[Show package version.]' \ | |
45 | {-t,--identifier=}'[Set syslog identifier.]' \ | |
46 | {-p,--priority=}'[Set priority value.]:value:({0..7})' \ | |
47 | '--level-prefix=[Control whether level prefix shall be parsed.]:boolean:(1 0)' \ | |
48 | ':Message' | |
49 | ;; | |
50 | systemd-cgls) | |
51 | _arguments \ | |
52 | {-h,--help}'[Show this help]' \ | |
53 | '--version[Show package version]' \ | |
54 | '--no-pager[Do not pipe output into a pager]' \ | |
55 | {-a,--all}'[Show all groups, including empty]' \ | |
56 | '-k[Include kernel threads in output]' \ | |
57 | ':cgroups:(cpuset cpu cpuacct memory devices freezer net_cls blkio)' | |
58 | ;; | |
59 | systemd-cgtop) | |
60 | _arguments \ | |
61 | {-h,--help}'[Show this help]' \ | |
62 | '--version[Print version and exit]' \ | |
63 | '(-c -m -i -t)-p[Order by path]' \ | |
64 | '(-c -p -m -i)-t[Order by number of tasks]' \ | |
65 | '(-m -p -i -t)-c[Order by CPU load]' \ | |
66 | '(-c -p -i -t)-m[Order by memory load]' \ | |
67 | '(-c -m -p -t)-i[Order by IO load]' \ | |
68 | {-d,--delay=}'[Specify delay]' \ | |
69 | {-n,--iterations=}'[Run for N iterations before exiting]' \ | |
70 | {-b,--batch}'[Run in batch mode, accepting no input]' \ | |
71 | '--depth=[Maximum traversal depth]' | |
72 | ;; | |
73 | systemd-delta) | |
74 | _arguments \ | |
75 | {-h,--help}'[Show this help]' \ | |
76 | '--version[Show package version]' \ | |
77 | '--no-pager[Do not pipe output into a pager]' \ | |
78 | '--diff=[Show a diff when overridden files differ]:boolean:(1 0)' \ | |
79 | {-t,--type=}'[Only display a selected set of override types]:types:(masked equivalent redirected overridden unchanged)' \ | |
80 | ':SUFFIX:(tmpfiles.d sysctl.d systemd/system)' | |
81 | ;; | |
82 | systemd-detect-virt) | |
83 | _arguments \ | |
84 | {-h,--help}'[Show this help]' \ | |
85 | '--version[Show package version]' \ | |
86 | {-c,--container}'[Only detect whether we are run in a container]' \ | |
87 | {-v,--vm}'[Only detect whether we are run in a VM]' \ | |
88 | {-q,--quiet}"[Don't output anything, just set return value]" | |
89 | ;; | |
90 | systemd-inhibit) | |
91 | _arguments \ | |
92 | {-h,--help}'[Show this help]' \ | |
93 | '--version[Show package version]' \ | |
94 | '--what=[Operations to inhibit]:options:(shutdown sleep idle handle-power-key handle-suspend-key handle-hibernate-key handle-lid-switch)' \ | |
95 | '--who=[A descriptive string who is inhibiting]' \ | |
96 | '--why=[A descriptive string why is being inhibited]' \ | |
97 | '--mode=[One of block or delay]' \ | |
98 | '--list[List active inhibitors]' \ | |
99 | '*:commands:_systemd_inhibit_command' | |
100 | ;; | |
101 | systemd-machine-id-setup) | |
102 | _arguments \ | |
103 | {-h,--help}'[Show this help]' \ | |
104 | '--version[Show package version]' | |
105 | ;; | |
106 | systemd-notify) | |
107 | _arguments \ | |
108 | {-h,--help}'[Show this help]' \ | |
109 | '--version[Show package version]' \ | |
110 | '--ready[Inform the init system about service start-up completion.]' \ | |
111 | '--pid=[Inform the init system about the main PID of the daemon]' \ | |
112 | '--status=[Send a free-form status string for the daemon to the init systemd]' \ | |
113 | '--booted[Returns 0 if the system was booted up with systemd]' \ | |
114 | '--readahead=[Controls disk read-ahead operations]:arguments:(cancel done noreply)' | |
115 | ;; | |
116 | systemd-nspawn) | |
117 | _arguments \ | |
118 | {-h,--help}'[Show this help]' \ | |
119 | {--directory=,-D}'[Directory to use as file system root for the namespace container. If omitted the current directory will be used.]:directories:_directories' \ | |
120 | {--boot,-b}'[Automatically search for an init binary and invoke it instead of a shell or a user supplied program.]' \ | |
121 | {--user=,-u}'[Run the command under specified user, create home directory and cd into it.]' \ | |
122 | '--uuid=[Set the specified uuid for the container.]' \ | |
123 | {--controllers=,-C}'[Makes the container appear in other hierarchies than the name=systemd:/ one. Takes a comma-separated list of controllers.]' \ | |
124 | '--private-network[Turn off networking in the container. This makes all network interfaces unavailable in the container, with the exception of the loopback device.]' \ | |
125 | '--read-only[Mount the root file system read only for the container.]' \ | |
126 | '--capability=[List one or more additional capabilities to grant the container.]:capabilities:_systemd-nspawn' \ | |
127 | "--link-journal=[Control whether the container's journal shall be made visible to the host system.]:options:(no, host, guest, auto)" \ | |
128 | '-j[Equivalent to --link-journal=guest.]' | |
129 | ;; | |
130 | systemd-tmpfiles) | |
131 | _arguments \ | |
132 | '--create[Create, set ownership/permissions based on the config files.]' \ | |
133 | '--clean[Clean up all files and directories with an age parameter configured.]' \ | |
134 | '--remove[All files and directories marked with r, R in the configuration files are removed.]' \ | |
135 | '--prefix=[Only apply rules that apply to paths with the specified prefix.]' \ | |
5c795114 | 136 | '--exclude-prefix=[Ignore rules that apply to paths with the specified prefix.]' \ |
553b9323 DW |
137 | '--help[Prints a short help text and exits.]' \ |
138 | '*::files:_files' | |
139 | ;; | |
140 | systemd-tty-ask-password-agent) | |
141 | _arguments \ | |
142 | {-h,--help}'[Prints a short help text and exits.]' \ | |
143 | '--version[Prints a short version string and exits.]' \ | |
144 | '--list[Lists all currently pending system password requests.]' \ | |
145 | '--query[Process all currently pending system password requests by querying the user on the calling TTY.]' \ | |
146 | '--watch[Continuously process password requests.]' \ | |
147 | '--wall[Forward password requests to wall(1).]' \ | |
148 | '--plymouth[Ask question with plymouth(8).]' \ | |
149 | '--console[Ask question on /dev/console.]' | |
150 | ;; | |
80d39fbb WG |
151 | machinectl) |
152 | _arguments \ | |
153 | {-h,--help}'[Prints a short help text and exits.]' \ | |
154 | '--version[Prints a short version string and exits.]' \ | |
155 | {-p,--property=}'[Limit output to specified property.]:property:(Name Id Timestamp TimestampMonotonic Service Scope Leader Class State RootDirectory)' \ | |
156 | {-a,--all}'[Show all proerties]' \ | |
157 | (-l,--full)'[Do not ellipsize cgroup members]' \ | |
158 | '--no-pager[Do not pipe output into a pager]' \ | |
159 | '--no-ask-password[Do not ask for system passwords]' \ | |
160 | '--kill-who=[Who to send signal to]:killwho:(leader all)' \ | |
161 | {-s,--signal=}'[Which signal to send]:signal:_signals' \ | |
162 | {-H,--host=}'[Show information for remote host]:userathost:_hosts_or_user_at_host' \ | |
163 | {-P,--privileged}'[Acquire privileges before execution]' \ | |
164 | '*::machinectl command:_machinectl_command' | |
165 | ;; | |
553b9323 DW |
166 | *) _message 'eh?' ;; |
167 | esac | |
168 | } | |
169 | ||
170 | _systemd-nspawn(){ | |
171 | local -a _caps | |
172 | _caps=( CAP_CHOWN CAP_DAC_OVERRIDE CAP_DAC_READ_SEARCH | |
173 | CAP_FOWNER CAP_FSETID CAP_IPC_OWNER CAP_KILL CAP_LEASE CAP_LINUX_IMMUTABLE | |
174 | CAP_NET_BIND_SERVICE CAP_NET_BROADCAST CAP_NET_RAW CAP_SETGID CAP_SETFCAP CAP_SETPCAP | |
175 | CAP_SETUID CAP_SYS_ADMIN CAP_SYS_CHROOT CAP_SYS_NICE CAP_SYS_PTRACE CAP_SYS_TTY_CONFIG | |
176 | CAP_SYS_RESOURCE CAP_SYS_BOOT ) | |
177 | _values -s , 'capabilities' "$_caps[@]" | |
178 | } | |
179 | ||
180 | _systemd_inhibit_command(){ | |
6af27427 | 181 | if (( CURRENT == 1 )); then |
553b9323 DW |
182 | compset -q |
183 | _normal | |
184 | else | |
185 | local n=${words[(b:2:i)[^-]*]} | |
186 | if (( n <= CURRENT )); then | |
187 | compset -n $n | |
188 | _alternative \ | |
189 | 'files:file:_files' \ | |
190 | 'commands:command:_normal' && return 0 | |
191 | fi | |
192 | _default | |
193 | fi | |
194 | ||
195 | } | |
196 | ||
197 | _systemd_analyze_command(){ | |
198 | local -a _systemd_analyze_cmds | |
96de7c04 | 199 | # Descriptions taken from systemd-analyze --help. |
553b9323 | 200 | _systemd_analyze_cmds=( |
96de7c04 ZJS |
201 | 'time:Print time spent in the kernel before reaching userspace' |
202 | 'blame:Print list of running units ordered by time to init' | |
203 | 'critical-chain:Print a tree of the time critical chain of units' | |
204 | 'plot:Output SVG graphic showing service initialization' | |
205 | 'dot:Dump dependency graph (in dot(1) format)' | |
553b9323 DW |
206 | ) |
207 | ||
208 | if (( CURRENT == 1 )); then | |
209 | _describe "options" _systemd_analyze_cmds | |
210 | else | |
211 | _message "no more options" | |
212 | fi | |
213 | } | |
214 | ||
215 | _hosts_or_user_at_host() | |
216 | { | |
217 | _alternative \ | |
218 | 'users-hosts:: _user_at_host' \ | |
219 | 'hosts:: _hosts' | |
220 | } | |
221 | ||
222 | _outputmodes() { | |
223 | local -a _output_opts | |
224 | _output_opts=(short short-monotonic verbose export json json-pretty json-see cat) | |
225 | _describe -t output 'output mode' _output_opts || compadd "$@" | |
553b9323 DW |
226 | } |
227 | ||
228 | _timedatectl_set-timezone(){ | |
229 | local -a _timezones | |
230 | _timezones=( ${(f)"$(_call_program timezones "${service}" list-timezones)"} ) | |
231 | compadd "$_timezones[@]" | |
232 | } | |
233 | ||
234 | _timedatectl_set-time(){ | |
235 | _message "YYYY-MM-DD HH:MM:SS" | |
236 | } | |
237 | ||
238 | _timedatectl_set-local-rtc(){ | |
239 | local -a _options | |
240 | _options=( | |
241 | '0:Maintain RTC in universal time' | |
242 | '1:Maintain RTC in local time' | |
243 | ) | |
244 | _describe options _options | |
245 | } | |
246 | ||
247 | _timedatectl_set-ntp(){ | |
248 | local -a _options | |
249 | _options=( | |
250 | '0:Disable NTP based network time configuration' | |
251 | '1:Enable NTP based network time configuration' | |
252 | ) | |
253 | _describe options _options | |
254 | } | |
255 | ||
256 | _timedatectl_command(){ | |
257 | local -a _timedatectl_cmds | |
258 | _timedatectl_cmds=( | |
259 | 'status:Show current time settings' | |
260 | 'set-time:Set system time' | |
261 | 'set-timezone:Set system timezone' | |
262 | 'list-timezones:Show known timezones' | |
263 | 'set-local-rtc:Control whether RTC is in local time' | |
264 | 'set-ntp:Control whether NTP is enabled' | |
265 | ) | |
266 | if (( CURRENT == 1 )); then | |
267 | _describe -t commands 'timedatectl command' _timedatectl_cmds | |
268 | else | |
269 | local curcontext="$curcontext" | |
270 | cmd="${${_timedatectl_cmds[(r)$words[1]:*]%%:*}}" | |
271 | if (( $#cmd )); then | |
272 | if (( $+functions[_timedatectl_$cmd] )); then | |
273 | _timedatectl_$cmd | |
274 | else | |
275 | _message "no more options" | |
276 | fi | |
277 | else | |
278 | _message "unknown timedatectl command: $words[1]" | |
279 | fi | |
280 | fi | |
281 | } | |
553b9323 | 282 | |
80d39fbb WG |
283 | (( $+functions[_machinectl_command] )) || _machinectl_command() |
284 | { | |
285 | local -a _machinectl_cmds | |
286 | _machinectl_cmds=( | |
287 | "list:List currently running VMs/containers" | |
288 | "status:Show VM/container status" | |
289 | "show:Show properties of one or more VMs/containers" | |
290 | "terminate:Terminate one or more VMs/containers" | |
291 | "kill:Send signal to process or a VM/container" | |
292 | ) | |
293 | if (( CURRENT == 1 )); then | |
294 | _describe -t commands 'machinectl command' _machinectl_cmds || compadd "$@" | |
295 | else | |
296 | local curcontext="$curcontext" | |
297 | cmd="${${_machinectl_cmds[(r)$words[1]:*]%%:*}}" | |
298 | if (( $#cmd )); then | |
299 | case $cmd in | |
300 | list) msg="no options" ;; | |
301 | *) | |
302 | _machines=( "${(foa)$(machinectl list | awk '{print $1}')}" ) | |
303 | if [[ -n "$_machines" ]]; then | |
304 | _describe 'machines' _machines | |
305 | else | |
306 | _message 'no machines' | |
307 | fi | |
308 | esac | |
309 | else | |
310 | _message "no more options" | |
311 | fi | |
312 | fi | |
313 | } | |
314 | ||
553b9323 DW |
315 | _udevadm_info(){ |
316 | _arguments \ | |
317 | '--query=[Query the database for specified type of device data. It needs the --path or --name to identify the specified device.]:type:(name symlink path property all)' \ | |
318 | '--path=[The devpath of the device to query.]:sys files:_files -P /sys/ -W /sys' \ | |
319 | '--name=[The name of the device node or a symlink to query]:device files:_files -P /dev/ -W /dev' \ | |
320 | '--root[Print absolute paths in name or symlink query.]' \ | |
321 | '--attribute-walk[Print all sysfs properties of the specified device that can be used in udev rules to match the specified device]' \ | |
322 | '--export[Print output as key/value pairs.]' \ | |
323 | '--export-prefix=[Add a prefix to the key name of exported values.]:prefix' \ | |
324 | '--device-id-of-file=[Print major/minor numbers of the underlying device, where the file lives on.]:files:_udevadm_mounts' \ | |
325 | '--export-db[Export the content of the udev database.]' \ | |
326 | '--cleanup-db[Cleanup the udev database.]' | |
327 | } | |
328 | ||
329 | _udevadm_trigger(){ | |
330 | _arguments \ | |
331 | '--verbose[Print the list of devices which will be triggered.]' \ | |
332 | '--dry-run[Do not actually trigger the event.]' \ | |
333 | '--type=[Trigger a specific type of devices.]:types:(devices subsystems failed)' \ | |
334 | '--action=[Type of event to be triggered.]:actions:(add change remove)' \ | |
335 | '--subsystem-match=[Trigger events for devices which belong to a matching subsystem.]' \ | |
336 | '--subsystem-nomatch=[Do not trigger events for devices which belong to a matching subsystem.]' \ | |
337 | '--attr-match=attribute=[Trigger events for devices with a matching sysfs attribute.]' \ | |
338 | '--attr-nomatch=attribute=[Do not trigger events for devices with a matching sysfs attribute.]' \ | |
339 | '--property-match=[Trigger events for devices with a matching property value.]' \ | |
340 | '--tag-match=property[Trigger events for devices with a matching tag.]' \ | |
341 | '--sysname-match=[Trigger events for devices with a matching sys device name.]' \ | |
342 | '--parent-match=[Trigger events for all children of a given device.]' | |
343 | } | |
344 | ||
345 | _udevadm_settle(){ | |
346 | _arguments \ | |
347 | '--timeout=[Maximum number of seconds to wait for the event queue to become empty.]' \ | |
348 | '--seq-start=[Wait only for events after the given sequence number.]' \ | |
349 | '--seq-end=[Wait only for events before the given sequence number.]' \ | |
350 | '--exit-if-exists=[Stop waiting if file exists.]:files:_files' \ | |
351 | '--quiet[Do not print any output, like the remaining queue entries when reaching the timeout.]' \ | |
352 | '--help[Print help text.]' | |
353 | } | |
354 | ||
355 | _udevadm_control(){ | |
356 | _arguments \ | |
357 | '--exit[Signal and wait for systemd-udevd to exit.]' \ | |
358 | '--log-priority=[Set the internal log level of systemd-udevd.]:priorities:(err info debug)' \ | |
359 | '--stop-exec-queue[Signal systemd-udevd to stop executing new events. Incoming events will be queued.]' \ | |
360 | '--start-exec-queue[Signal systemd-udevd to enable the execution of events.]' \ | |
361 | '--reload[Signal systemd-udevd to reload the rules files and other databases like the kernel module index.]' \ | |
362 | '--property=[Set a global property for all events.]' \ | |
363 | '--children-max=[Set the maximum number of events.]' \ | |
364 | '--timeout=[The maximum number of seconds to wait for a reply from systemd-udevd.]' \ | |
365 | '--help[Print help text.]' | |
366 | } | |
6af27427 | 367 | |
553b9323 DW |
368 | _udevadm_monitor(){ |
369 | _arguments \ | |
370 | '--kernel[Print the kernel uevents.]' \ | |
371 | '--udev[Print the udev event after the rule processing.]' \ | |
372 | '--property[Also print the properties of the event.]' \ | |
57277cbe | 373 | '--subsystem-match=[Filter events by subsystem/\[devtype\].]' \ |
553b9323 DW |
374 | '--tag-match=[Filter events by property.]' \ |
375 | '--help[Print help text.]' | |
376 | } | |
377 | ||
378 | _udevadm_test(){ | |
379 | _arguments \ | |
380 | '--action=[The action string.]:actions:(add change remove)' \ | |
381 | '--subsystem=[The subsystem string.]' \ | |
382 | '--help[Print help text.]' \ | |
383 | '*::devpath:_files -P /sys/ -W /sys' | |
384 | } | |
385 | ||
386 | _udevadm_test-builtin(){ | |
387 | if (( CURRENT == 2 )); then | |
388 | _arguments \ | |
389 | '--help[Print help text]' \ | |
c4b5cf87 | 390 | '*::builtins:(blkid btrfs hwdb input_id kmod path_id usb_id uaccess)' |
553b9323 DW |
391 | elif (( CURRENT == 3 )); then |
392 | _arguments \ | |
393 | '--help[Print help text]' \ | |
394 | '*::syspath:_files -P /sys -W /sys' | |
395 | else | |
396 | _arguments \ | |
397 | '--help[Print help text]' | |
398 | fi | |
399 | } | |
400 | ||
401 | _udevadm_mounts(){ | |
402 | local dev_tmp dpath_tmp mp_tmp mline | |
403 | ||
404 | tmp=( "${(@f)$(< /etc/mtab)}" ) | |
405 | dev_tmp=( "${(@)${(@)tmp%% *}:#none}" ) | |
406 | mp_tmp=( "${(@)${(@)tmp#* }%% *}" ) | |
407 | ||
408 | local MATCH | |
409 | mp_tmp=("${(@q)mp_tmp//(#m)\\[0-7](#c3)/${(#)$(( 8#${MATCH[2,-1]} ))}}") | |
410 | dpath_tmp=( "${(@Mq)dev_tmp:#/*}" ) | |
411 | dev_tmp=( "${(@q)dev_tmp:#/*}" ) | |
412 | ||
413 | _alternative \ | |
414 | 'device-paths: device path:compadd -a dpath_tmp' \ | |
415 | 'directories:mount point:compadd -a mp_tmp' | |
416 | } | |
417 | ||
418 | ||
419 | _udevadm_command(){ | |
420 | local -a _udevadm_cmds | |
421 | _udevadm_cmds=( | |
422 | 'info:query sysfs or the udev database' | |
423 | 'trigger:request events from the kernel' | |
424 | 'settle:wait for the event queue to finish' | |
425 | 'control:control the udev daemon' | |
426 | 'monitor:listen to kernel and udev events' | |
427 | 'test:test an event run' | |
428 | 'test-builtin:test a built-in command' | |
429 | ) | |
430 | ||
431 | if ((CURRENT == 1)); then | |
432 | _describe -t commands 'udevadm commands' _udevadm_cmds | |
433 | else | |
434 | local curcontext="$curcontext" | |
435 | cmd="${${_udevadm_cmds[(r)$words[1]:*]%%:*}}" | |
436 | if (($#cmd)); then | |
437 | if (( $+functions[_udevadm_$cmd] )); then | |
438 | _udevadm_$cmd | |
439 | else | |
440 | _message "no options for $cmd" | |
441 | fi | |
442 | else | |
443 | _message "no more options" | |
444 | fi | |
445 | fi | |
446 | } | |
447 | ||
448 | _ctls "$@" | |
449 | ||
450 | #vim: set ft=zsh sw=4 ts=4 et |