Try to automatically determine cpu sensor. If not detected ask the user.

This commit is contained in:
Meliox 2023-06-30 12:05:21 +02:00
parent 08c5b83d21
commit a89ad7ad61

View File

@ -15,6 +15,9 @@ cpuPerRow="4";
hddPerRow="4"; hddPerRow="4";
nvmePerRow="4"; nvmePerRow="4";
# Known CPU sensor names. If new are added, also update logic in configure section
knownCpuSensors=("coretemp-isa-0000" "k10temp-pci-00c3")
################### code below ############# ################### code below #############
timestamp=$(date '+%Y-%m-%d_%H-%M-%S') timestamp=$(date '+%Y-%m-%d_%H-%M-%S')
@ -62,10 +65,12 @@ install_packages () {
function configure { function configure {
sensorOutput=$(sensors -j)
# Check if kernal module drivetemp is installed # Check if kernal module drivetemp is installed
if (lsmod | grep -wq "drivetemp"); then if (lsmod | grep -wq "drivetemp"); then
# Check if SDD/HDD data is available # Check if SDD/HDD data is available
if (sensors -j | grep -q "drivetemp-scsi-" ); then if (echo "$sensorOutput" | grep -q "drivetemp-scsi-" ); then
enableHddSsdTemp=true enableHddSsdTemp=true
else else
enableHddSsdTemp=false enableHddSsdTemp=false
@ -75,24 +80,54 @@ function configure {
fi fi
# Check if NVME data is available # Check if NVME data is available
if (sensors -j | grep -q "nvme-" ); then if (echo "$sensorOutput" | grep -q "nvme-" ); then
enableNvmeTemp=true enableNvmeTemp=true
else else
enableNvmeTemp=false enableNvmeTemp=false
fi fi
# Ask user for CPU information # Check if CPU is part of known list for autoconfiguration
# Inform the user and prompt them to press any key to continue for item in "${knownCpuSensors[@]}"; do
read -rsp $'Sensor output will be presented. Press any key to continue...\n' -n1 key case "$sensorOutput" in
*"coretemp-isa-0000"*)
echo "Found known cpu sensor: coretemp-isa-0000"
cpuAddress="coretemp-isa-0000"
cpuItemPrefix="Core"
break
;;
*"k10temp-pci-00c3"*)
echo "Found known cpu sensor: k10temp-pci-00c3"
cpuAddress="k10temp-pci-00c3"
cpuItemPrefix="Tccd"
break
;;
*)
continue
;;
esac
done
# Print the output to the user # If cpu is not known, ask the user for input
echo "Sensor Output:" if [ -z "$cpuItemPrefix" ]; then
sensors -j echo "Warning: Could not automatically determine CPU sensor. Please configure it manually."
# Ask user for CPU information
# Inform the user and prompt them to press any key to continue
read -rsp $'Sensor output will be presented. Press any key to continue...\n' -n1 key
# Prompt the user for adapter name and item name # Print the output to the user
read -p "Enter the cpu adapter name: " cpu_address echo "Sensor Output:"
read -p "Enter the cpu item prefix: " cpu_item_prefix echo "$sensorOutput"
echo "Example: cpu address: coretemp-isa-0000 and cpuItemPrefix Core."
# Prompt the user for adapter name and item name
read -p "Enter the cpu address: " cpuAddress
read -p "Enter the cpu item prefix: " cpuItemPrefix
fi
if [[ -z "$cpuItemPrefix" || -z "$cpuItemPrefix" ]]; then
echo "Warning: The cpu configuration is not set. Temps will not be available"
fi
} }
# Function to install the modification # Function to install the modification
@ -303,13 +338,13 @@ fi
while [[ $# -gt 0 ]]; do while [[ $# -gt 0 ]]; do
case "$1" in case "$1" in
install) install)
echo "Installing the mod..." echo "Installing the proxmox temp mod..."
install_packages install_packages
configure configure
install_mod install_mod
;; ;;
uninstall) uninstall)
echo "Uninstalling the mod..." echo "Uninstalling the proxmox temp mod..."
uninstall_mod uninstall_mod
;; ;;
*) *)