commit 6df60caedc74a9ade0d7f878ad644673093e8c49 Author: Kyle Isom Date: Sun Apr 9 18:31:44 2023 -0700 Initial import. diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..55e8110 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +packer/build \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..6334d93 --- /dev/null +++ b/README.md @@ -0,0 +1,5 @@ +# bladerunner + +This is my setup for my +[computeblade](https://publish.obsidian.md/ai6ua/Projects/Computing/ComputeBlade) +cluster, which will theoretically be here around September 2023. diff --git a/packer/Dockerfile b/packer/Dockerfile new file mode 100644 index 0000000..433ef5e --- /dev/null +++ b/packer/Dockerfile @@ -0,0 +1,7 @@ +# Set up a packer image in Docker. +FROM ubuntu:22.04 +MAINTAINER Kyle Isom + +add . packer + +ENTRYPOINT ["/usr/bin/env", "bash"] diff --git a/packer/README.md b/packer/README.md new file mode 100644 index 0000000..b6d8cfc --- /dev/null +++ b/packer/README.md @@ -0,0 +1,9 @@ +# bladerunner/packer + +This directory contains the tooling to build raspberry pi images using +packer. + + +### Resources + +- [Build a Raspberry Pi image with Packer](https://linuxhit.com/build-a-raspberry-pi-image-packer-packer-builder-arm/) diff --git a/packer/install-packer.sh b/packer/install-packer.sh new file mode 100755 index 0000000..bcee371 --- /dev/null +++ b/packer/install-packer.sh @@ -0,0 +1,50 @@ +#!/usr/bin/env bash + +set -eux + +PACKER_VERSION=1.8.6 +INSTALL_DIR=/usr/local/bin +ARCH=amd64 +PACKER_FILE=packer_${PACKER_VERSION}_linux_${ARCH} +UPSTREAM="https://github.com/mkaczanowski/packer-builder-arm" +UPGRADE="false" + +prep () { + mkdir -p build + pushd build +} + +install_packer () { + if [ -x ${INSTALL_DIR}/packer ] + then + return 0 + fi + + curl -LO https://releases.hashicorp.com/packer/${PACKER_VERSION}/${PACKER_FILE}.zip + unzip ${PACKER_FILE} + sudo mv packer ${INSTALL_DIR}/ + rm ${PACKER_FILE}.zip +} + +install_packer_builder_arm () { + if [ -x "${INSTALL_DIR}/packer-builder-arm" -a -z "${UPGRADE}" ] + then + return 0 + fi + + git clone "${UPSTREAM}" + pushd "${UPSTREAM##*/}" + go mod download + go build + sudo mv packer-builder-arm ${INSTALL_DIR}/ + popd +} + +cleanup { + popd +} + +prep +install_packer +install_packer_builder_arm +cleanup diff --git a/tools/install-go.sh b/tools/install-go.sh new file mode 100755 index 0000000..5ecc27d --- /dev/null +++ b/tools/install-go.sh @@ -0,0 +1,50 @@ +#!/usr/bin/env bash + +set -euxo pipefail + +INSTALL_DIR="/usr/local/bin" +GODEB=https://godeb.s3.amazonaws.com/godeb-${ARCH}.tar.gz +GOVERSION=1.20.3 + +preflight () { + + if [ "$(uname -s)" != "Linux" ] + then + echo '[!] godeb is only supported on Linux.' > /dev/stderr + exit 1 + fi + + case "$(uname -m)" in + amd64) ARCH="amd64" ;; + arm64) ARCH="arm64" ;; + *) + echo "[!] $(uname -m) is an unsupported architecture." > /dev/stderr + echo '[!] supported architectures: amd64, arm64' > /dev/stderr + ;; + esac +} + +install_godeb () { + if [ -x "${INSTALL_DIR}/godeb" ] + then + return 0 + fi + + local GODEB_ARCHIVE="${GODEB##*/}" + + pushd /tmp + curl -LO "${GODEB}" + tar xzf "${GODEB_ARCHIVE}" + sudo mv godeb "${INSTALL_DIR}/" + rm "${GODEB_ARCHIVE}" + popd +} + +install_go { + pushd /tmp + echo '[*] installing go - this will request sudo' + godeb install "${GOVERSION}" + # note: deliberately leaving this in /tmp for inspection + # if needed. + popd +}