summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@open-infrastructure.net>2016-05-26 08:56:10 +0000
committerDaniel Baumann <daniel.baumann@open-infrastructure.net>2016-06-03 11:37:20 +0000
commit3f08711ea477461a832285b26bfb017770185825 (patch)
tree792cfcdb32075f49a09cacb1b71b824a69e2a713
parentCorrecting cleanup of temporary debconf files in debconf script. (diff)
downloadcompute-tools-3f08711ea477461a832285b26bfb017770185825.tar.xz
compute-tools-3f08711ea477461a832285b26bfb017770185825.zip
Guessing default container script from /usr/share/container-tools/scripts/default symlink (if existing).
Signed-off-by: Daniel Baumann <daniel.baumann@open-infrastructure.net>
-rwxr-xr-xlib/container/create31
-rw-r--r--share/man/container-create.1.txt4
2 files changed, 30 insertions, 5 deletions
diff --git a/lib/container/create b/lib/container/create
index 0b0aa3a..dea1e76 100755
--- a/lib/container/create
+++ b/lib/container/create
@@ -103,11 +103,34 @@ then
exit 1
fi
-SCRIPT="${SCRIPT:-debian}"
-
-if [ ! -e "/usr/share/container-tools/scripts/${SCRIPT}" ]
+if [ -z "${SCRIPT}" ]
then
- echo "'${SCRIPT}': no such script" >&2
+ if [ -e /usr/share/container-tools/scripts/default ]
+ then
+ TARGET="$(basename $(readlink /usr/share/container-tools/scripts/default))"
+
+ case "${TARGET}" in
+ container-tools_script)
+ TARGET="$(basename $(readlink /etc/alternatives/container-tools_script))"
+ ;;
+ esac
+
+ if [ -e "/usr/share/container-tools/scripts/${TARGET}" ]
+ then
+ SCRIPT="${TARGET}"
+ else
+ echo "default -> '${TARGET}': no such script" >&2
+ exit 1
+ fi
+ else
+ SCRIPT="debian"
+ fi
+else
+ if [ ! -e "/usr/share/container-tools/scripts/${SCRIPT}" ]
+ then
+ echo "'${SCRIPT}': no such script" >&2
+ exit 1
+ fi
fi
CNT_AUTO="${CNT_AUTO:-$(hostname -f)}"
diff --git a/share/man/container-create.1.txt b/share/man/container-create.1.txt
index 2aeffc6..2553569 100644
--- a/share/man/container-create.1.txt
+++ b/share/man/container-create.1.txt
@@ -67,6 +67,9 @@ The following container scripts are available:
*debconf*::
Advanced script to automatically create Debian based container, see container-create-debconf(1).
+*default*::
+ Symlink (if existing) to a container script which is used if no script was specified. On Debian based system this can be managed through update-alternatives(1), i.e. 'sudo update-alternatives --config container-tools_script'.
+
EXAMPLES
--------
@@ -76,7 +79,6 @@ EXAMPLES
*Create example.net container using debconf script:*::
sudo container create -n example.net -s debconf
-
SEE ALSO
--------
container-tools(7),