aboutsummaryrefslogtreecommitdiff
path: root/packer/scripts/install-prerequisites.sh
diff options
context:
space:
mode:
Diffstat (limited to 'packer/scripts/install-prerequisites.sh')
-rw-r--r--packer/scripts/install-prerequisites.sh33
1 files changed, 33 insertions, 0 deletions
diff --git a/packer/scripts/install-prerequisites.sh b/packer/scripts/install-prerequisites.sh
new file mode 100644
index 0000000..43880b9
--- /dev/null
+++ b/packer/scripts/install-prerequisites.sh
@@ -0,0 +1,33 @@
+#!/bin/bash
+
+test "${EUID}" -ne 0 && printf "%s\n" "run as root" && exit 1
+
+if ! command -v apt-get &>/dev/null; then
+ printf "%s\n" "[err] distribution not debian-based"
+ exit 1
+fi
+
+export DEBIAN_FRONTEND=noninteractive
+export NEEDRESTART_SUSPEND=1
+apt-get update
+apt-get install -y \
+ curl ca-certificates gpg lsb-release \
+ lsb-release xorriso qemu-system-x86
+
+curl -sSL https://apt.releases.hashicorp.com/gpg | gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg
+printf "%s" "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | tee /etc/apt/sources.list.d/hashicorp.list
+apt-get update
+apt-get install -y packer
+
+hash -r
+
+plugins=$(packer plugins installed)
+
+if ! printf "%s\n" "${plugins}" | grep -qi qemu; then
+ packer plugins install github.com/hashicorp/qemu
+ printf "%s\n" "[inf] installed packer qemu plugin"
+else
+ printf "%s\n" "[inf] packer qemu plugin already installed"
+fi
+
+curl -fsSL https://get.docker.com | bash