1 # systemd-nspawn(1) completion -*- shell-script -*-
2 # SPDX-License-Identifier: LGPL-2.1+
4 # This file is part of systemd.
6 # systemd is free software; you can redistribute it and/or modify it
7 # under the terms of the GNU Lesser General Public License as published by
8 # the Free Software Foundation; either version 2.1 of the License, or
9 # (at your option) any later version.
11 # systemd is distributed in the hope that it will be useful, but
12 # WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 # General Public License for more details.
16 # You should have received a copy of the GNU Lesser General Public License
17 # along with systemd; If not, see <http://www.gnu.org/licenses/>.
20 local w word=$1; shift
22 [[ $w = "$word" ]] && return
28 loginctl list-users --no-legend --no-pager | { while read a b; do echo " $b"; done; };
33 systemctl list-units -t slice --no-legend --no-pager --plain | { while read a b; do echo " $a"; done; };
38 machinectl list --full --no-legend --no-pager | { while read a b; do echo " $a"; done; };
43 env | { while read a; do echo " ${a%%=*}"; done; };
48 for name in $(cd /sys/class/net && ls); do
49 [[ "$name" != "lo" ]] && echo "$name"
55 for i in $(systemd-nspawn --rlimit=help 2>/dev/null); do
61 local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
65 [STANDALONE]='-h --help --version --private-network -b --boot --read-only -q --quiet --share-system
66 --keep-unit -n --network-veth -j -x --ephemeral -a --as-pid2 --private-users-chown -U'
67 [ARG]='-D --directory -u --user --uuid --capability --drop-capability --link-journal --bind --bind-ro
68 -M --machine -S --slice -E --setenv -Z --selinux-context -L --selinux-apifs-context
69 --register --network-interface --network-bridge --personality -i --image --tmpfs
70 --volatile --network-macvlan --kill-signal --template --notify-ready --root-hash --chdir
71 --pivot-root --property --private-users --network-namespace-path --network-ipvlan
72 --network-veth-extra --network-zone -p --port --system-call-filter --overlay --overlay-ro
73 --settings --rlimit --hostname --no-new-privileges --oom-score-adjust --cpu-affinity
74 --resolv-conf --timezone --root-hash-sig'
77 _init_completion || return
79 if __contains_word "$prev" ${OPTS[ARG]}; then
81 --directory|-D|--template)
83 comps=$(compgen -S/ -A directory -- "$cur" )
86 comps=$( __get_users )
92 comps='CAP_BLOCK_SUSPEND CAP_IPC_LOCK CAP_MAC_ADMIN CAP_MAC_OVERRIDE CAP_SYS_MODULE CAP_SYS_PACCT CAP_SYS_RAWIO
93 CAP_SYS_TIME CAP_SYSLOG CAP_WAKE_ALARM CAP_NET_ADMIN'
96 comps='CAP_AUDIT_CONTROL CAP_AUDIT_WRITE CAP_CHOWN CAP_DAC_OVERRIDE CAP_DAC_READ_SEARCH CAP_FOWNER CAP_FSETID
97 CAP_IPC_OWNER CAP_KILL CAP_LEASE CAP_LINUX_IMMUTABLE CAP_MKNOD CAP_NET_ADMIN CAP_NET_BIND_SERVICE
98 CAP_NET_BROADCAST CAP_NET_RAW CAP_SETFCAP CAP_SETGID CAP_SETPCAP CAP_SETUID CAP_SYS_ADMIN CAP_SYS_BOOT
99 CAP_SYS_CHROOT CAP_SYS_NICE CAP_SYS_PTRACE CAP_SYS_RESOURCE CAP_SYS_TTY_CONFIG'
102 comps='no auto guest try-guest host try-host'
105 compopt -o nospace -o filenames
106 comps=$(compgen -f -- "$cur" )
110 comps=$(compgen -S/ -A directory -- "$cur" )
113 comps=$( __get_machines )
116 comps=$( __get_slices )
121 --selinux-context|-Z)
124 --selinux-apifs-context|-L)
131 comps=$(__get_interfaces)
143 comps=$( systemd-nspawn --volatile=help 2>/dev/null )
147 comps=$( compgen -A file -- "$cur" )
159 --network-namespace-path)
160 comps=$( compgen -A file -- "$cur" )
163 comps='yes no override trusted'
166 comps=$( __get_rlimit )
181 comps=$( systemd-nspawn --resolv-conf=help 2>/dev/null )
184 comps=$( systemd-nspawn --timezone=help 2>/dev/null )
188 comps=$( compgen -A file -- "$cur" )
191 COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
195 COMPREPLY=( $(compgen -W '${OPTS[*]}' -- "$cur") )
198 complete -F _systemd_nspawn systemd-nspawn