Skip to content

Instantly share code, notes, and snippets.

@rowland007
Created September 5, 2025 15:57
Show Gist options
  • Save rowland007/64b593e3db969f3a81a9782d14d36b18 to your computer and use it in GitHub Desktop.
Save rowland007/64b593e3db969f3a81a9782d14d36b18 to your computer and use it in GitHub Desktop.
Upgrades Proxmox's Debian LXC image to Trixie, updates all packages, and installs Docker and Cloudflared.
#!/bin/bash
# Function to check if the script is running as root
check_root() {
if [ "$EUID" -ne 0 ]; then
echo "Please run as root or use sudo."
exit 1
fi
}
# Function to execute commands and echo status
execute_command() {
echo "Executing: $1"
eval "$1"
if [ $? -ne 0 ]; then
echo "Error occurred while executing: $1"
exit 1
fi
}
# Check if the script is running as root
check_root
# Update and upgrade packages
execute_command "apt update && apt upgrade -y"
execute_command "apt autoclean -y"
execute_command "apt autoremove -y"
# Change bookworm to trixie in sources.list
execute_command "sed -i 's/bookworm/trixie/g' /etc/apt/sources.list"
# Full upgrade
execute_command "apt update && apt full-upgrade -y"
# Final update and cleanup
execute_command "apt update && apt upgrade -y"
execute_command "apt autoclean -y"
execute_command "apt autoremove -y"
# Install required packages
execute_command "apt install -y curl ca-certificates wget"
# Create keyrings directory
execute_command "install -m 0755 -d /etc/apt/keyrings"
# Download Docker GPG key
execute_command "curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc"
# Set permissions for the GPG key
execute_command "chmod a+r /etc/apt/keyrings/docker.asc"
# Add Docker repository to apt
execute_command "echo \"deb [arch=\$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/debian \$(. /etc/os-release && echo \"\$VERSION_CODENAME\") stable\" | tee /etc/apt/sources.list.d/docker.list > /dev/null"
# Install Docker packages
execute_command "apt update && apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin"
execute_command "apt upgrade -y"
execute_command "apt autoclean -y"
execute_command "apt autoremove -y"
# Test Docker installation
execute_command "docker run hello-world"
# Add Cloudflare GPG key
execute_command "mkdir -p --mode=0755 /usr/share/keyrings"
execute_command "curl -fsSL https://pkg.cloudflare.com/cloudflare-main.gpg | tee /usr/share/keyrings/cloudflare-main.gpg >/dev/null"
# Add Cloudflare repo to apt repositories
execute_command "echo 'deb [signed-by=/usr/share/keyrings/cloudflare-main.gpg] https://pkg.cloudflare.com/cloudflared any main' | tee /etc/apt/sources.list.d/cloudflared.list"
# Install cloudflared
execute_command "apt update && apt install -y cloudflared"
echo "Script completed successfully."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment