Add save-sensors-data argument

This commit is contained in:
Meliox 2024-06-15 19:34:26 +02:00
parent 03b191aa7a
commit 82fb660c57

View File

@ -58,7 +58,7 @@ function err {
# Function to display usage information # Function to display usage information
function usage { function usage {
msgb "\nUsage:\n$0 [install | uninstall]\n" msgb "\nUsage:\n$0 [install | uninstall | save-sensors-data]\n"
exit 1 exit 1
} }
@ -785,6 +785,20 @@ function restart_proxy {
systemctl restart pveproxy systemctl restart pveproxy
} }
function save_sensors_data {
local script_dir filepath
# Check
if (command -v sensors &>/dev/null); then
# Save sensors output to sensorsdata.json in the script directory
script_dir="$(dirname "$0")"
filepath="$script_dir/sensorsdata.json"
sensors -j > "$filepath"
msgb "Sensors data saved in $filepath"
else
err "Sensors in not installed. No file could be saved"
fi
}
# Process the arguments using a while loop and a case statement # Process the arguments using a while loop and a case statement
executed=0 executed=0
while [[ $# -gt 0 ]]; do while [[ $# -gt 0 ]]; do
@ -802,6 +816,12 @@ while [[ $# -gt 0 ]]; do
uninstall_mod uninstall_mod
echo # add a new line echo # add a new line
;; ;;
save-sensors-data)
executed=$(($executed + 1))
msgb "\nSaves the Sensors json output into a file that can be used for debugging..."
save_sensors_data
echo # add a new line
;;
esac esac
shift shift
done done