add packer ubuntu board generator
This commit is contained in:
@@ -11,7 +11,7 @@ errmsg () {
|
||||
|
||||
preflight () {
|
||||
case "${IMAGE_TYPE}" in
|
||||
ubuntu) PACKER_BUILD_FILE="boards/raspberry-pi-4/ubuntu_server_20.04_arm64.json" ;;
|
||||
ubuntu) PACKER_BUILD_FILE="boards/pi-cm4-ubuntu-22.04.2.json" ;;
|
||||
raspbian) PACKER_BUILD_FILE="boards/raspberry-pi/raspios-lite-arm.json" ;;
|
||||
custom)
|
||||
PACKER_BUILD_FILE="${2:-}"
|
||||
@@ -33,7 +33,6 @@ preflight () {
|
||||
}
|
||||
|
||||
build_image () {
|
||||
cd build/packer-builder-arm
|
||||
sudo packer build ${PACKER_BUILD_FILE}
|
||||
}
|
||||
|
||||
|
||||
11
packer/scripts/install-base.sh
Executable file
11
packer/scripts/install-base.sh
Executable file
@@ -0,0 +1,11 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -euxo pipefail
|
||||
|
||||
echo "==> Setting nameserver"
|
||||
echo 'nameserver 8.8.8.8' > /etc/resolv.conf
|
||||
|
||||
echo "==> installing base updates"
|
||||
apt-get -y update
|
||||
apt-get -y install ansible apt-transport-https ca-certificates
|
||||
apt-get -y clean
|
||||
34
packer/setup-env.sh
Normal file
34
packer/setup-env.sh
Normal file
@@ -0,0 +1,34 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -euxo pipefail
|
||||
|
||||
IMAGE_TYPE="${1:-ubuntu}"
|
||||
|
||||
select_image () {
|
||||
case "${IMAGE_TYPE}" in
|
||||
ubuntu)
|
||||
PACKER_BUILD_FILE="boards/pi-cm4-ubuntu-22.04.2.json" ;;
|
||||
REMOTE_IMAGE_URL="$(jq '.builders[0].file_urls' boards/pi-cm4-ubuntu-22.04.2.json | grep https | tr -d ' \"')"
|
||||
|
||||
raspbian) PACKER_BUILD_FILE="boards/raspberry-pi/raspios-lite-arm.json" ;;
|
||||
PACKER_BUILD_FILE="boards/pi-cm4-ubuntu-22.04.2.json" ;;
|
||||
REMOTE_IMAGE_URL="$(jq '.builders[0].file_urls' boards/pi-cm4-ubuntu-22.04.2.json | grep https | tr -d ' \"')"
|
||||
|
||||
custom)
|
||||
PACKER_BUILD_FILE="${2:-}"
|
||||
if [ -z "${PACKER_BUILD_FILE}" ]
|
||||
then
|
||||
errmsg "[!] custom board requires a board file path"
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
errmsg "[!] invalid image type ${IMAGE_TYPE}."
|
||||
errmsg "[!] valid image types are"
|
||||
errmsg " - raspbian"
|
||||
errmsg " - ubuntu"
|
||||
errmsg " - custom path/to/board/file"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
}
|
||||
Reference in New Issue
Block a user