diff --git a/ubuntu/scripts/cleanup.sh b/ubuntu/scripts/cleanup.sh
index e8957450..61e5af41 100644
--- a/ubuntu/scripts/cleanup.sh
+++ b/ubuntu/scripts/cleanup.sh
@@ -1,4 +1,4 @@
-#!/bin/bash -e
+#!/bin/bash -ex
#
# cleanup.sh - Remove cache and install artifacts
#
@@ -18,6 +18,7 @@
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
+export DEBIAN_FRONTEND=noninteractive
apt-get autoremove --purge -yq
apt-get clean -yq
diff --git a/ubuntu/scripts/cloudimg/cleanup.sh b/ubuntu/scripts/cloudimg/cleanup.sh
index 0d2fd31c..996e1b07 100644
--- a/ubuntu/scripts/cloudimg/cleanup.sh
+++ b/ubuntu/scripts/cloudimg/cleanup.sh
@@ -1,4 +1,4 @@
-#!/bin/bash -e
+#!/bin/bash -ex
#
# cleanup.sh - Clean up what we did to be able to build the image.
#
diff --git a/ubuntu/scripts/cloudimg/install-custom-kernel.sh b/ubuntu/scripts/cloudimg/install-custom-kernel.sh
index d8a26888..a1926011 100755
--- a/ubuntu/scripts/cloudimg/install-custom-kernel.sh
+++ b/ubuntu/scripts/cloudimg/install-custom-kernel.sh
@@ -1,4 +1,4 @@
-#!/bin/bash -e
+#!/bin/bash -ex
#
# install-custom-kernel.sh - Install custom kernel, if specified
#
diff --git a/ubuntu/scripts/cloudimg/setup-boot.sh b/ubuntu/scripts/cloudimg/setup-boot.sh
index 9b26087b..8cd36d1d 100644
--- a/ubuntu/scripts/cloudimg/setup-boot.sh
+++ b/ubuntu/scripts/cloudimg/setup-boot.sh
@@ -1,4 +1,4 @@
-#!/bin/bash -e
+#!/bin/bash -ex
#
# setup-boot.sh - Set up the image after initial boot
#
@@ -17,6 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
+export DEBIAN_FRONTEND=noninteractive
# Configure apt proxy if needed.
packer_apt_proxy_config="/etc/apt/apt.conf.d/packer-proxy.conf"
diff --git a/ubuntu/scripts/cloudimg/setup-curtin.sh b/ubuntu/scripts/cloudimg/setup-curtin.sh
index 98b2ff16..145d8d35 100755
--- a/ubuntu/scripts/cloudimg/setup-curtin.sh
+++ b/ubuntu/scripts/cloudimg/setup-curtin.sh
@@ -1,4 +1,4 @@
-#!/bin/bash -e
+#!/bin/bash -ex
#
# cloud-img-setup-curtin.sh - Set up curtin curthooks, if needed.
#
diff --git a/ubuntu/scripts/curtin.sh b/ubuntu/scripts/curtin.sh
index 4505247e..2d605dfd 100644
--- a/ubuntu/scripts/curtin.sh
+++ b/ubuntu/scripts/curtin.sh
@@ -1,4 +1,4 @@
-#!/bin/bash -e
+#!/bin/bash -ex
#
# curtin.sh - Move curtin scripts to final destination
#
@@ -19,6 +19,8 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
+export DEBIAN_FRONTEND=noninteractive
+
apt-get install -y jq
mkdir -p /curtin
diff --git a/ubuntu/scripts/install-custom-packages b/ubuntu/scripts/install-custom-packages
index 00189567..ade9a941 100644
--- a/ubuntu/scripts/install-custom-packages
+++ b/ubuntu/scripts/install-custom-packages
@@ -1,4 +1,4 @@
-#!/bin/bash -e
+#!/bin/bash -ex
#
# install-custom-packages - Install custom packages
#
diff --git a/ubuntu/scripts/networking.sh b/ubuntu/scripts/networking.sh
index 9f0539ac..5a165467 100644
--- a/ubuntu/scripts/networking.sh
+++ b/ubuntu/scripts/networking.sh
@@ -1,4 +1,4 @@
-#!/bin/bash -e
+#!/bin/bash -ex
#
# networking.sh - Prepare image to boot with cloud-init
#
@@ -18,6 +18,7 @@
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
+export DEBIAN_FRONTEND=noninteractive
apt-get install -qy netplan.io cloud-init
diff --git a/ubuntu/scripts/setup-bootloader b/ubuntu/scripts/setup-bootloader
index 54efbf7b..f679b67b 100644
--- a/ubuntu/scripts/setup-bootloader
+++ b/ubuntu/scripts/setup-bootloader
@@ -1,4 +1,4 @@
-#!/bin/bash -e
+#!/bin/bash -ex
#
# setup-bootloader - Install bootloader in the boot disk
#