From d883681bba408af3553b2a32c2bdfb1aeec58840 Mon Sep 17 00:00:00 2001 From: Yurii Smetanka Date: Sat, 19 Oct 2024 18:01:11 +0200 Subject: [PATCH] Fixing resolving apt repos :( --- .github/workflows/publish.yml | 2 +- builder/bpim4.json.pkr.hcl | 59 ++++++++++++++++++++++++++++++++++- 2 files changed, 59 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index df65d219..4d662172 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -6,7 +6,7 @@ on: jobs: build: name: ${{ matrix.name }} - runs-on: ubuntu-latest + runs-on: buildjet-2vcpu-ubuntu-2204 strategy: matrix: include: diff --git a/builder/bpim4.json.pkr.hcl b/builder/bpim4.json.pkr.hcl index 4dbd47a3..061d1f15 100644 --- a/builder/bpim4.json.pkr.hcl +++ b/builder/bpim4.json.pkr.hcl @@ -24,12 +24,54 @@ source "arm-image" "bpim4-pwnagotchi" { // qemu_binary = "qemu-aarch64-static" qemu_args = ["-r", "6.6.44"] target_image_size = 19969908736 + additional_chroot_mounts = [ + ["/run/systemd"] + ], } build { name = "Banana Pi M4 Zero Pwnagotchi" sources = ["source.arm-image.bpim4-pwnagotchi"] + provisioner "shell" { + inline = [ + # Set DNS servers + // "sudo touch /etc/resolv.conf", + "ls -la /etc", + "cat /etc/resolv.conf", + "echo 'nameserver 8.8.8.8' | sudo tee -a /etc/resolv.conf > /dev/null", + "echo 'nameserver 8.8.4.4' | sudo tee -a /etc/resolv.conf > /dev/null", + + # Optional: Prevent automatic overwriting of resolv.conf + // "sudo chattr +i /etc/resolv.conf || true", # Makes resolv.conf immutable + ] + } + + # Continue with other provisioners + provisioner "shell" { + inline = [ + # Diagnostic Commands + "echo 'Verifying DNS Configuration...'", + "cat /etc/resolv.conf", + "nslookup google.com || { echo 'DNS resolution failed'; exit 1; }", + "ping -c 4 google.com || { echo 'Ping failed'; exit 1; }", + ] + } + + // TODO: figure out why dns is failing + // provisioner "shell" { + // inline = [ + // "echo '>>>-----> updating hosts <-----<<<'", + // "echo \"199.232.138.132 deb.debian.org\n151.101.2.132 security.debian.org\n130.185.239.78 apt.armbian.com\n130.225.254.116 mirrors.dotsrc.org\n46.102.157.202 armbian.systemonachip.net\" | sudo tee -a /etc/hosts" + // ] + // } + + provisioner "shell" { + inline = [ + "sudo apt-get update || (sleep 30 && sudo apt-get update)" + ] + } + provisioner "file" { destination = "/usr/bin/" sources = [ @@ -42,6 +84,11 @@ build { "data/64bit/usr/bin/pwnlib", ] } + provisioner "shell" { + inline = [ + "apt-get update -o Acquire::Retries=3 --allow-releaseinfo-change" + ] + } provisioner "shell" { inline = ["chmod +x /usr/bin/*"] } @@ -68,8 +115,18 @@ build { inline = ["chmod +x /etc/update-motd.d/*"] } provisioner "shell" { - inline = ["apt-get -y --allow-releaseinfo-change update", "apt-get -y dist-upgrade", "apt-get install -y --no-install-recommends ansible"] + inline = [ + "echo '>>>-----> APT UPDATE <-----<<<'", + "apt-get -y --allow-releaseinfo-change update", + "echo '==>-----> APT UPGRADE <-----<=='", + "#apt-get -y upgrade", + "echo '###======]> INSTALLING ANSIBLE <[=====###'", + "apt-get install -y --no-install-recommends ansible" + ] } + // provisioner "shell" { + // inline = ["apt-get -y --allow-releaseinfo-change update", "apt-get -y dist-upgrade", "apt-get install -y --no-install-recommends ansible"] + // } provisioner "ansible-local" { command = "ANSIBLE_FORCE_COLOR=1 PYTHONUNBUFFERED=1 PWN_VERSION=${var.pwn_version} PWN_HOSTNAME=${var.pwn_hostname} ansible-playbook" extra_arguments = ["--extra-vars \"ansible_python_interpreter=/usr/bin/python3\""]