summaryrefslogtreecommitdiffstats
path: root/share/scripts/curl
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@open-infrastructure.net>2016-11-13 17:16:42 +0000
committerDaniel Baumann <daniel.baumann@open-infrastructure.net>2016-11-15 12:19:40 +0000
commit279744cf6e4f6096507953f1c1f956e0b9ed8532 (patch)
tree54c4e59d20cf43c904ee03cb7dfbef5446186e76 /share/scripts/curl
parentUsing https by default in container-images.sh example script. (diff)
downloadcompute-tools-tmp-daniel3.tar.xz
compute-tools-tmp-daniel3.zip
Adding debconf support for image selection in curl container create script (FIXME).tmp-daniel3
Signed-off-by: Daniel Baumann <daniel.baumann@open-infrastructure.net>
Diffstat (limited to 'share/scripts/curl')
-rwxr-xr-xshare/scripts/curl70
1 files changed, 69 insertions, 1 deletions
diff --git a/share/scripts/curl b/share/scripts/curl
index 49d7f71..a7d506c 100755
--- a/share/scripts/curl
+++ b/share/scripts/curl
@@ -100,6 +100,47 @@ Usage ()
exit 1
}
+Debconf ()
+{
+ # Configure local debconf
+ mkdir -p /tmp/container-tools
+ DEBCONF_TMPDIR="$(mktemp -d -p /tmp/container-tools -t $(basename ${0}).XXXX)"
+ export DEBCONF_TMPDIR
+
+ mkdir -p "${DEBCONF_TMPDIR}/debconf"
+
+cat > "${DEBCONF_TMPDIR}/debconf.systemrc" << EOF
+Config: configdb
+Templates: templatedb
+
+Name: config
+Driver: File
+Mode: 644
+Reject-Type: password
+Filename: ${DEBCONF_TMPDIR}/debconf/config.dat
+
+Name: passwords
+Driver: File
+Mode: 600
+Backup: false
+Required: false
+Accept-Type: password
+Filename: ${DEBCONF_TMPDIR}/debconf/passwords.dat
+
+Name: configdb
+Driver: Stack
+Stack: config, passwords
+
+Name: templatedb
+Driver: File
+Mode: 644
+Filename: ${DEBCONF_TMPDIR}/debconf/templates.dat
+EOF
+
+ DEBCONF_SYSTEMRC="${DEBCONF_TMPDIR}/debconf.systemrc"
+ export DEBCONF_SYSTEMRC
+}
+
Parameters "${@}"
if [ -z "${NAME}" ]
@@ -126,13 +167,36 @@ then
fi
ARCHITECTURE="${ARCHITECTURE:-$(dpkg --print-architecture)}"
-IMAGE="${IMAGE:-debian-stretch-${ARCHITECTURE}.tar.xz}"
SERVER="${SERVER:-https://files.open-infrastructure.net/images/container-tools/current}"
PASSWORD="${PASSWORD:-$(dd if=/dev/urandom bs=12 count=1 2> /dev/null | base64)}"
VERSION="$(container version)"
# Run
+if [ -z "${IMAGE}" ]
+then
+ Debconf
+
+ # Run debconf parts
+ for SCRIPT in /usr/share/container-tools/scripts/curl.d/*
+ do
+ if [ -x "${SCRIPT}" ]
+ then
+ # FIXME
+ # debconf -ocontainer-tools "${SCRIPT}"
+ "${SCRIPT}"
+ fi
+ done
+
+ # Read-in configuration from debconf
+ . "${DEBCONF_TMPDIR}/debconf.default"
+fi
+
+if [ -z "${IMAGE}" ]
+then
+ echo "no image selected, doing nothing." >&2
+ exit 1
+fi
# FIXME: Show available image directories on server
# FIXME: Fetch debconf-choices.txt to show debconf select
@@ -202,3 +266,7 @@ case "${CLEAN}" in
rm -f "${CACHE}/${IMAGE}"
;;
esac
+
+# remove debconf temporary files
+rm --preserve-root --one-file-system -rf "${DEBCONF_TMPDIR}"
+rmdir --ignore-fail-on-non-empty /tmp/container-tools 2>&1 || true