summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-xshare/scripts/curl83
1 files changed, 58 insertions, 25 deletions
diff --git a/share/scripts/curl b/share/scripts/curl
index 4f575f9..8176991 100755
--- a/share/scripts/curl
+++ b/share/scripts/curl
@@ -147,7 +147,8 @@ else
fi
ARCHITECTURE="${ARCHITECTURE:-$(dpkg --print-architecture)}"
-IMAGE="${IMAGE:-debian-stretch-${ARCHITECTURE}.tar.${COMPRESSION}}"
+IMAGE="${IMAGE:-debian-stretch-${ARCHITECTURE}.system.tar.${COMPRESSION}}"
+SETUP="$(echo ${IMAGE} | 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)}"
@@ -178,22 +179,25 @@ then
CURL_OPTIONS="${CURL_OPTIONS} --http2"
fi
-if [ -e "${CACHE}/${IMAGE}" ]
-then
- CURL_OPTIONS="${CURL_OPTIONS} --time-cond ${CACHE}/${IMAGE}"
-fi
-
-for FILE in "${SERVER}/${IMAGE}" "${SERVER}/${IMAGE}.sha512"
+for FILE in "${IMAGE}" "${IMAGE}.sha512" \
+ "${SETUP}" "${SETUP}.sha512"
do
- if curl --fail --head --output /dev/null --silent "${FILE}"
+ if curl --fail --head --output /dev/null --silent "${SERVER}/${FILE}"
then
- echo "Downloading $(basename ${FILE})"
- curl --fail --location --progress-bar --user-agent container-tools/${VERSION} ${CURL_OPTIONS} \
- "${FILE}" -o "${CACHE}/$(basename ${FILE})"
+ if [ -e "${CACHE}/${FILE}" ]
+ then
+ CURL_TIME_COND="--time-cond ${CACHE}/${FILE}"
+ else
+ CURL_TIME_COND=""
+ fi
+
+ echo "Downloading ${FILE}"
+ curl --fail --location --progress-bar --user-agent container-tools/${VERSION} ${CURL_OPTIONS} ${CURL_TIME_COND} \
+ "${SERVER}/${FILE}" -o "${CACHE}/${FILE}"
fi
done
-for FILE in "${CACHE}/$(basename ${IMAGE})"
+for FILE in "${IMAGE}" "${SETUP}"
do
cd "${CACHE}"
@@ -204,10 +208,10 @@ do
if [ -e "${FILE}.sha512" ]
then
- echo -n "Verifying ${IMAGE}:"
+ echo -n "Verifying ${FILE}:"
set +e
- sha512sum --check "${IMAGE}.sha512" --status
+ sha512sum --check "${FILE}.sha512" --status
SHA512SUM="${?}"
set -e
@@ -226,8 +230,6 @@ do
cd "${OLDPWD}"
done
-mkdir -p "${MACHINES}/${NAME}"
-
case "${IMAGE}" in
*.gz)
TAR_OPTIONS="--gzip"
@@ -260,14 +262,45 @@ case "${IMAGE}" in
;;
esac
-if [ -e /usr/bin/pv ]
+for FILE in "${IMAGE}" "${SETUP}"
+do
+ if [ ! -e "${CACHE}/${FILE}" ]
+ then
+ continue
+ fi
+
+ case "${FILE}" in
+ *.system.tar.*)
+ DIRECTORY="${MACHINES}/${NAME}"
+ ;;
+
+ *.setup.tar.*)
+ DIRECTORY="${MACHINES}/${NAME}/setup"
+ ;;
+ esac
+
+ mkdir -p "${DIRECTORY}"
+
+ if [ -e /usr/bin/pv ]
+ then
+ echo "Unpacking ${FILE}"
+ pv --format '%p' --width 77 "${CACHE}/${FILE}" | tar xf - ${TAR_OPTIONS} -C "${DIRECTORY}" --strip 1
+ else
+ echo -n "Unpacking ${FILE}:"
+ tar xf "${CACHE}/${FILE}" ${TAR_OPTIONS} -C "${DIRECTORY}" --strip 1
+ echo " ok."
+ fi
+done
+
+if [ -x "${MACHINES}/${NAME}/setup/container" ]
then
- echo "Unpacking ${IMAGE}"
- pv --format '%p' --width 77 "${CACHE}/${IMAGE}" | tar xf - ${TAR_OPTIONS} -C "${MACHINES}/${NAME}" --strip 1
-else
- echo -n "Unpacking ${IMAGE}:"
- tar xf "${CACHE}/${IMAGE}" ${TAR_OPTIONS} -C "${MACHINES}/${NAME}" --strip 1
- echo " ok."
+ chroot "${MACHINES}/${NAME}" /usr/bin/env -i \
+ LC_ALL="C" PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games:/usr/games" TERM="${TERM}" \
+ DEBIAN_FRONTEND="dialog" DEBIAN_PRIORITY="low" \
+ DEBCONF_NONINTERACTIVE_SEEN="true" DEBCONF_NOWARNINGS="true" \
+ /setup/container
+
+ rm -rf "${MACHINES}/${NAME}/setup"
fi
# Creating machine-id
@@ -286,8 +319,8 @@ echo "${NAME}: root password set to '${PASSWORD}'."
# Remove cache
case "${CLEAN}" in
true)
- rm -f "${CACHE}/${IMAGE}"
- rm -f "${CACHE}/${IMAGE}.sha512"
+ rm -f "${CACHE}/${IMAGE}" "${CACHE}/${IMAGE}.sha512"
+ rm -f "${CACHE}/${SETUP}" "${CACHE}/${SETUP}.sha512"
;;
esac