1
0
mirror of synced 2026-05-04 23:35:26 +00:00

2006-01-06 14:44:54 by steve

The xen-delete-image script now takes hostnames upon the command line, no
 need for a '--hostname' parameter.  It also allows multiple deletions at
 once.
This commit is contained in:
steve
2006-01-06 14:44:54 +00:00
parent 77d9a0464e
commit 940f575c43
2 changed files with 76 additions and 86 deletions

View File

@@ -20,7 +20,7 @@
# --
# http://www.steve.org.uk
#
# $Id: xen-tools,v 1.15 2005-12-27 16:07:17 steve Exp $
# $Id: xen-tools,v 1.16 2006-01-06 14:44:54 steve Exp $
#
@@ -129,11 +129,10 @@ complete -F _xen_duplicate_image xen-duplicate-image
#
_xen_delete_image()
{
local cur prev opts base
local cur prev opts base names
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
opts="--dir --hostname --help --manual --version"
#
# First of all the base directory comes from the configuration file.
@@ -141,6 +140,18 @@ _xen_delete_image()
base=`grep ^dir /etc/xen-tools/xen-tools.conf | awk -F'= ' '{print $2}'`
base=${base}/domains/
#
# If we have a base which isn't empty then find all the hosts
#
if [[ ${base} != '/domains/' ]]; then
names=$(for x in `ls -1 ${base}`; do echo -n "${x} " ; done )
fi
#
# Complete the options + all available hostnames.
#
opts="--dir --help --manual --version ${names}"
case "${prev}" in
--dir)
_filedir -d
@@ -148,16 +159,14 @@ _xen_delete_image()
;;
--hostname)
if [[ ${base} != '/domains/' ]] ; then
local names=$(for x in `ls -1 ${base}`; do echo ${x} ; done )
COMPREPLY=( $(compgen -W "${names}" -- ${cur}) )
fi
;;
esac
if [[ ${cur} == -* ]]; then
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
fi
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
}
complete -F _xen_delete_image xen-delete-image