diff options
author | Daniel Baumann <mail@daniel-baumann.ch> | 2016-04-21 17:46:16 +0000 |
---|---|---|
committer | Daniel Baumann <mail@daniel-baumann.ch> | 2016-05-06 12:00:31 +0000 |
commit | 7a0a1f92a6f8fa40d987f3e7c73abae7e790ea35 (patch) | |
tree | e9a2ae82cf38a11c0a4181c31f8fcb31151a79c7 /lib/container/create | |
parent | Adding upstream version 20160301. (diff) | |
download | open-infrastructure-compute-tools-7a0a1f92a6f8fa40d987f3e7c73abae7e790ea35.tar.xz open-infrastructure-compute-tools-7a0a1f92a6f8fa40d987f3e7c73abae7e790ea35.zip |
Adding upstream version 20160401.upstream/20160401
Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
Diffstat (limited to 'lib/container/create')
-rwxr-xr-x | lib/container/create | 34 |
1 files changed, 27 insertions, 7 deletions
diff --git a/lib/container/create b/lib/container/create index d267641..fab9f5b 100755 --- a/lib/container/create +++ b/lib/container/create @@ -1,7 +1,7 @@ #!/bin/sh -# Open Infrastructure: container-tools -# Copyright (C) 2014-2015 Daniel Baumann <daniel.baumann@open-infrastructure.net> +# container-tools - Manage systemd-nspawn containers +# Copyright (C) 2014-2016 Daniel Baumann <daniel.baumann@open-infrastructure.net> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -25,8 +25,8 @@ MACHINES="/var/lib/machines" Parameters () { - LONG_OPTIONS="name:,bind:,script:" - OPTIONS="n:,b:,s:" + LONG_OPTIONS="name:,cnt.autostart:,bind:,capability:,drop-capability:script:" + OPTIONS="n:,b:,c:,d:,s:" PARAMETERS="$(getopt --longoptions ${LONG_OPTIONS} --name=${COMMAND} --options ${OPTIONS} --shell sh -- ${@})" @@ -46,11 +46,26 @@ Parameters () shift 2 ;; + --cnt.autostart) + CNT_AUTOSTART="${2}" + shift 2 + ;; + -b|--bind) BIND="${2}" shift 2 ;; + -c|--capability) + CAPABILITY="${2}" + shift 2 + ;; + + -d|--drop-capability) + DROP_CAPABILITY="${2}" + shift 2 + ;; + -s|--script) SCRIPT="${2}" shift 2 @@ -71,7 +86,7 @@ Parameters () Usage () { - echo "Usage: container ${COMMAND} -n|--name NAME [-b|--bind DIRECTORY:DIRECTORY[:OPTIONS]] [-s|--script SCRIPT] [-- SCRIPT_OPTIONS]" >&2 + echo "Usage: container ${COMMAND} -n|--name NAME [--cnt.autostart=true|false|FQDN] [-b|--bind DIRECTORY:DIRECTORY[:OPTIONS]] [-c|--capability CAPABILITY[,CAPABILITY]] [-d|--drop-capability DROP_CAPABILITY[,DROP_CAPABILITY]] [-s|--script SCRIPT] [-- SCRIPT_OPTIONS]" >&2 exit 1 } @@ -88,13 +103,15 @@ then exit 1 fi -SCRIPT="${SCRIPT:-debootstrap}" +SCRIPT="${SCRIPT:-debian}" if [ ! -e "/usr/share/container-tools/scripts/${SCRIPT}" ] then echo "'${SCRIPT}': no such script" >&2 fi +CNT_AUTOSTART="${CNT_AUTOSTART:-$(hostname -f)}" + BINDS="$(echo ${BIND} | sed -e 's|;| |g')" for ENTRY in ${BINDS} @@ -110,10 +127,13 @@ done # config mkdir -p "${CONFIG}" -sed -e "s|@NAME@|${NAME}|g" \ +sed -e "s|@CNT_AUTOSTART@|${CNT_AUTOSTART}|g" \ + -e "s|@NAME@|${NAME}|g" \ -e "s|@BIND@|${BIND}|g" \ -e "s|@BOOT@|yes|g" \ + -e "s|@CAPABILITY@|${CAPABILITY}|g" \ -e "s|@DIRECTORY@|${MACHINES}/${NAME}|g" \ + -e "s|@DROP_CAPABILITY@|${DROP_CAPABILITY}|g" \ -e "s|@MACHINE@|${NAME}|g" \ -e "s|@NETWORK_VETH@|yes|g" \ -e "s|@NETWORK_BRIDGE@|br0|g" \ |