Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add driver_file checksum and prevent download if file already exists #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
This is a little Bash script that configures a Proxmox 7 or 8 server to use Nvidia vGPU's.

For further instructions see my blogpost at https://wvthoog.nl/proxmox-7-vgpu-v3/
For further instructions see my blogpost at https://wvthoog.nl/proxmox-7-vgpu-v3/

### create driver_file checksum

sha256sum NVIDIA-Linux-x86_64-535.104.06-vgpu-kvm.run
4c87bc5da281a268d2dfe9252159dcfb38f7fa832fedfe97568689bd035bf087 NVIDIA-Linux-x86_64-535.104.06-vgpu-kvm.run
51 changes: 30 additions & 21 deletions proxmox-installer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ case $STEP in
run_command "Running APT Dist-Upgrade (...this might take some time)" "info" "apt dist-upgrade -y"
else
echo -e "${YELLOW}[-]${NC} Skipping apt Dist-Upgrade"
fi
fi

# APT installing packages
run_command "Installing packages" "info" "apt install -y git build-essential dkms pve-headers mdevctl megatools"
Expand All @@ -304,12 +304,12 @@ case $STEP in
fi

# Download vgpu-proxmox
rm -rf $HOME/vgpu-proxmox 2>/dev/null
rm -rf $HOME/vgpu-proxmox 2>/dev/null
run_command "Downloading vgpu-proxmox" "info" "git clone https://gitlab.com/polloloco/vgpu-proxmox.git $HOME/vgpu-proxmox"

# Download vgpu_unlock-rs
cd /opt
rm -rf vgpu_unlock-rs 2>/dev/null
rm -rf vgpu_unlock-rs 2>/dev/null
run_command "Downloading vgpu_unlock-rs" "info" "git clone https://github.com/mbilker/vgpu_unlock-rs.git "

# Download and source Rust
Expand All @@ -334,7 +334,7 @@ case $STEP in
echo -e "${GREEN}[+]${NC} Adding vgpu_unlock-rs library"
echo -e "[Service]\nEnvironment=LD_PRELOAD=/opt/vgpu_unlock-rs/target/release/libvgpu_unlock_rs.so" > /etc/systemd/system/nvidia-vgpud.service.d/vgpu_unlock.conf
echo -e "[Service]\nEnvironment=LD_PRELOAD=/opt/vgpu_unlock-rs/target/release/libvgpu_unlock_rs.so" > /etc/systemd/system/nvidia-vgpu-mgr.service.d/vgpu_unlock.conf

# Systemctl
run_command "Systemctl daemon-reload" "info" "systemctl daemon-reload"
run_command "Enable nvidia-vgpud.service" "info" "systemctl enable nvidia-vgpud.service"
Expand Down Expand Up @@ -365,7 +365,7 @@ case $STEP in
else
echo -e "${RED}[!]${NC} Unknown CPU architecture. Unable to configure GRUB"
exit 1
fi
fi
# Update GRUB
run_command "Updating GRUB" "info" "update-grub"
fi
Expand Down Expand Up @@ -411,7 +411,7 @@ case $STEP in
fi
;;

3)
3)
echo ""
echo "Clean vGPU installation"
echo ""
Expand Down Expand Up @@ -451,14 +451,14 @@ case $STEP in

exit 0
;;
4)
4)
echo ""
echo "This will setup a FastAPI-DLS Nvidia vGPU licensing server on this Promox server"
echo "This will setup a FastAPI-DLS Nvidia vGPU licensing server on this Promox server"
echo ""
echo -e "${GREEN}[+]${NC} Licensing vGPU"

configure_fastapi_dls

exit 0
;;
5)
Expand Down Expand Up @@ -506,7 +506,7 @@ case $STEP in
echo -e "${RED}[!]${NC} Unknown CPU architecture."
echo ""
exit 1
fi
fi
echo -n -e "${RED}[!]${NC} IOMMU is disabled. Do you want to continue anyway? (y/n): "
read -r continue_choice
if [ "$continue_choice" != "y" ]; then
Expand Down Expand Up @@ -614,7 +614,7 @@ case $STEP in
echo "No patches available for your vGPU driver version"
exit 1
fi

echo -e "${YELLOW}[-]${NC} Driver version: $driver_filename"

else
Expand Down Expand Up @@ -647,6 +647,7 @@ case $STEP in
driver_url="https://mega.nz/file/wy1WVCaZ#Yq2Pz_UOfydHy8nC_X_nloR4NIFC1iZFHqJN0EiAicU"
fi
driver_filename="NVIDIA-Linux-x86_64-535.104.06-vgpu-kvm.run"
SHA256_CHECKSUM="4c87bc5da281a268d2dfe9252159dcfb38f7fa832fedfe97568689bd035bf087"
driver_patch="535.104.06.patch"
;;
2)
Expand All @@ -655,8 +656,9 @@ case $STEP in
driver_url="$URL"
else
driver_url="https://mega.nz/file/xrNCCAaT#UuUjqRap6urvX4KA1m8-wMTCW5ZwuWKUj6zAB4-NPSo"
fi
fi
driver_filename="NVIDIA-Linux-x86_64-535.54.06-vgpu-kvm.run"
SHA256_CHECKSUM=""
driver_patch="535.54.06.patch"
;;
3)
Expand All @@ -665,8 +667,9 @@ case $STEP in
driver_url="$URL"
else
driver_url="https://mega.nz/file/h6UVwS4a#ieGy_Q28p5v0TGrNCO0BuCFTTqXH9VXO2Jx-fgWTvZc"
fi
fi
driver_filename="NVIDIA-Linux-x86_64-525.85.07-vgpu-kvm.run"
SHA256_CHECKSUM=""
driver_patch="525.85.07.patch"
;;
4)
Expand All @@ -675,8 +678,9 @@ case $STEP in
driver_url="$URL"
else
driver_url="https://mega.nz/file/FzVlRZ4T#-mCwwGee9UVo34NuDuT-kQ-y9kbEswlwu7ii8KnfBbM"
fi
fi
driver_filename="NVIDIA-Linux-x86_64-525.60.12-vgpu-kvm.run"
SHA256_CHECKSUM=""
driver_patch="525.60.12.patch"
;;
*)
Expand All @@ -694,8 +698,11 @@ case $STEP in
;;
esac

# Check if $driver_filename exists
if [ -e "$driver_filename" ]; then
echo -n "$SHA256_CHECKSUM $driver_filename" | sha256sum --check --status
checksum_ok=$?

# Remove old driver file if $driver_filename exists and checksum doesn't match
if [ -e "$driver_filename" ] && [ 0 -ne $checksum_ok ]; then
mv "$driver_filename" "$driver_filename.bak"
echo -e "${YELLOW}[-]${NC} Moved $driver_filename to $driver_filename.bak"
fi
Expand All @@ -705,15 +712,17 @@ case $STEP in
mv "$custom_filename" "$custom_filename.bak"
echo -e "${YELLOW}[-]${NC} Moved $custom_filename to $custom_filename.bak"
fi

# Download and install the selected vGPU driver version
echo -e "${GREEN}[+]${NC} Downloading vGPU $driver_filename host driver using megadl"
megadl "$driver_url"

# Download and install the selected vGPU driver version if not existing already
if [ ! -e "$driver_filename" ]; then
echo -e "${GREEN}[+]${NC} Downloading vGPU $driver_filename host driver using megadl"
megadl "$driver_url"
fi
fi

# Make driver executable
chmod +x $driver_filename

# Patch and install the driver
run_command "Patching driver" "info" "./$driver_filename --apply-patch ~/vgpu-proxmox/$driver_patch"

Expand Down