From 632c4cd51760266b414a511c3bf44f3a82b7bfaf Mon Sep 17 00:00:00 2001 From: Philippe Caseiro Date: Tue, 27 Dec 2022 15:26:03 +0100 Subject: [PATCH] fix(recipe): matchbox updating install script --- recipes/alpine/locals.matchbox.pkr.hcl | 4 ++ recipes/alpine/provisionning/matchbox.sh | 46 ++++++++++++++++---- recipes/alpine/templates/one/vm/matchbox.xml | 2 +- 3 files changed, 43 insertions(+), 9 deletions(-) diff --git a/recipes/alpine/locals.matchbox.pkr.hcl b/recipes/alpine/locals.matchbox.pkr.hcl index 808dbf0..683bebe 100644 --- a/recipes/alpine/locals.matchbox.pkr.hcl +++ b/recipes/alpine/locals.matchbox.pkr.hcl @@ -49,6 +49,10 @@ locals { name = "kubectl" action = "install" } + gpg = { + name = "gpg" + action = "install" + } } Vars = { PXE = { diff --git a/recipes/alpine/provisionning/matchbox.sh b/recipes/alpine/provisionning/matchbox.sh index bd16b54..357f763 100644 --- a/recipes/alpine/provisionning/matchbox.sh +++ b/recipes/alpine/provisionning/matchbox.sh @@ -6,25 +6,55 @@ BIN="matchbox" FILENAME="matchbox-v${VERSION}-linux-${ARCH}.tar.gz" URL="https://github.com/poseidon/matchbox/releases/download/v${VERSION}/${FILENAME}" MATCHBOX_DIR="/var/lib/matchbox" -ASSETS_DIR="${MATCHBOX_DIR}/assets" +ASSETS_DIR="${MATCHBOX_DIR}/assets/" MATCHBOX_USER="matchbox" +FL_VERSIONS="current 3374.2.0" + +echo "Downloading matchbox" +cd /tmp +wget -q --show-progress "${URL}" +tar -xzvf "${FILENAME}" +cd ./matchbox-v${VERSION}-linux-${ARCH} echo "Installing matchbox" -cd /tmp -wget "${URL}" -tar -xzvf "${FILENAME}" -cd "matchbox-v${VERSION}-linux-${ARCH}" cp ${BIN} /usr/local/bin + +echo "Installing get-flatcar" cp ./scripts/get-flatcar /usr/local/bin -./scripts/get-flatcar stable current "${ASSETS_DIR}" -./scripts/get-flatcar stable 3374.2.0 "${ASSETS_DIR}" +chmod +x /usr/local/bin/get-flatcar useradd -U "${MATCHBOX_USER}" mkdir -p "${ASSETS_DIR}" -mv ./examples/assets/flatcar "${ASSETS_DIR}" chown -R "${MATCHBOX_USER}:${MATCHBOX_USER}" "${MATCHBOX_DIR}" chown -R "${MATCHBOX_USER}:${MATCHBOX_USER}" "${ASSETS_DIR}" +tout=30 +item=1 +echo "Provisionning matchbox with flatcar images" +echo " * Current stable image (try 1)" +for version in ${FL_VERSIONS}; do + while ! bash -x /usr/local/bin/get-flatcar stable ${version} ${ASSETS_DIR}; do + sleep 1 + echo " * ${version} stable image (try ${item})" + if [ "${tout}" -eq "${item}" ]; then + break + exit 1 + fi + item=$((item+1)) + done +done + +echo " * 3374.2.0 stable image (try 1)" +get-flatcar stable 3374.2.0 "${ASSETS_DIR}" +if [ "${?}" -ne 0 ]; then + sleep 3 + echo " * 3374.2.0 stable image (try 2)" + get-flatcar stable 3374.2.0 "${ASSETS_DIR}" +fi + +chown -R "${MATCHBOX_USER}:${MATCHBOX_USER}" "${ASSETS_DIR}" +ls -lhaR ${ASSETS_DIR} + cp -rp ./scripts/tls /root exit "${?}" \ No newline at end of file diff --git a/recipes/alpine/templates/one/vm/matchbox.xml b/recipes/alpine/templates/one/vm/matchbox.xml index 0d94ca0..2db9d25 100644 --- a/recipes/alpine/templates/one/vm/matchbox.xml +++ b/recipes/alpine/templates/one/vm/matchbox.xml @@ -14,7 +14,7 @@ CONTEXT = [ SSH_PUBLIC_KEY = "$USER[SSH_PUBLIC_KEY]", TOKEN = "YES" ] CPU = "0.2" -DESCRIPTION = "K3S Ready VM" +DESCRIPTION = "Matchbox Ready VM" DISK = [ IMAGE = "<%= image_name %>", IMAGE_UNAME = "<%= user %>",