commit 34495a389b269e78b619993c8fc940fb43070c2b Author: Patrick Balsiger Date: Mon Apr 21 11:19:02 2025 +0200 Initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..03c1662 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +.packer_cache + +.terraform/ +terraform.tfstate +terraform.tfstate.backup diff --git a/ctl.sh b/ctl.sh new file mode 100755 index 0000000..cf965a2 --- /dev/null +++ b/ctl.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash + +function info { + echo "PI-Lab Utils" +} + +function build { + docker run --rm --privileged \ + -v /dev:/dev \ + -v ${PWD}:/build mkaczanowski/packer-builder-arm:latest \ + build packer/raspios.pkr.hcl +} + +${@:-info} diff --git a/packer/raspios.pkr.hcl b/packer/raspios.pkr.hcl new file mode 100644 index 0000000..45736e1 --- /dev/null +++ b/packer/raspios.pkr.hcl @@ -0,0 +1,46 @@ +source "arm" "raspios-arm64" { + file_urls = ["https://downloads.raspberrypi.com/raspios_lite_arm64/images/raspios_lite_arm64-2024-11-19/2024-11-19-raspios-bookworm-arm64-lite.img.xz"] + file_checksum_url = "https://downloads.raspberrypi.com/raspios_lite_arm64/images/raspios_lite_arm64-2024-11-19/2024-11-19-raspios-bookworm-arm64-lite.img.xz.sha256" + file_checksum_type = "sha256" + file_target_extension = "xz" + file_unarchive_cmd = ["xz", "--decompress", "$ARCHIVE_PATH"] + image_build_method = "resize" + image_path = "raspios-arm64.img" + image_size = "4G" + image_type = "dos" + + image_partitions { + name = "boot" + type = "c" + start_sector = "8192" + filesystem = "vfat" + size = "256M" + mountpoint = "/boot" + } + + image_partitions { + name = "root" + type = "83" + start_sector = "532480" + filesystem = "ext4" + size = "0" + mountpoint = "/" + } + + image_chroot_env = ["PATH=/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin"] + qemu_binary_source_path = "/usr/bin/qemu-aarch64-static" + qemu_binary_destination_path = "/usr/bin/qemu-aarch64-static" +} + +build { + sources = ["source.arm.raspios-arm64"] + + provisioner "shell" { + inline = [ + "touch /boot/ssh.txt", + "echo 'pi:$6$c70VpvPsVNCG0YR5$l5vWWLsLko9Kj65gcQ8qvMkuOoRkEagI90qi3F/Y7rm8eNYZHW8CY6BOIKwMH7a3YYzZYL90zf304cAHLFaZE0' > /boot/userconf.txt", + "apt update", + "apt upgrade -y" + ] + } +}