]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
bash-completion: nspawn: support recently added options 11147/head
authorYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 13 Dec 2018 18:13:30 +0000 (03:13 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 13 Dec 2018 18:18:33 +0000 (03:18 +0900)
shell-completion/bash/systemd-nspawn

index 2ff39b65d7d181c19cdd3cad1f6da271d8ecf5a6..62bb0ba6056ad3045e6adca0f447edb505a390ce 100644 (file)
@@ -44,13 +44,20 @@ __get_env() {
         env | { while read a; do echo " ${a%%=*}"; done; };
 }
 
-__get_interfaces(){
+__get_interfaces() {
         { cd /sys/class/net && echo *; } | \
         while read -d' ' -r name; 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() {
         local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
         local i verb comps
@@ -62,7 +69,8 @@ _systemd_nspawn() {
                               -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'
+                              --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
@@ -131,7 +139,7 @@ _systemd_nspawn() {
                                 comps='x86 x86-64'
                         ;;
                         --volatile)
-                                comps='yes state no'
+                                comps=$( systemd-nspawn --volatile=help 2>/dev/null )
                         ;;
                         --image|-i)
                                 compopt -o nospace
@@ -153,6 +161,27 @@ _systemd_nspawn() {
                         --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