2022-12-06 15:44:25 +01:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
VERSION=0.9.1
|
|
|
|
ARCH=amd64
|
|
|
|
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"
|
2022-12-27 15:26:03 +01:00
|
|
|
ASSETS_DIR="${MATCHBOX_DIR}/assets/"
|
2022-12-06 15:44:25 +01:00
|
|
|
MATCHBOX_USER="matchbox"
|
2022-12-27 15:26:03 +01:00
|
|
|
FL_VERSIONS="current 3374.2.0"
|
2022-12-06 15:44:25 +01:00
|
|
|
|
2022-12-28 09:51:38 +01:00
|
|
|
apk add wget
|
|
|
|
|
2022-12-27 15:26:03 +01:00
|
|
|
echo "Downloading matchbox"
|
2022-12-06 15:44:25 +01:00
|
|
|
cd /tmp
|
2022-12-27 15:26:03 +01:00
|
|
|
wget -q --show-progress "${URL}"
|
2022-12-06 15:44:25 +01:00
|
|
|
tar -xzvf "${FILENAME}"
|
2022-12-27 15:26:03 +01:00
|
|
|
cd ./matchbox-v${VERSION}-linux-${ARCH}
|
|
|
|
|
|
|
|
echo "Installing matchbox"
|
2022-12-06 15:44:25 +01:00
|
|
|
cp ${BIN} /usr/local/bin
|
2022-12-27 15:26:03 +01:00
|
|
|
|
|
|
|
echo "Installing get-flatcar"
|
2022-12-06 15:44:25 +01:00
|
|
|
cp ./scripts/get-flatcar /usr/local/bin
|
2022-12-27 15:26:03 +01:00
|
|
|
chmod +x /usr/local/bin/get-flatcar
|
2022-12-06 15:44:25 +01:00
|
|
|
|
|
|
|
useradd -U "${MATCHBOX_USER}"
|
|
|
|
mkdir -p "${ASSETS_DIR}"
|
|
|
|
chown -R "${MATCHBOX_USER}:${MATCHBOX_USER}" "${MATCHBOX_DIR}"
|
|
|
|
chown -R "${MATCHBOX_USER}:${MATCHBOX_USER}" "${ASSETS_DIR}"
|
|
|
|
|
2022-12-27 15:26:03 +01:00
|
|
|
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}
|
|
|
|
|
2022-12-06 15:44:25 +01:00
|
|
|
cp -rp ./scripts/tls /root
|
|
|
|
|
|
|
|
exit "${?}"
|