- vim /etc/cron.daily/lxc-update-template
- chmod +x /etc/cron.daily/lxc-update-template
#!/bin/bash
# =============================================================================
# Script Name: update_lxc_template.sh
# Version: 1.0
# Description: Starts the 'template' LXC container, performs an update &
# upgrade inside it, and shuts it back down after.
# =============================================================================
CONTAINER="template"
echo "[DEBUG] Starting $CONTAINER..."
lxc-start -n "$CONTAINER"
sleep 15 # Let it get networking (adjust if needed)
echo "[DEBUG] Updating packages..."
lxc-attach -n "$CONTAINER" -- bash -c "
export DEBIAN_FRONTEND=noninteractive
apt update && apt -y upgrade && apt -y autoremove
"
echo "[DEBUG] Shutting down $CONTAINER..."
lxc-stop -n "$CONTAINER"
echo "[DEBUG] Done."