ProxMenux/scripts/install_coral_pve.sh

113 lines
3.8 KiB
Bash
Raw Permalink Normal View History

2025-01-31 18:43:05 +01:00
#!/bin/bash
2025-02-02 12:30:02 +01:00
2025-01-31 18:43:05 +01:00
# ProxMenu - A menu-driven script for Proxmox VE management
# ==========================================================
# Author : MacRimi
# Copyright : (c) 2024 MacRimi
# License : MIT (https://raw.githubusercontent.com/MacRimi/ProxMenux/main/LICENSE)
# Version : 1.0
# Last Updated: 28/01/2025
# ==========================================================
# Description:
# This script installs the Coral TPU drivers on the Proxmox VE host.
# It ensures that necessary packages are installed and compiles the
# Coral TPU drivers for proper functionality.
# ==========================================================
# Configuration ============================================
2025-02-02 10:13:00 +01:00
REPO_URL="https://raw.githubusercontent.com/MacRimi/ProxMenux/main"
2025-01-31 18:43:05 +01:00
BASE_DIR="/usr/local/share/proxmenux"
2025-02-02 10:13:00 +01:00
UTILS_FILE="$BASE_DIR/utils.sh"
2025-01-31 18:43:05 +01:00
VENV_PATH="/opt/googletrans-env"
2025-02-02 10:13:00 +01:00
if [[ -f "$UTILS_FILE" ]]; then
source "$UTILS_FILE"
2025-01-31 18:43:05 +01:00
fi
2025-01-31 22:20:53 +01:00
load_language
2025-02-02 10:13:00 +01:00
initialize_cache
2025-05-05 00:20:09 +02:00
2025-01-31 18:43:05 +01:00
# ==========================================================
# Prompt before installation
pre_install_prompt() {
2025-02-02 12:30:02 +01:00
if ! whiptail --title "$(translate 'Coral TPU Installation')" --yesno "$(translate 'Installing Coral TPU drivers requires rebooting the server after installation. Do you want to proceed?')" 10 70; then
msg_warn "$(translate 'Installation cancelled by user.')"
2025-01-31 18:43:05 +01:00
exit 0
fi
}
2025-02-02 12:30:02 +01:00
# Verify and configure repositories on the host
2025-01-31 18:43:05 +01:00
verify_and_add_repos() {
2025-02-02 12:30:02 +01:00
msg_info "$(translate 'Configuring necessary repositories on the host...')"
2025-01-31 18:43:05 +01:00
sleep 2
if ! grep -q "pve-no-subscription" /etc/apt/sources.list /etc/apt/sources.list.d/* 2>/dev/null; then
echo "deb http://download.proxmox.com/debian/pve $(lsb_release -sc) pve-no-subscription" | tee /etc/apt/sources.list.d/pve-no-subscription.list
2025-02-02 12:30:02 +01:00
msg_ok "$(translate 'pve-no-subscription repository added.')"
2025-01-31 18:43:05 +01:00
fi
if ! grep -q "non-free-firmware" /etc/apt/sources.list; then
echo "deb http://deb.debian.org/debian $(lsb_release -sc) main contrib non-free-firmware
deb http://deb.debian.org/debian $(lsb_release -sc)-updates main contrib non-free-firmware
deb http://security.debian.org/debian-security $(lsb_release -sc)-security main contrib non-free-firmware" | tee -a /etc/apt/sources.list
2025-02-02 12:30:02 +01:00
msg_ok "$(translate 'non-free-firmware repositories added.')"
2025-01-31 18:43:05 +01:00
fi
2025-02-02 12:30:02 +01:00
msg_ok "$(translate 'Added repositories')"
sleep 2
2025-01-31 18:43:05 +01:00
2025-02-02 12:30:02 +01:00
msg_info "$(translate 'Verifying repositories...')"
apt-get update &>/dev/null
2025-01-31 18:43:05 +01:00
2025-02-02 12:30:02 +01:00
msg_ok "$(translate 'Verified and updated repositories.')"
2025-01-31 18:43:05 +01:00
}
# Function to install Coral TPU drivers on the host
install_coral_host() {
2025-06-10 14:27:09 +02:00
show_proxmenux_logo
2025-01-31 18:43:05 +01:00
verify_and_add_repos
2025-01-31 18:53:29 +01:00
apt-get install -y git devscripts dh-dkms dkms pve-headers-$(uname -r) >/dev/null 2>&1
2025-01-31 18:43:05 +01:00
cd /tmp
rm -rf gasket-driver
git clone https://github.com/google/gasket-driver.git
if [ $? -ne 0 ]; then
2025-02-02 12:30:02 +01:00
msg_error "$(translate 'Error: Could not clone the repository.')"
2025-01-31 18:43:05 +01:00
exit 1
fi
cd gasket-driver/
debuild -us -uc -tc -b
if [ $? -ne 0 ]; then
2025-02-02 12:30:02 +01:00
msg_error "$(translate 'Error: Failed to build driver packages.')"
2025-01-31 18:43:05 +01:00
exit 1
fi
dpkg -i ../gasket-dkms_*.deb
if [ $? -ne 0 ]; then
2025-02-02 12:30:02 +01:00
msg_error "$(translate 'Error: Failed to install the driver packages.')"
2025-01-31 18:43:05 +01:00
exit 1
fi
2025-02-02 12:30:02 +01:00
msg_ok "$(translate 'Coral TPU drivers installed successfully on the host.')"
2025-01-31 18:43:05 +01:00
}
# Prompt for reboot after installation
restart_prompt() {
2025-02-02 12:30:02 +01:00
if whiptail --title "$(translate 'Coral TPU Installation')" --yesno "$(translate 'The installation requires a server restart to apply changes. Do you want to restart now?')" 10 70; then
#echo -ne "\r${TAB}${YW}-$(translate 'Restarting the server...') ${CL}"
msg_warn "$(translate 'Restarting the server...')"
2025-01-31 18:43:05 +01:00
reboot
fi
}
# Main logic
pre_install_prompt
install_coral_host
restart_prompt