From bbeff75c74bdfa9e0ec2ede44c21c01b690fd319 Mon Sep 17 00:00:00 2001 From: Meliox Date: Wed, 26 Apr 2023 18:01:06 +0200 Subject: [PATCH] Update pve-mod-gui-temp.sh Add function to install lm-sensors during installation process --- pve-mod-gui-temp.sh | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/pve-mod-gui-temp.sh b/pve-mod-gui-temp.sh index 1c862bb..bbcc266 100644 --- a/pve-mod-gui-temp.sh +++ b/pve-mod-gui-temp.sh @@ -18,6 +18,38 @@ function usage { exit 1 } +#!/bin/bash + +# Define a function to install packages +install_packages () { + # Check if the 'sensors' command is available on the system + if ! command -v sensors &> /dev/null; then + # If the 'sensors' command is not available, prompt the user to install lm-sensors + read -p "lm-sensors is not installed. Would you like to install it? (y/n) " choice + case "$choice" in + y|Y ) + # If the user chooses to install lm-sensors, update the package list and install the package + apt-get update + apt-get install lm-sensors + ;; + n|N ) + # If the user chooses not to install lm-sensors, exit the script with a zero status code + echo "Decided to not install lm-sensors. The mod cannot run without" + exit 0 + ;; + * ) + # If the user enters an invalid input, print an error message and exit the script with a non-zero status code + echo "Invalid input. Exiting..." + exit 1 + ;; + esac + fi +} + +# Call the 'install_packages' function to check if lm-sensors is installed and install it if necessary +install_packages + + # Function to install the modification function install_mod { # Create backup of original files @@ -134,6 +166,7 @@ while [[ $# -gt 0 ]]; do case "$1" in install) echo "Installing the mod..." + install_packages install_mod ;; uninstall) @@ -148,4 +181,4 @@ while [[ $# -gt 0 ]]; do done echo "" -exit 0 \ No newline at end of file +exit 0