From 84de79e829830a2c15f742dacd9c3294cd137448 Mon Sep 17 00:00:00 2001 From: Arthur Zamarin Date: Sat, 27 Apr 2024 20:54:40 +0300 Subject: [PATCH 1/4] shell-completion: add missing args to bash systemd-analyze Signed-off-by: Arthur Zamarin --- shell-completion/bash/systemd-analyze | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/shell-completion/bash/systemd-analyze b/shell-completion/bash/systemd-analyze index eb1061f787..75ea1dc757 100644 --- a/shell-completion/bash/systemd-analyze +++ b/shell-completion/bash/systemd-analyze @@ -67,7 +67,7 @@ _systemd_analyze() { ) local -A VERBS=( - [STANDALONE]='time blame unit-paths exit-status calendar timestamp timespan' + [STANDALONE]='time blame unit-files unit-paths exit-status capability compare-versions calendar timestamp timespan pcrs srk' [CRITICAL_CHAIN]='critical-chain' [DOT]='dot' [DUMP]='dump' @@ -79,11 +79,12 @@ _systemd_analyze() { [INSPECT_ELF]='inspect-elf' [PLOT]='plot' [ARCHITECTURES]='architectures' + [FDSTORE]='fdstore' ) - local CONFIGS='systemd/bootchart.conf systemd/coredump.conf systemd/journald.conf + local CONFIGS='locale.conf systemd/bootchart.conf systemd/coredump.conf systemd/journald.conf systemd/journal-remote.conf systemd/journal-upload.conf systemd/logind.conf - systemd/resolved.conf systemd/networkd.conf systemd/resolved.conf + systemd/resolved.conf systemd/networkd.conf systemd/pstore.conf systemd/resolved.conf systemd/sleep.conf systemd/system.conf systemd/timedated.conf systemd/timesyncd.conf systemd/user.conf udev/udev.conf' @@ -211,6 +212,13 @@ _systemd_analyze() { else comps=$( __get_architectures ) fi + + elif __contains_word "$verb" ${VERBS[FDSTORE]}; then + if [[ $cur = -* ]]; then + comps='--help --version --system --user --global -H --host -M --machine --no-pager --json=off --json=pretty --json=short --root --image' + else + comps=$( __get_services $mode ) + fi fi COMPREPLY=( $(compgen -W '$comps' -- "$cur") ) From 4a06acda25fb895f65ee24c6378cb8db47577c7a Mon Sep 17 00:00:00 2001 From: Arthur Zamarin Date: Sat, 27 Apr 2024 22:00:18 +0300 Subject: [PATCH 2/4] shell-completion: add missing args to bash resolvectl Signed-off-by: Arthur Zamarin --- shell-completion/bash/resolvectl | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/shell-completion/bash/resolvectl b/shell-completion/bash/resolvectl index 1a5febe1e3..344eaad973 100644 --- a/shell-completion/bash/resolvectl +++ b/shell-completion/bash/resolvectl @@ -24,7 +24,7 @@ __contains_word () { done } -__get_interfaces(){ +__get_interfaces() { local name for name in $(cd /sys/class/net && command ls); do [[ "$name" != "lo" ]] && echo "$name" @@ -36,10 +36,10 @@ _resolvectl() { local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]} local -A OPTS=( [STANDALONE]='-h --help --version -4 -6 --legend=no --cname=no - --validate=no --synthesize=no --cache=no --zone=no + --validate=no --synthesize=no --cache=no --relax-single-label=no --zone=no --trust-anchor=no --network=no --service-address=no --service-txt=no --search=no --stale-data=no --no-pager' - [ARG]='-t --type -c --class -i --interface -p --protocol --raw' + [ARG]='-t --type -c --class -i --interface -p --protocol --raw --json' ) local -A VERBS=( [DOMAIN]='query service openpgp' @@ -50,7 +50,7 @@ _resolvectl() { [RESOLVE]='llmnr mdns' [DNSSEC]='dnssec' [DNSOVERTLS]='dnsovertls' - [STANDALONE]='statistics reset-statistics flush-caches reset-server-features show-cache' + [STANDALONE]='statistics reset-statistics flush-caches reset-server-features monitor show-cache show-server-state' [LOG_LEVEL]='log-level' ) local -A ARGS=( @@ -60,14 +60,13 @@ _resolvectl() { [DNSSEC]='yes no allow-downgrade' [DNSOVERTLS]='yes no opportunistic' ) - local interfaces=$( __get_interfaces ) if __contains_word "$prev" ${OPTS[ARG]}; then case $prev in --interface|-i) - comps="$interfaces" + comps=$( __get_interfaces ) ;; - --protocol|-p|--type|-t|--class|-c) + --protocol|-p|--type|-t|--class|-c|--json) comps=$( resolvectl --legend=no "$prev" help; echo help ) ;; --raw) @@ -98,7 +97,7 @@ _resolvectl() { comps='' elif __contains_word "$verb" ${VERBS[STATUS]}; then - comps="$interfaces" + comps=$( __get_interfaces ) elif __contains_word "$verb" ${VERBS[LOG_LEVEL]}; then comps='debug info notice warning err crit alert emerg' @@ -118,6 +117,7 @@ _resolvectl() { fi elif __contains_word "$verb" ${VERBS[LINK]} ${VERBS[BOOLEAN]} ${VERBS[RESOLVE]} ${VERBS[DNSSEC]} ${VERBS[DNSOVERTLS]}; then + local interfaces=$( __get_interfaces ) for ((i++; i < COMP_CWORD; i++)); do if __contains_word "${COMP_WORDS[i]}" $interfaces && ! __contains_word "${COMP_WORDS[i-1]}" ${OPTS[ARG]}; then From 5db2bf1b30c4fb444f6996d0acfd619325a78a60 Mon Sep 17 00:00:00 2001 From: Arthur Zamarin Date: Sat, 27 Apr 2024 22:26:12 +0300 Subject: [PATCH 3/4] shell-completion: add missing args to zsh resolvectl Signed-off-by: Arthur Zamarin --- shell-completion/zsh/_resolvectl | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/shell-completion/zsh/_resolvectl b/shell-completion/zsh/_resolvectl index 94ff3950af..4ca469adcf 100644 --- a/shell-completion/zsh/_resolvectl +++ b/shell-completion/zsh/_resolvectl @@ -48,7 +48,9 @@ domain:"Configure per-interface search and route-only domains" flush-caches:"Flushes all DNS resource record caches the service maintains locally" llmnr:"Configure per-interface llmnr enabled status" + log-level:"Get/set logging threshold for systemd-resolved" mdns:"Configure per-interface mdns enabled status" + monitor:"Monitor DNS queries" nta:"Configure per-interface nta domains" openpgp:"Retrieve openpgp keys for an email" query:"Resolve domain names, IPv4 and IPv6 addresses" @@ -57,6 +59,7 @@ revert:"Revert the per-interfce DNS configuration" service:"Resolve DNS-SD and SRV services" show-cache:"Show the current cache contents" + show-server-state:"Show servers state" statistics:"Show resolver statistics" status:"Show the global and per-link DNS settings currently in effect" tlsa:"Query tlsa public keys stored as TLSA resource records" @@ -81,5 +84,14 @@ _arguments \ '--service-address=[Do not resolve address for services]:BOOL:(yes no)' \ '--service-txt=[Do not resolve TXT records for services]:BOOL:(yes no)' \ '--cname=[Do not follow CNAME redirects]:BOOL:(yes no)' \ + '--validate=[Do not allow DNSSEC validation]:BOOL:(yes no)' \ + '--synthesize=[Do not allow synthetic response]:BOOL:(yes no)' \ + '--cache=[Do not allow response from cache]:BOOL:(yes no)' \ + '--stale-data=[Do not allow response from cache with stale data]:BOOL:(yes no)' \ + '--zone=[Do not allow response from locally registered mDNS/LLMNR records]:BOOL:(yes no)' \ + '--trust-anchor=[Do not allow response from local trust anchor]:BOOL:(yes no)' \ + '--network=[Do not allow response from network]:BOOL:(yes no)' \ '--search=[Do not use search domains]:BOOL:(yes no)' \ + '--raw=[Dump the answer as binary data]:RAW:(payload packet)' \ + '--json=[Output as JSON]:JSON:(pretty short off)' \ '*::default: _resolvectl_commands' From 3b18a8795df525f1e10528f8c056f1e49a1d9bfe Mon Sep 17 00:00:00 2001 From: Arthur Zamarin Date: Wed, 1 May 2024 19:17:40 +0300 Subject: [PATCH 4/4] shell-completion: add bash completion for systemd-vmspawn Signed-off-by: Arthur Zamarin --- shell-completion/bash/systemd-vmspawn | 70 +++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 shell-completion/bash/systemd-vmspawn diff --git a/shell-completion/bash/systemd-vmspawn b/shell-completion/bash/systemd-vmspawn new file mode 100644 index 0000000000..7043ce2c89 --- /dev/null +++ b/shell-completion/bash/systemd-vmspawn @@ -0,0 +1,70 @@ +# shellcheck shell=bash +# systemd-vmspawn(1) completion -*- shell-script -*- +# SPDX-License-Identifier: LGPL-2.1-or-later +# +# This file is part of systemd. +# +# 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 +# the Free Software Foundation; either version 2.1 of the License, or +# (at your option) any later version. +# +# systemd is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with systemd; If not, see . + +__contains_word() { + local w word=$1; shift + for w in "$@"; do + [[ $w = "$word" ]] && return + done +} + +_systemd_vmspawn() { + local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]} words cword + local i verb comps + + local -A OPTS=( + [STANDALONE]='-h --help --version -q --quiet --no-pager -n --network-tap --network-user-mode' + [PATH]='-D --directory -i --image --linux --initrd --extra-drive --forward-journal' + [BOOL]='--kvm --vsock --tpm --secure-boot --discard-disk --register --pass-ssh-key' + [FIRMWARE]='--firmware' + [BIND]='--bind --bind-ro' + [SSH_KEY]='--ssh-key' + [CONSOLE]='--console' + [ARG]='--cpus --ram --vsock-cid -M --machine --uuid--private-users --background --set-credential --load-credential' + ) + + _init_completion || return + + if __contains_word "$prev" ${OPTS[BOOL]}; then + comps='yes no' + elif __contains_word "$prev" ${OPTS[PATH]}; then + compopt -o nospace -o filenames + comps=$(compgen -f -- "$cur" ) + elif __contains_word "$prev" ${OPTS[FIRMWARE]}; then + compopt -o nospace -o filenames + comps="list $(compgen -f -- "$cur" )" + elif __contains_word "$prev" ${OPTS[BIND]}; then + compopt -o nospace -o filenames + comps=$(compgen -f -- "${cur}" ) + elif __contains_word "$prev" ${OPTS[SSH_KEY]}; then + comps='dsa ecdsa ecdsa-sk ed25519 ed25519-sk rsa' + elif __contains_word "$prev" ${OPTS[CONSOLE]}; then + comps='interactive native gui' + elif __contains_word "$prev" ${OPTS[ARG]}; then + comps='' + else + COMPREPLY=( $(compgen -W '${OPTS[*]}' -- "$cur") ) + return 0 + fi + COMPREPLY=( $(compgen -W '$comps' -- "$cur") ) + return 0 + +} + +complete -F _systemd_vmspawn systemd-vmspawn