From 3f08711ea477461a832285b26bfb017770185825 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Thu, 26 May 2016 10:56:10 +0200 Subject: Guessing default container script from /usr/share/container-tools/scripts/default symlink (if existing). Signed-off-by: Daniel Baumann --- lib/container/create | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) (limited to 'lib/container/create') 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)}" -- cgit v1.2.3