Some checks failed
Test / test (push) Has been cancelled
Co-authored-by: Cursor <cursoragent@cursor.com>
89 lines
2.2 KiB
Bash
Executable File
89 lines
2.2 KiB
Bash
Executable File
#!/bin/bash
|
|
source ~/.bashrc
|
|
# Download Ubuntu Cloud-Init Image for Proxmox Template
|
|
|
|
set -e
|
|
|
|
# Colors
|
|
GREEN='\033[0;32m'
|
|
YELLOW='\033[1;33m'
|
|
BLUE='\033[0;34m'
|
|
NC='\033[0m'
|
|
|
|
log_info() {
|
|
echo -e "${GREEN}[INFO]${NC} $1"
|
|
}
|
|
|
|
log_step() {
|
|
echo -e "${BLUE}[STEP]${NC} $1"
|
|
}
|
|
|
|
# Ubuntu versions
|
|
UBUNTU_24_04_URL="https://cloud-images.ubuntu.com/releases/24.04/release/ubuntu-24.04-server-cloudimg-amd64.img"
|
|
UBUNTU_22_04_URL="https://cloud-images.ubuntu.com/releases/22.04/release/ubuntu-22.04-server-cloudimg-amd64.img"
|
|
|
|
VERSION="${1:-24.04}"
|
|
DOWNLOAD_DIR="${2:-./downloads}"
|
|
|
|
main() {
|
|
echo "========================================="
|
|
echo "Download Ubuntu Cloud-Init Image"
|
|
echo "========================================="
|
|
echo ""
|
|
|
|
case "$VERSION" in
|
|
24.04)
|
|
URL="$UBUNTU_24_04_URL"
|
|
FILENAME="ubuntu-24.04-server-cloudimg-amd64.img"
|
|
;;
|
|
22.04)
|
|
URL="$UBUNTU_22_04_URL"
|
|
FILENAME="ubuntu-22.04-server-cloudimg-amd64.img"
|
|
;;
|
|
*)
|
|
echo "Error: Unsupported version. Use 22.04 or 24.04"
|
|
exit 1
|
|
;;
|
|
esac
|
|
|
|
mkdir -p "$DOWNLOAD_DIR"
|
|
OUTPUT="$DOWNLOAD_DIR/$FILENAME"
|
|
|
|
log_step "Downloading Ubuntu $VERSION Cloud Image..."
|
|
log_info "URL: $URL"
|
|
log_info "Output: $OUTPUT"
|
|
echo ""
|
|
|
|
if [ -f "$OUTPUT" ]; then
|
|
log_info "File already exists: $OUTPUT"
|
|
read -p "Overwrite? (y/N): " -n 1 -r
|
|
echo
|
|
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
|
|
log_info "Skipping download"
|
|
exit 0
|
|
fi
|
|
fi
|
|
|
|
# Download with progress
|
|
if command -v wget &> /dev/null; then
|
|
wget --progress=bar:force -O "$OUTPUT" "$URL"
|
|
elif command -v curl &> /dev/null; then
|
|
curl -L --progress-bar -o "$OUTPUT" "$URL"
|
|
else
|
|
log_error "Neither wget nor curl found"
|
|
exit 1
|
|
fi
|
|
|
|
log_info "✓ Download complete: $OUTPUT"
|
|
echo ""
|
|
log_info "Next steps:"
|
|
log_info " 1. Upload to Proxmox storage"
|
|
log_info " 2. Convert to template"
|
|
log_info " 3. Use for cloning VMs"
|
|
echo ""
|
|
log_info "See: docs/proxmox-ubuntu-images.md for details"
|
|
}
|
|
|
|
main "$@"
|
|
|