1 # systemd-nspawn(1) completion -*- shell-script -*-
2 # SPDX-License-Identifier: LGPL-2.1+
4 # This file is part of systemd.
7 # systemd is free software; you can redistribute it and/or modify it
8 # under the terms of the GNU Lesser General Public License as published by
9 # the Free Software Foundation; either version 2.1 of the License, or
10 # (at your option) any later version.
12 # systemd is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 # General Public License for more details.
17 # You should have received a copy of the GNU Lesser General Public License
18 # along with systemd; If not, see <http://www.gnu.org/licenses/>.
21 local w word=$1; shift
23 [[ $w = "$word" ]] && return
29 loginctl list-users --no-legend --no-pager | { while read a b; do echo " $b"; done; };
34 systemctl list-units -t slice --no-legend --no-pager | { while read a b; do echo " $a"; done; };
39 machinectl list --no-legend --no-pager | { while read a b; do echo " $a"; done; };
44 env | { while read a; do echo " ${a%%=*}"; done; };
49 for name in $(cd /sys/class/net && ls); do
50 [[ "$name" != "lo" ]] && echo "$name"
56 for i in $(systemd-nspawn --rlimit=help 2>/dev/null); do
62 local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
66 [STANDALONE]='-h --help --version --private-network -b --boot --read-only -q --quiet --share-system --keep-unit -n --network-veth
67 -j -x --ephemeral -a --as-pid2 --private-users-chown -U'
68 [ARG]='-D --directory -u --user --uuid --capability --drop-capability --link-journal --bind --bind-ro -M --machine
69 -S --slice -E --setenv -Z --selinux-context -L --selinux-apifs-context --register --network-interface --network-bridge
70 --personality -i --image --tmpfs --volatile --network-macvlan --kill-signal --template --notify-ready --root-hash
71 --chdir --pivot-root --property --private-users --network-namespace-path --network-ipvlan --network-veth-extra
72 --network-zone -p --port --system-call-filter --overlay --overlay-ro --settings
73 --rlimit --hostname --no-new-privileges --oom-score-adjust --cpu-affinity --resolv-conf --timezone'
76 _init_completion || return
78 if __contains_word "$prev" ${OPTS[ARG]}; then
80 --directory|-D|--template)
82 comps=$(compgen -S/ -A directory -- "$cur" )
85 comps=$( __get_users )
91 comps='CAP_BLOCK_SUSPEND CAP_IPC_LOCK CAP_MAC_ADMIN CAP_MAC_OVERRIDE CAP_SYS_MODULE CAP_SYS_PACCT CAP_SYS_RAWIO
92 CAP_SYS_TIME CAP_SYSLOG CAP_WAKE_ALARM CAP_NET_ADMIN'
95 comps='CAP_AUDIT_CONTROL CAP_AUDIT_WRITE CAP_CHOWN CAP_DAC_OVERRIDE CAP_DAC_READ_SEARCH CAP_FOWNER CAP_FSETID
96 CAP_IPC_OWNER CAP_KILL CAP_LEASE CAP_LINUX_IMMUTABLE CAP_MKNOD CAP_NET_ADMIN CAP_NET_BIND_SERVICE
97 CAP_NET_BROADCAST CAP_NET_RAW CAP_SETFCAP CAP_SETGID CAP_SETPCAP CAP_SETUID CAP_SYS_ADMIN CAP_SYS_BOOT
98 CAP_SYS_CHROOT CAP_SYS_NICE CAP_SYS_PTRACE CAP_SYS_RESOURCE CAP_SYS_TTY_CONFIG'
101 comps='no auto guest try-guest host try-host'
105 comps=$(compgen -S/ -A directory -- "$cur" )
109 comps=$(compgen -S/ -A directory -- "$cur" )
112 comps=$( __get_machines )
115 comps=$( __get_slices )
120 --selinux-context|-Z)
123 --selinux-apifs-context|-L)
130 comps=$(__get_interfaces)
142 comps=$( systemd-nspawn --volatile=help 2>/dev/null )
146 comps=$( compgen -A file -- "$cur" )
158 --network-namespace-path)
159 comps=$( compgen -A file -- "$cur" )
162 comps='yes no override trusted'
165 comps=$( __get_rlimit )
180 comps=$( systemd-nspawn --resolv-conf=help 2>/dev/null )
183 comps=$( systemd-nspawn --timezone=help 2>/dev/null )
186 COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
190 COMPREPLY=( $(compgen -W '${OPTS[*]}' -- "$cur") )
193 complete -F _systemd_nspawn systemd-nspawn