Created
June 24, 2024 14:14
-
-
Save bgulla/d13401a19d79f7245bffb4c35338bfe6 to your computer and use it in GitHub Desktop.
Synology ARC on Proxmox Helper Script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Standard disclaimer | |
echo "This script is provided as-is without any warranty. Use it at your own risk. Do not use this script for any illegal activities." | |
# Default values | |
DEFAULT_NAME="synology-arc-test" | |
DEFAULT_MEMORY="4096" | |
DEFAULT_CORES="4" | |
DEFAULT_VM_ID="119" | |
DEFAULT_CPU="x86-64-v2-AES" | |
DEFAULT_ISO_URL="https://github.com/AuxXxilium/arc/releases/download/24.6.23/arc-24.6.23.img.zip" | |
# Function to check if unzip is installed and install it if necessary | |
install_unzip() { | |
if ! command -v unzip &> /dev/null; then | |
echo "unzip could not be found. Installing unzip..." | |
apt-get update | |
apt-get install -y unzip | |
fi | |
} | |
# Ensure unzip is installed | |
install_unzip | |
# Prompt the user for VM name | |
read -p "Enter VM name [${DEFAULT_NAME}]: " VM_NAME | |
VM_NAME=${VM_NAME:-$DEFAULT_NAME} | |
# Prompt the user for memory | |
read -p "Enter memory (MB) [${DEFAULT_MEMORY}]: " MEMORY | |
MEMORY=${MEMORY:-$DEFAULT_MEMORY} | |
# Prompt the user for CPU cores | |
read -p "Enter number of CPU cores [${DEFAULT_CORES}]: " CORES | |
CORES=${CORES:-$DEFAULT_CORES} | |
# Prompt the user for ISO URL | |
read -p "Enter ISO URL [${DEFAULT_ISO_URL}]: " ISO_URL | |
ISO_URL=${ISO_URL:-$DEFAULT_ISO_URL} | |
# Download the ISO | |
ISO_ZIP_FILENAME=$(basename "$ISO_URL") | |
wget -O "/tmp/$ISO_ZIP_FILENAME" "$ISO_URL" | |
# Uncompress the ISO | |
unzip "/tmp/$ISO_ZIP_FILENAME" -d /tmp | |
# Find the uncompressed ISO file | |
ISO_FILENAME=$(find /tmp -type f -name "*.img") | |
# Create the VM | |
qm create $DEFAULT_VM_ID --name $VM_NAME --cores $CORES --memory $MEMORY --net0 virtio,bridge=vmbr0 --ostype l26 --numa 0 --sockets 1 --cpu $DEFAULT_CPU | |
# Import the disk to Proxmox | |
qm importdisk $DEFAULT_VM_ID "$ISO_FILENAME" local-lvm | |
# Add the SCSI Disk | |
qm set $DEFAULT_VM_ID --scsi0 local-lvm:vm-$DEFAULT_VM_ID-disk-0,iothread=on | |
# Configure the SCSI Controller | |
qm set $DEFAULT_VM_ID --scsihw virtio-scsi-single | |
# Add the CD-ROM Drive | |
qm set $DEFAULT_VM_ID --ide2 none,media=cdrom | |
# Set the boot device to scsi0 | |
qm set $DEFAULT_VM_ID --boot order=scsi0 | |
# Clean up | |
rm "/tmp/$ISO_ZIP_FILENAME" | |
rm "$ISO_FILENAME" | |
# Final message | |
echo "VM $VM_NAME with $CORES cores, $MEMORY MB memory created successfully with ID $DEFAULT_VM_ID." | |
echo "The VM has been created. Please add your virtual or physical disks and have fun!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment