Refactor golden image handling in backup upload process</message>

<message>Update the _set_golden_from_path function to improve the handling of existing golden image files. Replace the existing unlink logic with a more robust method that safely removes files or broken symlinks using the missing_ok parameter. This change enhances the reliability of the backup upload process by ensuring that stale references are properly cleared before setting a new golden image path.
This commit is contained in:
nearxos
2026-02-24 00:19:40 +02:00
parent df180120aa
commit 808fbf5c7c
136 changed files with 407837 additions and 2 deletions

View File

@@ -0,0 +1,4 @@
#!/bin/bash
# Minimal bootstrap script for cloud-init first boot (test).
set -e
echo "[$(date -Iseconds)] test completed" | tee -a /var/log/cloud-init-bootstrap.log

View File

@@ -0,0 +1,19 @@
#!/bin/bash
# Example bootstrap script run by cloud-init at first boot.
# Copy to bootstrap.sh, edit as needed, and place in your portal files (e.g. first-boot/)
# so it is served at http://YOUR_SERVER:5000/files/bootstrap.sh
#
# Cloud-init downloads this and runs it as root. Add your first-boot logic here:
# - Install packages, apply config, run first-boot.sh from this repo, etc.
set -e
echo "[$(date -Iseconds)] Bootstrap script started."
# Example: run the full first-boot flow from your file server (same as user-data-remote-gnss.example)
# FILE_SERVER="http://10.20.50.1:5000/files/first-boot"
# curl -fsSL "$FILE_SERVER/first-boot.sh" -o /tmp/first-boot.sh
# curl -fsSL "$FILE_SERVER/first-boot.conf" -o /tmp/first-boot.conf
# chmod +x /tmp/first-boot.sh
# /tmp/first-boot.sh
echo "[$(date -Iseconds)] Bootstrap script finished."

View File

@@ -0,0 +1,7 @@
# NoCloud meta-data: hostname "guard" and instance id for cloud-init.
# Copy to the boot (FAT32) partition as "meta-data" (same directory as user-data).
# instance-id: guard-01
# Hostname set on first boot
local-hostname: guard

View File

@@ -0,0 +1,35 @@
#cloud-config
# Minimal user-data: download bootstrap.sh from your file server and run it at first boot.
#
# 1. Host bootstrap.sh at a URL reachable from the device on first boot (e.g. your
# provisioning portal or file server). Example: http://10.20.50.1:5000/files/bootstrap.sh
# 2. Copy this file to the boot partition as "user-data" (with meta-data and optional network-config).
# 3. Edit BOOTSTRAP_URL below to match your server (or set it once in the runcmd section).
package_update: true
package_upgrade: false
packages:
- curl
# Ensure SSH is enabled and password auth allowed so you can log in after first boot
write_files:
- path: /etc/ssh/sshd_config.d/99-cloud-init.conf
content: |
PasswordAuthentication yes
PermitRootLogin no
runcmd:
- systemctl enable ssh
- systemctl start ssh
# Download and run bootstrap script (edit URL to match your file server)
- |
BOOTSTRAP_URL="http://10.20.50.1:5000/files/bootstrap.sh"
LOG="/var/log/cloud-init-bootstrap.log"
if ! curl -fsSL "$BOOTSTRAP_URL" -o /tmp/bootstrap.sh 2>>"$LOG" || [ ! -s /tmp/bootstrap.sh ]; then
echo "$(date -Iseconds) ERROR: Failed to download bootstrap.sh from $BOOTSTRAP_URL (file missing or empty)" >> "$LOG"
exit 0
fi
chmod +x /tmp/bootstrap.sh
/tmp/bootstrap.sh
- cloud-init single --name cc_final_message