summaryrefslogtreecommitdiffstats
path: root/share/scripts/curl
diff options
context:
space:
mode:
Diffstat (limited to 'share/scripts/curl')
-rwxr-xr-xshare/scripts/curl89
1 files changed, 83 insertions, 6 deletions
diff --git a/share/scripts/curl b/share/scripts/curl
index 9b92800..62ce9be 100755
--- a/share/scripts/curl
+++ b/share/scripts/curl
@@ -157,13 +157,50 @@ else
fi
ARCHITECTURE="${ARCHITECTURE:-$(dpkg --print-architecture)}"
-SYSTEM="${SYSTEM:-debian-stretch-current_${ARCHITECTURE}.system.tar.${COMPRESSION}}"
-SETUP="${SETUP:-$(echo ${SYSTEM} | sed -e 's|.system.tar.|.setup.tar.|')}"
SERVER="${SERVER:-https://files.open-infrastructure.net/system/container/debian}"
PASSWORD="${PASSWORD:-$(dd if=/dev/urandom bs=12 count=1 2> /dev/null | base64)}"
VERSION="$(container version)"
+export SERVER
+
+Debconf ()
+{
+ # Configure local debconf
+ 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
+}
+
# Pre hooks
for FILE in "${HOOKS}/pre-${SCRIPT}".* "${HOOKS}/${NAME}.pre-${SCRIPT}"
do
@@ -175,12 +212,8 @@ done
# Run
-# FIXME: Show available image directories on server
-# FIXME: Fetch debconf-choices.txt to show debconf select
# FIXME: default server via configuration file
-mkdir -p "${CACHE}"
-
CURL_OPTIONS=""
if curl -V | grep -qs http2
@@ -188,6 +221,50 @@ then
CURL_OPTIONS="${CURL_OPTIONS} --http2"
fi
+if [ -z "${SYSTEM}" ]
+then
+ # Downloading container list
+ if curl --fail --head --output /dev/null --silent "${SERVER}/container-list.txt"
+ then
+ mkdir -p /tmp/container-tools
+ DEBCONF_TMPDIR="$(mktemp -d -p /tmp/container-tools -t $(basename ${0}).XXXX)"
+ export DEBCONF_TMPDIR
+
+ echo "Downloading $(echo ${SERVER} | awk -F/ '{ print $3 }') container list"
+ curl --fail --location --progress-bar --user-agent container-tools/${VERSION} ${CURL_OPTIONS} \
+ "${SERVER}/container-list.txt" -o "${DEBCONF_TMPDIR}/container-list.txt"
+
+ umask 0022
+
+ Debconf
+
+ # Run debconf parts
+ for DEBCONF_SCRIPT in /usr/share/container-tools/scripts/curl.d/*
+ do
+ if [ -x "${DEBCONF_SCRIPT}" ]
+ then
+ # FIXME
+ # debconf -ocontainer-tools "${DEBCONF_SCRIPT}"
+ "${DEBCONF_SCRIPT}"
+ fi
+ done
+
+ # Read-in configuration from debconf
+ . "${DEBCONF_TMPDIR}/debconf.default"
+
+ SYSTEM="${SYSTEM}.${COMPRESSION}"
+
+ # 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
+ fi
+fi
+
+# Downloading container files
+mkdir -p "${CACHE}"
+
+SETUP="${SETUP:-$(echo ${SYSTEM} | sed -e 's|.system.tar.|.setup.tar.|')}"
+
for FILE in "${SYSTEM}" "${SYSTEM}.gpg" "${SYSTEM}.sha512" \
"${SETUP}" "${SETUP}.gpg" "${SETUP}.sha512"
do