]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - shell-completion/bash/systemd-nspawn
Merge pull request #11827 from keszybz/pkgconfig-variables
[thirdparty/systemd.git] / shell-completion / bash / systemd-nspawn
index f9b740380c26546e294fa2bf4b8a97aaf20bbd39..3ba2cd6ec948257bd0b619dd1fd10bd16be2d1da 100644 (file)
@@ -1,8 +1,8 @@
 # systemd-nspawn(1) completion                  -*- shell-script -*-
+# SPDX-License-Identifier: LGPL-2.1+
 #
 # This file is part of systemd.
 #
-# Copyright 2014 Thomas H.P. Andersen
 #
 # systemd is free software; you can redistribute it and/or modify it
 # under the terms of the GNU Lesser General Public License as published by
@@ -45,7 +45,17 @@ __get_env() {
 }
 
 __get_interfaces(){
-    cut -f 1 -d ' ' /proc/net/dev | tail -n +3 | tr -s '\n' | tr -d ':' | xargs
+        local name
+        for name in $(cd /sys/class/net && ls); do
+                [[ "$name" != "lo" ]] && echo "$name"
+        done
+}
+
+__get_rlimit() {
+        local i
+        for i in $(systemd-nspawn --rlimit=help 2>/dev/null); do
+                echo " ${i}="
+        done
 }
 
 _systemd_nspawn() {
@@ -53,25 +63,28 @@ _systemd_nspawn() {
         local i verb comps
 
         local -A OPTS=(
-               [STANDALONE]='-h --help --version --private-network -b --boot --read-only -q --quiet --share-system --keep-unit --network-veth -j'
-                      [ARG]='-D --directory -u --user --uuid --capability --drop-capability --link-journal --bind --bind-ro -M --machine
-                             -S --slice --setenv -Z --selinux-context -L --selinux-apifs-context --register --network-interface --network-bridge
-                             --personality -i --image --tmpfs --volatile
-                             --network-macvlan'
+                [STANDALONE]='-h --help --version --private-network -b --boot --read-only -q --quiet --share-system --keep-unit -n --network-veth
+                              -j -x --ephemeral -a --as-pid2 --private-users-chown -U'
+                       [ARG]='-D --directory -u --user --uuid --capability --drop-capability --link-journal --bind --bind-ro -M --machine
+                              -S --slice -E --setenv -Z --selinux-context -L --selinux-apifs-context --register --network-interface --network-bridge
+                              --personality -i --image --tmpfs --volatile --network-macvlan --kill-signal --template --notify-ready --root-hash
+                              --chdir --pivot-root --property --private-users --network-namespace-path --network-ipvlan --network-veth-extra
+                              --network-zone -p --port --system-call-filter --overlay --overlay-ro --settings
+                              --rlimit --hostname --no-new-privileges --oom-score-adjust --cpu-affinity --resolv-conf --timezone'
         )
 
         _init_completion || return
 
         if __contains_word "$prev" ${OPTS[ARG]}; then
                 case $prev in
-                        --directory|-D)
+                        --directory|-D|--template)
                                 compopt -o nospace
                                 comps=$(compgen -S/ -A directory -- "$cur" )
                         ;;
                         --user|-u)
                                 comps=$( __get_users )
                         ;;
-                        --uuid)
+                        --uuid|--root-hash)
                                 comps=''
                         ;;
                         --capability)
@@ -101,7 +114,7 @@ _systemd_nspawn() {
                         --slice|-S)
                                 comps=$( __get_slices )
                         ;;
-                        --setenv)
+                        --setenv|-E)
                                 comps=$( __get_env )
                         ;;
                         --selinux-context|-Z)
@@ -126,12 +139,49 @@ _systemd_nspawn() {
                                 comps='x86 x86-64'
                         ;;
                         --volatile)
-                                comps='yes state no'
+                                comps=$( systemd-nspawn --volatile=help 2>/dev/null )
                         ;;
                         --image|-i)
                                 compopt -o nospace
                                 comps=$( compgen -A file -- "$cur" )
                         ;;
+                        --kill-signal)
+                                _signals
+                                return
+                        ;;
+                        --notify-ready)
+                                comps='yes no'
+                        ;;
+                        --private-users)
+                                comps='yes no pick'
+                        ;;
+                        --network-namespace-path)
+                                comps=$( compgen -A file -- "$cur" )
+                        ;;
+                        --settings)
+                                comps='yes no override trusted'
+                        ;;
+                        --rlimit)
+                                comps=$( __get_rlimit )
+                        ;;
+                        --hostname)
+                                comps=''
+                        ;;
+                        --no-new-privileges)
+                                comps='yes no'
+                        ;;
+                        --oom-score-adjust)
+                                comps=''
+                        ;;
+                        --cpu-affinity)
+                                comps=''
+                        ;;
+                        --resolv-conf)
+                                comps=$( systemd-nspawn --resolv-conf=help 2>/dev/null )
+                        ;;
+                        --timezone)
+                                comps=$( systemd-nspawn --timezone=help 2>/dev/null )
+                        ;;
                 esac
                 COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
                 return 0