summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@open-infrastructure.net>2018-05-03 09:57:10 +0000
committerDaniel Baumann <daniel.baumann@open-infrastructure.net>2018-05-03 09:57:58 +0000
commit7034bdfaf3e91b132ca0b68167570e4ed9384e2f (patch)
tree9fd2b0322aa7d91e16ccd00634896337630787ce
parentRemoving suite reference in examples of container-create-debconf manpage. (diff)
downloadcompute-tools-7034bdfaf3e91b132ca0b68167570e4ed9384e2f.tar.xz
compute-tools-7034bdfaf3e91b132ca0b68167570e4ed9384e2f.zip
Adding -v, --verbose option to container-create command to be used e.g. when mass-creating new containers in a row.
Signed-off-by: Daniel Baumann <daniel.baumann@open-infrastructure.net>
-rwxr-xr-xlib/container/create23
-rw-r--r--share/bash-completion/container2
-rw-r--r--share/man/container-create.1.txt3
3 files changed, 24 insertions, 4 deletions
diff --git a/lib/container/create b/lib/container/create
index 5878e7e..2ffcfda 100755
--- a/lib/container/create
+++ b/lib/container/create
@@ -29,8 +29,8 @@ SCRIPTS="/usr/share/container-tools/scripts"
Parameters ()
{
- GETOPT_LONGOPTIONS="name:,cnt.container-server:,cnt.overlay:,bind:,bind-ro:,capability:,drop-capability:script:,"
- GETOPT_OPTIONS="n:,b:,c:,d:,s:,"
+ GETOPT_LONGOPTIONS="name:,cnt.container-server:,cnt.overlay:,bind:,bind-ro:,capability:,drop-capability:script:,verbose,"
+ GETOPT_OPTIONS="n:,b:,c:,d:,s:,v,"
PARAMETERS="$(getopt --longoptions ${GETOPT_LONGOPTIONS} --name=${COMMAND} --options ${GETOPT_OPTIONS} --shell sh -- ${@})"
@@ -90,6 +90,11 @@ Parameters ()
shift 2
;;
+ -v|--verbose)
+ VERBOSE="true"
+ shift 1
+ ;;
+
--)
shift 1
break
@@ -105,7 +110,7 @@ Parameters ()
Usage ()
{
- echo "Usage: container ${COMMAND} -n|--name NAME [--cnt.container-server=true|false|FQDN] [--cnt.overlay=DIRECTORY_LOWER:DIRECTORY_UPPER:DIRECTORY_WORK:DIRECTORY_MERGED] [-b|--bind DIRECTORY:DIRECTORY[:OPTIONS]] [--bind-ro DIRECTORY:DIRECTORY[:OPTIONS]] [-c|--capability CAPABILITY[,CAPABILITY]] [-d|--drop-capability DROP_CAPABILITY[,DROP_CAPABILITY]] [-s|--script SCRIPT] [-- SCRIPT_OPTIONS]" >&2
+ echo "Usage: container ${COMMAND} -n|--name NAME [--cnt.container-server=true|false|FQDN] [--cnt.overlay=DIRECTORY_LOWER:DIRECTORY_UPPER:DIRECTORY_WORK:DIRECTORY_MERGED] [-b|--bind DIRECTORY:DIRECTORY[:OPTIONS]] [--bind-ro DIRECTORY:DIRECTORY[:OPTIONS]] [-c|--capability CAPABILITY[,CAPABILITY]] [-d|--drop-capability DROP_CAPABILITY[,DROP_CAPABILITY]] [-s|--script SCRIPT] [-v|--verbose] [-- SCRIPT_OPTIONS]" >&2
exit 1
}
@@ -152,6 +157,18 @@ else
fi
fi
+case "${VERBOSE}" in
+ true)
+
+cat << EOF
+################################################################################
+Creating container: ${NAME}
+################################################################################
+EOF
+
+ ;;
+esac
+
CNT_CONTAINER_SERVER="${CNT_CONTAINER_SERVER:-$(hostname -f)}"
# Pre hooks
diff --git a/share/bash-completion/container b/share/bash-completion/container
index 0a9af1a..29643c2 100644
--- a/share/bash-completion/container
+++ b/share/bash-completion/container
@@ -76,7 +76,7 @@ _container()
;;
*)
- opts="-n --name -c --capability -d --drop-capability -s --script -b --bind --bind-ro"
+ opts="-n --name -c --capability -d --drop-capability -s --script -v --verbose -b --bind --bind-ro"
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
;;
diff --git a/share/man/container-create.1.txt b/share/man/container-create.1.txt
index 6ffc867..d21bd58 100644
--- a/share/man/container-create.1.txt
+++ b/share/man/container-create.1.txt
@@ -55,6 +55,9 @@ The following container-create options are available:
*-s, --script='SCRIPT'*::
Specify container creation script, defaults to debootstrap.
+*-v, --verbose*::
+ Explain what is being done.
+
*-b, --bind='DIRECTORY:DIRECTORY[:OPTIONS][;DIRECTORY:DIRECTORY[:OPTIONS]]'*::
Specify container read-write bind mounts, see systemd-nspawn(1) --bind option.