From dc4804b632eb097879c8d1bf63c82f45fa07188a Mon Sep 17 00:00:00 2001 From: rmm Date: Thu, 16 May 2024 18:58:07 +0200 Subject: [PATCH 01/12] Add missing text if no HDD/SSD sensors found. --- pve-mod-gui-sensors.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/pve-mod-gui-sensors.sh b/pve-mod-gui-sensors.sh index 9ab2b9c..aa2acf5 100644 --- a/pve-mod-gui-sensors.sh +++ b/pve-mod-gui-sensors.sh @@ -145,6 +145,7 @@ function configure { enableHddTemp=false fi else + warn "No HDD/SSD temperature sensors found." enableHddTemp=false fi From 9198ffe6cd0871c7750f6468c7f56a8ec5fd8518 Mon Sep 17 00:00:00 2001 From: Meliox <5264368+Meliox@users.noreply.github.com> Date: Sat, 25 May 2024 09:35:16 +0200 Subject: [PATCH 02/12] Inform user to clear browser cache after successfull installation (#40) --- pve-mod-gui-sensors.sh | 4 +++- readme.md | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/pve-mod-gui-sensors.sh b/pve-mod-gui-sensors.sh index 153e15a..19eca23 100644 --- a/pve-mod-gui-sensors.sh +++ b/pve-mod-gui-sensors.sh @@ -669,6 +669,8 @@ Ext.define('PVE.mod.TempHelper', {\n\ restart_proxy msg "Installation completed" + + msg "Clear the browser cache to ensure all changes are visualized." else warn "Sensor display items already added to the summary panel in \"$pvemanagerlibjs\"." fi @@ -735,4 +737,4 @@ done # If no arguments were provided or all arguments have been processed, print the usage message if [[ $executed -eq 0 ]]; then usage -fi +fi \ No newline at end of file diff --git a/readme.md b/readme.md index bd2614a..da77c5d 100644 --- a/readme.md +++ b/readme.md @@ -22,8 +22,10 @@ For HDDs/SSDs readings to work, the kernel module *drivetemp* must be installed. ``` apt-get install lm-sensors wget https://raw.githubusercontent.com/Meliox/PVE-mods/main/pve-mod-gui-sensors.sh +bash pve-mod-gui-sensors.sh ``` Or use git clone. +Then clear the browser cache to ensure all changes are visualized. ![Promxox temp mod](https://github.com/Meliox/PVE-mods/blob/main/pve-mod-sensors.png?raw=true) From a06df57cb93da02c19ec917da2010415815e4cb6 Mon Sep 17 00:00:00 2001 From: rmm Date: Sat, 25 May 2024 14:55:23 +0200 Subject: [PATCH 03/12] Add function for info texts --- pve-mod-gui-sensors.sh | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/pve-mod-gui-sensors.sh b/pve-mod-gui-sensors.sh index 19eca23..ff502c6 100644 --- a/pve-mod-gui-sensors.sh +++ b/pve-mod-gui-sensors.sh @@ -38,8 +38,12 @@ function msgb { echo -e "\e[1m$1\e[0m" } +function info { + echo -e "\e[0;32m[info] $1\e[0m" +} + function warn { - echo -e "\e[0;33m[warning] $1\e[0m" + echo -e "\e[0;93m[warning] $1\e[0m" } function err { @@ -668,9 +672,9 @@ Ext.define('PVE.mod.TempHelper', {\n\ restart_proxy - msg "Installation completed" + msg "Installation completed." - msg "Clear the browser cache to ensure all changes are visualized." + info "Clear the browser cache to ensure all changes are visualized." else warn "Sensor display items already added to the summary panel in \"$pvemanagerlibjs\"." fi @@ -737,4 +741,4 @@ done # If no arguments were provided or all arguments have been processed, print the usage message if [[ $executed -eq 0 ]]; then usage -fi \ No newline at end of file +fi From cd9b2fb4c8d2ce9e3c86b117cd2746a8a7f2c947 Mon Sep 17 00:00:00 2001 From: eremem <56274896+eremem@users.noreply.github.com> Date: Sat, 25 May 2024 15:09:10 +0200 Subject: [PATCH 04/12] Add function for info texts (#43) * Add function for info texts * Add missing text if no HDD/SSD sensors found. --- pve-mod-gui-sensors.sh | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/pve-mod-gui-sensors.sh b/pve-mod-gui-sensors.sh index 19eca23..ff502c6 100644 --- a/pve-mod-gui-sensors.sh +++ b/pve-mod-gui-sensors.sh @@ -38,8 +38,12 @@ function msgb { echo -e "\e[1m$1\e[0m" } +function info { + echo -e "\e[0;32m[info] $1\e[0m" +} + function warn { - echo -e "\e[0;33m[warning] $1\e[0m" + echo -e "\e[0;93m[warning] $1\e[0m" } function err { @@ -668,9 +672,9 @@ Ext.define('PVE.mod.TempHelper', {\n\ restart_proxy - msg "Installation completed" + msg "Installation completed." - msg "Clear the browser cache to ensure all changes are visualized." + info "Clear the browser cache to ensure all changes are visualized." else warn "Sensor display items already added to the summary panel in \"$pvemanagerlibjs\"." fi @@ -737,4 +741,4 @@ done # If no arguments were provided or all arguments have been processed, print the usage message if [[ $executed -eq 0 ]]; then usage -fi \ No newline at end of file +fi From 9c7dc540d8188e87cee98135c741f835f0544aae Mon Sep 17 00:00:00 2001 From: rmm Date: Sat, 25 May 2024 15:24:32 +0200 Subject: [PATCH 05/12] Detect default temperature unit selection --- pve-mod-gui-sensors.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pve-mod-gui-sensors.sh b/pve-mod-gui-sensors.sh index ff502c6..640071d 100644 --- a/pve-mod-gui-sensors.sh +++ b/pve-mod-gui-sensors.sh @@ -188,8 +188,12 @@ function configure { [fF]) TEMP_UNIT="F" ;; + "") + info "No unit selected. Temperatures will be presented in degrees Celsius." + TEMP_UNIT="C" + ;; *) - warn "Invalid selection. Temperatures will be presented in degrees Celsius." + warn "Invalid unit selected. Temperatures will be presented in degrees Celsius." TEMP_UNIT="C" ;; esac From 76e28b9d7c4e423423ddaba373c82b34ea0f43b9 Mon Sep 17 00:00:00 2001 From: Meliox <5264368+Meliox@users.noreply.github.com> Date: Sat, 15 Jun 2024 17:01:42 +0200 Subject: [PATCH 06/12] Add system information #2 (#47) --- pve-mod-gui-sensors.sh | 63 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 55 insertions(+), 8 deletions(-) diff --git a/pve-mod-gui-sensors.sh b/pve-mod-gui-sensors.sh index 640071d..856c8c0 100644 --- a/pve-mod-gui-sensors.sh +++ b/pve-mod-gui-sensors.sh @@ -198,6 +198,22 @@ function configure { ;; esac fi + echo "" + read -p "Do you wish to enable System Information. [Yn]: " ENABLE_SYS_INFO + case "$ENABLE_SYS_INFO" in + [yY]|"") + enableSystemInfo=true + msg "Displaying System Information... yes" + ;; + [nN]) + enableSystemInfo=false + msg "Displaying System Information... no" + ;; + *) + warn "Invalid selection. System information will be displayed." + enableSystemInfo=true + ;; + esac echo # add a new line } @@ -213,27 +229,37 @@ function install_mod { local timestamp=$(date '+%Y-%m-%d_%H-%M-%S') - # Add new line to Nodes.pm file - if [[ -z $(cat $nodespm | grep -e "$res->{sensorsOutput}") ]]; then + # Perform backup + if [[ -z $(cat $nodespm | grep -e "$res->{sensorsOutput}") ]] || [[ -z $(cat $nodespm | grep -e "$res->{systemInfo}") ]]; then # Create backup of original file cp "$nodespm" "$BACKUP_DIR/Nodes.pm.$timestamp" msg "Backup of \"$nodespm\" saved to \"$BACKUP_DIR/Nodes.pm.$timestamp\"." + # Create backup of original file + cp "$pvemanagerlibjs" "$BACKUP_DIR/pvemanagerlib.js.$timestamp" + msg "Backup of \"$pvemanagerlibjs\" saved to \"$BACKUP_DIR/pvemanagerlib.js.$timestamp\"." + else + err "Mod is already installed. Uninstall existing before installing." + exit + fi + + enableSensors=true + if [[ "$enableSensors" == true ]]; then # WTF: sensors -f used for Fahrenheit breaks the fan speeds :| #local sensorsCmd=$([[ "$TEMP_UNIT" = "F" ]] && echo "sensors -j -f" || echo "sensors -j") local sensorsCmd="sensors -j" sed -i '/my \$dinfo = df('\''\/'\'', 1);/i\'$'\t''$res->{sensorsOutput} = `'"$sensorsCmd"'`;\n\t# sanitize JSON output\n\t$res->{sensorsOutput} =~ s/ERROR:.+\\s(\\w+):\\s(.+)/\\"$1\\": 0.000,/g;\n\t$res->{sensorsOutput} =~ s/ERROR:.+\\s(\\w+)!/\\"$1\\": 0.000,/g;\n\t$res->{sensorsOutput} =~ s/,(.*[.\\n]*.+})/$1/g;\n' "$nodespm" msg "Sensors' output added to \"$nodespm\"." - else - warn "Sensors' output already integrated in in \"$nodespm\"." + fi + + if [[ "$enableSystemInfo" == true ]]; then + local systemInfoCmd=$(dmidecode -t 1 | awk -F': ' '/Manufacturer|Product Name|Serial Number/ {print $1": "$2}' | awk '{$1=$1};1' | sed 's/$/ |/' | paste -sd " " - | sed 's/ |$//') + sed -i "/my \$dinfo = df('\/', 1);/i\\\t\$res->{systemInfo} = \"$(echo "$systemInfoCmd")\";\n" "$nodespm" + msg "System Information output added to \"$nodespm\"." fi # Add new item to the items array in PVE.node.StatusView if [[ -z $(cat "$pvemanagerlibjs" | grep -e "itemId: 'thermal[[:alnum:]]*'") ]]; then - # Create backup of original file - cp "$pvemanagerlibjs" "$BACKUP_DIR/pvemanagerlib.js.$timestamp" - msg "Backup of \"$pvemanagerlibjs\" saved to \"$BACKUP_DIR/pvemanagerlib.js.$timestamp\"." - local tempHelperCtorParams=$([[ "$TEMP_UNIT" = "F" ]] && echo '{srcUnit: PVE.mod.TempHelper.CELSIUS, dstUnit: PVE.mod.TempHelper.FAHRENHEIT}' || echo '{srcUnit: PVE.mod.TempHelper.CELSIUS, dstUnit: PVE.mod.TempHelper.CELSIUS}') # Expand space in StatusView sed -i "/Ext.define('PVE\.node\.StatusView'/,/\},/ { @@ -331,6 +357,27 @@ Ext.define('PVE.mod.TempHelper', {\n\ },\n\ });\n" "$pvemanagerlibjs" + if [[ $enableSystemInfo == "true" ]]; then + sed -i "/^Ext.define('PVE.node.StatusView',/ { + :a; + /items:/!{N;ba;} + :b; + /cpus.*},/!{N;bb;} + a\ + \\ + {\n\ + itemId: 'sysinfo',\n\ + colspan: 2,\n\ + printBar: false,\n\ + title: gettext('System Information'),\n\ + textField: 'systemInfo',\n\ + renderer: function(value){\n\ + return value;\n\ + }\n\ + }, + }" "$pvemanagerlibjs" + fi + sed -i "/^Ext.define('PVE.node.StatusView',/ { :a; /items:/!{N;ba;} From d13d02ab36a199643eb9cdce2feccd40b42d01ac Mon Sep 17 00:00:00 2001 From: Meliox <5264368+Meliox@users.noreply.github.com> Date: Sun, 16 Jun 2024 00:02:54 +0200 Subject: [PATCH 07/12] save-sensors-data argument (#52) --- pve-mod-gui-sensors.sh | 41 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/pve-mod-gui-sensors.sh b/pve-mod-gui-sensors.sh index 856c8c0..21d504f 100644 --- a/pve-mod-gui-sensors.sh +++ b/pve-mod-gui-sensors.sh @@ -26,6 +26,10 @@ BACKUP_DIR="$SCRIPT_CWD/backup" pvemanagerlibjs="/usr/share/pve-manager/js/pvemanagerlib.js" nodespm="/usr/share/perl5/PVE/API2/Nodes.pm" +# Debug location +DEBUG_SAVE_PATH="$SCRIPT_CWD" +DEBUG_SAVE_FILENAME="sensorsdata.json" + ############################################### # Helper functions @@ -54,7 +58,7 @@ function err { # Function to display usage information function usage { - msgb "\nUsage:\n$0 [install | uninstall]\n" + msgb "\nUsage:\n$0 [install | uninstall | save-sensors-data]\n" exit 1 } @@ -768,6 +772,35 @@ function restart_proxy { systemctl restart pveproxy } +function save_sensors_data { + # Check if DEBUG_SAVE_PATH exists and is writable + if [[ ! -d "$DEBUG_SAVE_PATH" || ! -w "$DEBUG_SAVE_PATH" ]]; then + err "Directory $DEBUG_SAVE_PATH does not exist or is not writable. No file could be saved" + return + fi + + # Check if command exists + if (command -v sensors &>/dev/null); then + # Save sensors output + local filepath="${DEBUG_SAVE_PATH}/${DEBUG_SAVE_FILENAME}" + echo "Sensors data will be saved in $filepath" + + # Prompt user for confirmation + read -p "Do you wish to continue? (y/n): " choice + case "$choice" in + y|Y ) + sensors -j > "$filepath" + msgb "Sensors data saved in $filepath" + ;; + * ) + echo "Operation cancelled by user." + ;; + esac + else + err "Sensors is not installed. No file could be saved" + fi +} + # Process the arguments using a while loop and a case statement executed=0 while [[ $# -gt 0 ]]; do @@ -785,6 +818,12 @@ while [[ $# -gt 0 ]]; do uninstall_mod echo # add a new line ;; + save-sensors-data) + executed=$(($executed + 1)) + msgb "\nSaving current sensor readings in a file for debugging..." + save_sensors_data + echo # add a new line + ;; esac shift done From 3490d3a07e63359027c8c261af31f09e8d7cb162 Mon Sep 17 00:00:00 2001 From: Meliox <5264368+Meliox@users.noreply.github.com> Date: Sun, 16 Jun 2024 11:42:31 +0200 Subject: [PATCH 08/12] Add "remote" debug option of json file (#50) --- pve-mod-gui-sensors.sh | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/pve-mod-gui-sensors.sh b/pve-mod-gui-sensors.sh index 21d504f..ba01218 100644 --- a/pve-mod-gui-sensors.sh +++ b/pve-mod-gui-sensors.sh @@ -30,7 +30,11 @@ nodespm="/usr/share/perl5/PVE/API2/Nodes.pm" DEBUG_SAVE_PATH="$SCRIPT_CWD" DEBUG_SAVE_FILENAME="sensorsdata.json" -############################################### +##################### DO NOT EDIT BELOW ####################### +# Only to be used to debug on other systems. Save the "sensor -j" output into a json file. +# Information will be loaded for script configuration and presented in Proxmox. +DEBUG_REMOTE=false +JSON_FILE="/tmp/sensordata.json" # Helper functions function msg { @@ -89,7 +93,15 @@ function install_packages { function configure { sensorsDetected=false - local sensorsOutput=$(sensors -j) + local sensorsOutput + + if [ $DEBUG_REMOTE = true ]; then + warn "Remote debugging is used. Sensor readings from dump file $JSON_FILE will be used." + sensorsOutput=$(cat $JSON_FILE) + else + sensorsOutput=$(sensors -j) + fi + if [ $? -ne 0 ]; then err "Sensor output error.\n\nCommand output:\n${sensorsOutput}\n\nExiting...\n" fi @@ -249,9 +261,14 @@ function install_mod { enableSensors=true if [[ "$enableSensors" == true ]]; then - # WTF: sensors -f used for Fahrenheit breaks the fan speeds :| - #local sensorsCmd=$([[ "$TEMP_UNIT" = "F" ]] && echo "sensors -j -f" || echo "sensors -j") - local sensorsCmd="sensors -j" + local sensorsCmd + if [ $DEBUG_REMOTE = true ]; then + sensorsCmd="cat \"$JSON_FILE\"" + else + # WTF: sensors -f used for Fahrenheit breaks the fan speeds :| + #local sensorsCmd=$([[ "$TEMP_UNIT" = "F" ]] && echo "sensors -j -f" || echo "sensors -j") + sensorsCmd="sensors -j" + fi sed -i '/my \$dinfo = df('\''\/'\'', 1);/i\'$'\t''$res->{sensorsOutput} = `'"$sensorsCmd"'`;\n\t# sanitize JSON output\n\t$res->{sensorsOutput} =~ s/ERROR:.+\\s(\\w+):\\s(.+)/\\"$1\\": 0.000,/g;\n\t$res->{sensorsOutput} =~ s/ERROR:.+\\s(\\w+)!/\\"$1\\": 0.000,/g;\n\t$res->{sensorsOutput} =~ s/,(.*[.\\n]*.+})/$1/g;\n' "$nodespm" msg "Sensors' output added to \"$nodespm\"." fi From ba3991a3a2d62847b114ba6c75c4676a06f3596a Mon Sep 17 00:00:00 2001 From: Meliox <5264368+Meliox@users.noreply.github.com> Date: Sun, 16 Jun 2024 13:01:46 +0200 Subject: [PATCH 09/12] Add support for multiple AMD temp types (#49) --- pve-mod-gui-sensors.sh | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/pve-mod-gui-sensors.sh b/pve-mod-gui-sensors.sh index ba01218..1895c02 100644 --- a/pve-mod-gui-sensors.sh +++ b/pve-mod-gui-sensors.sh @@ -112,15 +112,27 @@ function configure { if (echo "$sensorsOutput" | grep -q "$item"); then case "$item" in "coretemp-"*) - CPU_ADDRESS_PREFIX=$item - CPU_ITEM_PREFIX="Core " - CPU_TEMP_CAPTION="Core" + # Intel CPU + # Set temperature search criteria + if (echo "$sensorsOutput" | grep -A 10 "$item" | grep -q "Core "); then + CPU_ADDRESS_PREFIX=$item + CPU_ITEM_PREFIX="Core " + CPU_TEMP_CAPTION="Core" + fi break ;; "k10temp-"*) - CPU_ADDRESS_PREFIX=$item - CPU_ITEM_PREFIX="Tccd" - CPU_TEMP_CAPTION="Temp" + # AMD CPU + # Find and set temperature search criteria + if (echo "$sensorsOutput" | grep -A 4 "$item" | grep -q -e "Tctl" -e "Tccd"); then + CPU_ADDRESS_PREFIX=$item + CPU_ITEM_PREFIX="Tccd" + CPU_TEMP_CAPTION="Temp" + elif (echo "$sensorsOutput" | grep -A 4 "$item" | grep -q "temp"); then + CPU_ADDRESS_PREFIX=$item + CPU_ITEM_PREFIX="temp" + CPU_TEMP_CAPTION="Temp" + fi break ;; *) From 288a7f69e91e49dc65c7c0f41eb7b87fa75da93a Mon Sep 17 00:00:00 2001 From: Meliox <5264368+Meliox@users.noreply.github.com> Date: Sun, 16 Jun 2024 13:17:12 +0200 Subject: [PATCH 10/12] Option to display Intel package or cores temp (#54) Implements #8 --- pve-mod-gui-sensors.sh | 68 ++++++++++++++++++++++++------------------ 1 file changed, 39 insertions(+), 29 deletions(-) diff --git a/pve-mod-gui-sensors.sh b/pve-mod-gui-sensors.sh index 1895c02..16f4d1b 100644 --- a/pve-mod-gui-sensors.sh +++ b/pve-mod-gui-sensors.sh @@ -110,40 +110,50 @@ function configure { msg "\nDetecting support for CPU temperature sensors..." for item in "${KNOWN_CPU_SENSORS[@]}"; do if (echo "$sensorsOutput" | grep -q "$item"); then - case "$item" in - "coretemp-"*) - # Intel CPU - # Set temperature search criteria - if (echo "$sensorsOutput" | grep -A 10 "$item" | grep -q "Core "); then - CPU_ADDRESS_PREFIX=$item - CPU_ITEM_PREFIX="Core " - CPU_TEMP_CAPTION="Core" - fi - break - ;; - "k10temp-"*) - # AMD CPU - # Find and set temperature search criteria - if (echo "$sensorsOutput" | grep -A 4 "$item" | grep -q -e "Tctl" -e "Tccd"); then - CPU_ADDRESS_PREFIX=$item - CPU_ITEM_PREFIX="Tccd" - CPU_TEMP_CAPTION="Temp" - elif (echo "$sensorsOutput" | grep -A 4 "$item" | grep -q "temp"); then - CPU_ADDRESS_PREFIX=$item - CPU_ITEM_PREFIX="temp" - CPU_TEMP_CAPTION="Temp" - fi - break - ;; - *) - continue - ;; - esac + CPU_ADDRESS_PREFIX=$item fi done if [ -n "$CPU_ADDRESS_PREFIX" ]; then msg "Detected sensors:\n$(echo "$sensorsOutput" | grep -o "\"${CPU_ADDRESS_PREFIX}[^\"]*\"" | sed 's/"//g')" + + # Populate search criterias for known CPUs + if (echo "$sensorsOutput" | grep -q "coretemp-"); then + # Intel CPU + # Prompt user for which temperature to use + read -p "Do you wish to display temperatures for all cores [C] or just an average value(s) per CPU [a]? (C/a): " choice + case "$choice" in + # Set temperature search criteria + [cC]|"") + if (echo "$sensorsOutput" | grep -A 10 "coretemp-" | grep -q "Core "); then + CPU_ITEM_PREFIX="Core " + CPU_TEMP_CAPTION="Core" + fi + ;; + [aA] ) + if (echo "$sensorsOutput" | grep -A 10 "coretemp-" | grep -q "Package id "); then + CPU_ITEM_PREFIX="Package id" + CPU_TEMP_CAPTION="Package" + fi + ;; + *) + # If the user enters an invalid input, print an error message and exit the script with a non-zero status code + err "Invalid input. Exiting..." + ;; + esac + elif (echo "$sensorsOutput" | grep -q "k10temp-"); then + # AMD CPU + # Find and set temperature search criteria + if (echo "$sensorsOutput" | grep -A 4 "$item" | grep -q -e "Tctl" -e "Tccd"); then + CPU_ADDRESS_PREFIX=$item + CPU_ITEM_PREFIX="Tccd" + CPU_TEMP_CAPTION="Temp" + elif (echo "$sensorsOutput" | grep -A 4 "$item" | grep -q "temp"); then + CPU_ADDRESS_PREFIX=$item + CPU_ITEM_PREFIX="temp" + CPU_TEMP_CAPTION="Temp" + fi + fi else # If cpu is not known, ask the user for input warn "Could not automatically detect the CPU temperature sensor. Please configure it manually." From 305bd0d225903e90839d39955b6146e9348c3d58 Mon Sep 17 00:00:00 2001 From: eremem <56274896+eremem@users.noreply.github.com> Date: Sun, 16 Jun 2024 13:21:15 +0200 Subject: [PATCH 11/12] Unify prompt texts (#56) * Adjust & unify prompts * Change case y|Y to [yY] * Add some missing trailing dots --- pve-mod-gui-sensors.sh | 55 +++++++++++++++++++++--------------------- 1 file changed, 27 insertions(+), 28 deletions(-) diff --git a/pve-mod-gui-sensors.sh b/pve-mod-gui-sensors.sh index 16f4d1b..d3b1a55 100644 --- a/pve-mod-gui-sensors.sh +++ b/pve-mod-gui-sensors.sh @@ -216,42 +216,41 @@ function configure { fi if [ $sensorsDetected = true ]; then - msg "\nSelect a unit for temperature readings..." - read -p "Type C for Celsius or F for Fahrenheit and press Enter: " TEMP_UNIT + echo + read -p "Do you wish to display temperature readings in degrees Celsius [C] or Fahrenheit [f]? (C/f): " TEMP_UNIT case "$TEMP_UNIT" in - [cC]) + [cC] | "") TEMP_UNIT="C" + info "Temperatures will be presented in degrees Celsius." ;; [fF]) TEMP_UNIT="F" - ;; - "") - info "No unit selected. Temperatures will be presented in degrees Celsius." - TEMP_UNIT="C" + info "Temperatures will be presented in degrees Fahrenheit." ;; *) - warn "Invalid unit selected. Temperatures will be presented in degrees Celsius." + warn "Invalid unit selected. Temperatures will be displayed in degrees Celsius." TEMP_UNIT="C" ;; esac fi - echo "" - read -p "Do you wish to enable System Information. [Yn]: " ENABLE_SYS_INFO + + echo + read -p "Do you wish to enable system information? (Y/n): " ENABLE_SYS_INFO case "$ENABLE_SYS_INFO" in - [yY]|"") + [yY] | "") enableSystemInfo=true - msg "Displaying System Information... yes" + info "System information will be displayed..." ;; [nN]) enableSystemInfo=false - msg "Displaying System Information... no" + info "System information will NOT be displayed..." ;; *) warn "Invalid selection. System information will be displayed." enableSystemInfo=true ;; - esac + esac echo # add a new line } @@ -275,7 +274,7 @@ function install_mod { # Create backup of original file cp "$pvemanagerlibjs" "$BACKUP_DIR/pvemanagerlib.js.$timestamp" - msg "Backup of \"$pvemanagerlibjs\" saved to \"$BACKUP_DIR/pvemanagerlib.js.$timestamp\"." + msg "Backup of \"$pvemanagerlibjs\" saved to \"$BACKUP_DIR/pvemanagerlib.js.$timestamp\"." else err "Mod is already installed. Uninstall existing before installing." exit @@ -288,7 +287,7 @@ function install_mod { sensorsCmd="cat \"$JSON_FILE\"" else # WTF: sensors -f used for Fahrenheit breaks the fan speeds :| - #local sensorsCmd=$([[ "$TEMP_UNIT" = "F" ]] && echo "sensors -j -f" || echo "sensors -j") + #local sensorsCmd=$([[ "$TEMP_UNIT" = "F" ]] && echo "sensors -j -f" || echo "sensors -j") sensorsCmd="sensors -j" fi sed -i '/my \$dinfo = df('\''\/'\'', 1);/i\'$'\t''$res->{sensorsOutput} = `'"$sensorsCmd"'`;\n\t# sanitize JSON output\n\t$res->{sensorsOutput} =~ s/ERROR:.+\\s(\\w+):\\s(.+)/\\"$1\\": 0.000,/g;\n\t$res->{sensorsOutput} =~ s/ERROR:.+\\s(\\w+)!/\\"$1\\": 0.000,/g;\n\t$res->{sensorsOutput} =~ s/,(.*[.\\n]*.+})/$1/g;\n' "$nodespm" @@ -298,7 +297,7 @@ function install_mod { if [[ "$enableSystemInfo" == true ]]; then local systemInfoCmd=$(dmidecode -t 1 | awk -F': ' '/Manufacturer|Product Name|Serial Number/ {print $1": "$2}' | awk '{$1=$1};1' | sed 's/$/ |/' | paste -sd " " - | sed 's/ |$//') sed -i "/my \$dinfo = df('\/', 1);/i\\\t\$res->{systemInfo} = \"$(echo "$systemInfoCmd")\";\n" "$nodespm" - msg "System Information output added to \"$nodespm\"." + msg "System information output added to \"$nodespm\"." fi # Add new item to the items array in PVE.node.StatusView @@ -814,7 +813,7 @@ function restart_proxy { function save_sensors_data { # Check if DEBUG_SAVE_PATH exists and is writable if [[ ! -d "$DEBUG_SAVE_PATH" || ! -w "$DEBUG_SAVE_PATH" ]]; then - err "Directory $DEBUG_SAVE_PATH does not exist or is not writable. No file could be saved" + err "Directory $DEBUG_SAVE_PATH does not exist or is not writable. No file could be saved." return fi @@ -822,21 +821,21 @@ function save_sensors_data { if (command -v sensors &>/dev/null); then # Save sensors output local filepath="${DEBUG_SAVE_PATH}/${DEBUG_SAVE_FILENAME}" - echo "Sensors data will be saved in $filepath" - + msg "Sensors data will be saved in $filepath" + # Prompt user for confirmation read -p "Do you wish to continue? (y/n): " choice - case "$choice" in - y|Y ) - sensors -j > "$filepath" - msgb "Sensors data saved in $filepath" + case "$choice" in + [yY]) + sensors -j >"$filepath" + msgb "Sensors data saved in $filepath." ;; - * ) - echo "Operation cancelled by user." + *) + warn "Operation cancelled by user." ;; esac else - err "Sensors is not installed. No file could be saved" + err "Sensors is not installed. No file could be saved." fi } @@ -862,7 +861,7 @@ while [[ $# -gt 0 ]]; do msgb "\nSaving current sensor readings in a file for debugging..." save_sensors_data echo # add a new line - ;; + ;; esac shift done From 94acafdc8596f8489f4d7f4493218299a7b9d07f Mon Sep 17 00:00:00 2001 From: Meliox <5264368+Meliox@users.noreply.github.com> Date: Sun, 16 Jun 2024 13:27:14 +0200 Subject: [PATCH 12/12] Update issue templates (#55) --- .github/ISSUE_TEMPLATE/bug_report.md | 30 +++++++++++++++++++++++ .github/ISSUE_TEMPLATE/feature_request.md | 23 +++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/bug_report.md create mode 100644 .github/ISSUE_TEMPLATE/feature_request.md diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 0000000..9144db4 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,30 @@ +--- +name: Bug report +about: Create a report to help us improve +title: '' +labels: bug +assignees: '' + +--- + +**Describe the bug** +A clear and concise description of what the bug is. + +**To Reproduce** +Steps to reproduce the behavior: +1. Go to '...' +2. Click on '....' +3. Scroll down to '....' +4. See error + +**Expected behavior** +A clear and concise description of what you expected to happen. + +**Screenshots** +If applicable, add screenshots to help explain your problem. + +**Sensors output** +If applicable, provide sensor datadump (use the argument save-sensors-data) + +**Additional context** +Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 0000000..8fa3e51 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,23 @@ +--- +name: Feature request +about: Suggest an idea for this project +title: '' +labels: enhancement +assignees: '' + +--- + +**Is your feature request related to a problem? Please describe.** +A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] + +**Describe the solution you'd like** +A clear and concise description of what you want to happen. + +**Describe alternatives you've considered** +A clear and concise description of any alternative solutions or features you've considered. + +**Additional context** +Add any other context or screenshots about the feature request here. + +**Sensors output** +If applicable, provide sensor datadump (use the argument save-sensors-data)