From 93d59c3176876b0990b27375458cf6518459bb07 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 23 Feb 2019 16:36:10 +0100 Subject: Merging upstream version 20190222. Signed-off-by: Daniel Baumann --- share/bash-completion/container | 54 ++++++++++++++++++++++++++++++++++------- 1 file changed, 45 insertions(+), 9 deletions(-) (limited to 'share/bash-completion/container') diff --git a/share/bash-completion/container b/share/bash-completion/container index e117d16..150ff71 100644 --- a/share/bash-completion/container +++ b/share/bash-completion/container @@ -1,8 +1,7 @@ # bash-completion # -# container-tools - Manage systemd-nspawn containers # Copyright (C) 2016 Andreas Kreuzer -# Copyright (C) 2016-2018 Daniel Baumann +# Copyright (C) 2016-2019 Daniel Baumann # # SPDX-License-Identifier: GPL-3.0+ # @@ -64,13 +63,13 @@ _container() create) case "${prev}" in -n|--name) - opts="$(cd /etc/container-tools/debconf 2>/dev/null && ls *.cfg */*.cfg 2>/dev/null | sed -e 's|.*/||g' -e 's|.cfg$||g')" + opts="$(cd /etc/open-infrastructure/container/debconf 2>/dev/null && ls *.cfg */*.cfg 2>/dev/null | sed -e 's|.*/||g' -e 's|.cfg$||g')" COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) return 0 ;; -s|--script) - opts="$(cd /usr/share/container-tools/scripts && find -maxdepth 1 -not -type d -and -not -name 'default' -and -not -name 'debconf' -and -not -name '*.d' -printf '%P\n' | sort)" + opts="$(cd /usr/share/open-infrastructure/container/scripts && find -maxdepth 1 -not -type d -and -not -name 'default' -and -not -name 'debconf' -and -not -name '*.d' -printf '%P\n' | sort)" COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) return 0 ;; @@ -124,7 +123,7 @@ _container() list|ls) case "${prev}" in -h|--host) - opts="true false $(hostname -f)" + opts="true false $(hostname -f 2> /dev/null || hostname)" COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) return 0 ;; @@ -143,6 +142,43 @@ _container() esac ;; + log) + case "${prev}" in + -d|--date) + opts="$(if ls /var/log/open-infrastructure/container.log-*.gz > /dev/null 2>&1; + then \ + zcat /var/log/open-infrastructure/container.log-*.gz | awk '{ print $1 }' | sort -u; \ + fi; \ + if [ -e /var/log/open-infrastructure/container.log ]; \ + then \ + awk '{ print $1 }' /var/log/open-infrastructure/container.log | sort -u; \ + fi) \ + today yesterday" + COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) + return 0 + ;; + + -n|--name) + opts="$(if ls /var/log/open-infrastructure/container.log-*.gz > /dev/null 2>&1; + then \ + zgrep -E '(\-n|\-\-name) ' /var/log/open-infrastructure/container.log-*.gz | sed -e 's|.*-n ||' -e 's|.*--name ||' -e 's| .*$||' | sort -u; \ + fi; \ + if [ -e /var/log/open-infrastructure/container.log ]; \ + then \ + grep -E '(\-n|\-\-name) ' /var/log/open-infrastructure/container.log | sed -e 's|.*-n ||' -e 's|.*--name ||' -e 's| .*$||' | sort -u; \ + fi)" + COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) + return 0 + ;; + + *) + opts="-d --date -n --name" + COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) + return 0 + ;; + esac + ;; + move|mv) case "${prev}" in -o|--old) @@ -191,7 +227,7 @@ _container() esac ;; - start) + start|s) case "${prev}" in -n|--name) opts="$(container list -t -f shell)" @@ -207,7 +243,7 @@ _container() esac ;; - status) + status|st) case "${prev}" in -n|--name) opts="$(container list -t -f shell)" @@ -223,7 +259,7 @@ _container() esac ;; - stop) + stop|t) case "${prev}" in -n|--name) opts="$(container list -s -f shell)" @@ -250,7 +286,7 @@ _container() ;; *) - local commands=$(cd /usr/lib/container-tools/container 2>/dev/null && find * -type f -print) + local commands=$(cd /usr/lib/open-infrastructure/container 2>/dev/null && find * -type f -print) COMPREPLY=( $(compgen -W "${commands}" -- ${cur}) ) return 0 ;; -- cgit v1.2.3