Skip to content

Agent Mesh

Fix script downloads and unattended-upgrades

Antonio Ojea8d9fc375b79e
diff --git a/scripts/provision-scale-vm.sh b/scripts/provision-scale-vm.sh
index d8fb520d..a699a8d5 100755
--- a/scripts/provision-scale-vm.sh
+++ b/scripts/provision-scale-vm.sh
@@ -33,6 +33,14 @@ if [ -n "$GCS_URL" ]; then
gcloud storage cp /tmp/sam-node "$GCS_URL/sam-node"
gcloud storage cp /tmp/sam-box "$GCS_URL/sam-box"
+ echo "Uploading rootfs.ext4 and launch script to GCS..."
+ if [ ! -f "rootfs.ext4" ]; then
+ echo "WARNING: rootfs.ext4 not found in current directory! Please run build-rootfs.sh first."
+ else
+ gcloud storage cp rootfs.ext4 "$GCS_URL/rootfs.ext4"
+ fi
+ gcloud storage cp scripts/launch-microvms.sh "$GCS_URL/launch-microvms.sh"
+
METADATA="enable-osconfig=TRUE,sam-binaries-url=$GCS_URL"
fi
diff --git a/scripts/startup-script.sh b/scripts/startup-script.sh
index 257f3822..443f6c64 100644
--- a/scripts/startup-script.sh
+++ b/scripts/startup-script.sh
@@ -5,6 +5,10 @@ set -e
exec > >(tee -a /var/log/startup-script.log) 2>&1
echo "Starting SAM Host VM bootstrap..."
+# Kill unattended-upgrades to avoid apt lock
+systemctl stop unattended-upgrades.service || true
+killall unattended-upgrades || true
+
# 1. Update and install packages
apt-get update
apt-get upgrade -y
@@ -44,6 +48,8 @@ if [ -n "$BIN_URL" ] && [ "$BIN_URL" != "null" ]; then
# Download the pre-built MicroVM rootfs
mkdir -p /opt/microvm
gcloud storage cp "$BIN_URL/rootfs.ext4" /opt/microvm/rootfs.ext4
+ # Download the launch script
+ gcloud storage cp "$BIN_URL/launch-microvms.sh" /opt/microvm/launch-microvms.sh
else
echo "No custom binaries specified. Installing latest release from github..."
export SAM_INSTALL_DIR=/usr/local/bin
@@ -54,8 +60,7 @@ fi
mkdir -p /opt/microvm
curl --retry 5 --retry-connrefused --retry-delay 5 -fsSL -o /opt/microvm/vmlinux.bin https://s3.amazonaws.com/spec.ccfc.min/img/quickstart_guide/x86_64/kernels/vmlinux.bin
-# Download the launch script from the repo
-curl --retry 5 --retry-connrefused --retry-delay 5 -fsSL -o /opt/microvm/launch-microvms.sh https://raw.githubusercontent.com/google/sam/main/scripts/launch-microvms.sh || echo "Failed to download launch script"
-chmod +x /opt/microvm/launch-microvms.sh
+# Ensure launch script is executable (if it was downloaded via GCS)
+chmod +x /opt/microvm/launch-microvms.sh || true
echo "SAM Host bootstrap finished successfully."