1 # systemd-nspawn(1) completion -*- shell-script -*-
2 # SPDX-License-Identifier: LGPL-2.1+
4 # This file is part of systemd.
6 # Copyright 2014 Thomas H.P. Andersen
8 # systemd is free software; you can redistribute it and/or modify it
9 # under the terms of the GNU Lesser General Public License as published by
10 # the Free Software Foundation; either version 2.1 of the License, or
11 # (at your option) any later version.
13 # systemd is distributed in the hope that it will be useful, but
14 # WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 # General Public License for more details.
18 # You should have received a copy of the GNU Lesser General Public License
19 # along with systemd; If not, see <http://www.gnu.org/licenses/>.
22 local w word=$1; shift
24 [[ $w = "$word" ]] && return
30 loginctl list-users --no-legend --no-pager | { while read a b; do echo " $b"; done; };
35 systemctl list-units -t slice --no-legend --no-pager | { while read a b; do echo " $a"; done; };
40 machinectl list --no-legend --no-pager | { while read a b; do echo " $a"; done; };
45 env | { while read a; do echo " ${a%%=*}"; done; };
49 { cd /sys/class/net && echo *; } | \
50 while read -d' ' -r name; do
51 [[ "$name" != "lo" ]] && echo "$name"
56 local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
60 [STANDALONE]='-h --help --version --private-network -b --boot --read-only -q --quiet --share-system --keep-unit --network-veth -j'
61 [ARG]='-D --directory -u --user --uuid --capability --drop-capability --link-journal --bind --bind-ro -M --machine
62 -S --slice --setenv -Z --selinux-context -L --selinux-apifs-context --register --network-interface --network-bridge
63 --personality -i --image --tmpfs --volatile
64 --network-macvlan --kill-signal --template
68 _init_completion || return
70 if __contains_word "$prev" ${OPTS[ARG]}; then
72 --directory|-D|--template)
74 comps=$(compgen -S/ -A directory -- "$cur" )
77 comps=$( __get_users )
83 comps='CAP_BLOCK_SUSPEND CAP_IPC_LOCK CAP_MAC_ADMIN CAP_MAC_OVERRIDE CAP_SYS_MODULE CAP_SYS_PACCT CAP_SYS_RAWIO
84 CAP_SYS_TIME CAP_SYSLOG CAP_WAKE_ALARM CAP_NET_ADMIN'
87 comps='CAP_AUDIT_CONTROL CAP_AUDIT_WRITE CAP_CHOWN CAP_DAC_OVERRIDE CAP_DAC_READ_SEARCH CAP_FOWNER CAP_FSETID
88 CAP_IPC_OWNER CAP_KILL CAP_LEASE CAP_LINUX_IMMUTABLE CAP_MKNOD CAP_NET_ADMIN CAP_NET_BIND_SERVICE
89 CAP_NET_BROADCAST CAP_NET_RAW CAP_SETFCAP CAP_SETGID CAP_SETPCAP CAP_SETUID CAP_SYS_ADMIN CAP_SYS_BOOT
90 CAP_SYS_CHROOT CAP_SYS_NICE CAP_SYS_PTRACE CAP_SYS_RESOURCE CAP_SYS_TTY_CONFIG'
93 comps='no auto guest try-guest host try-host'
97 comps=$(compgen -S/ -A directory -- "$cur" )
101 comps=$(compgen -S/ -A directory -- "$cur" )
104 comps=$( __get_machines )
107 comps=$( __get_slices )
112 --selinux-context|-Z)
115 --selinux-apifs-context|-L)
122 comps=$(__get_interfaces)
138 comps=$( compgen -A file -- "$cur" )
149 COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
153 COMPREPLY=( $(compgen -W '${OPTS[*]}' -- "$cur") )
156 complete -F _systemd_nspawn systemd-nspawn