Some code cleanup

Enable copying of backup files
This commit is contained in:
Meliox 2023-06-27 20:16:56 +02:00
parent 1469e64ba7
commit 496b250ca3

View File

@ -5,7 +5,6 @@
pvemanagerlib="/usr/share/pve-manager/js/pvemanagerlib.js" pvemanagerlib="/usr/share/pve-manager/js/pvemanagerlib.js"
nodespm="/usr/share/perl5/PVE/API2/Nodes.pm" nodespm="/usr/share/perl5/PVE/API2/Nodes.pm"
backuplocation="/root/backup" backuplocation="/root/backup"
timestamp=$(date '+%Y-%m-%d_%H-%M-%S')
# Sensor configuration # Sensor configuration
# CPU. See tempN_in put for "Core 0" using sensor -j # CPU. See tempN_in put for "Core 0" using sensor -j
@ -17,6 +16,8 @@ HDDPerRow="4";
NVMEPerRow="4"; NVMEPerRow="4";
################### code below ############# ################### code below #############
timestamp=$(date '+%Y-%m-%d_%H-%M-%S')
echo "" echo ""
# Function to display usage information # Function to display usage information
@ -26,12 +27,10 @@ function usage {
exit 1 exit 1
} }
#!/bin/bash
# Define a function to install packages # Define a function to install packages
install_packages () { install_packages () {
# Check if the 'sensors' command is available on the system # Check if the 'sensors' command is available on the system
if ! command -v sensors &> /dev/null; then if (! command -v sensors &> /dev/null); then
# If the 'sensors' command is not available, prompt the user to install lm-sensors # 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 read -p "lm-sensors is not installed. Would you like to install it? (y/n) " choice
case "$choice" in case "$choice" in
@ -221,19 +220,19 @@ function uninstall_mod {
fi fi
# Remove the latest Nodes.pm file # Remove the latest Nodes.pm file
echo cp "$latest_Nodes_pm" "$nodespm" cp "$latest_Nodes_pm" "$nodespm"
echo "Copied latest backup to $nodespm" echo "Copied latest backup to $nodespm"
# Find the latest pvemanagerlib file using the find command # Find the latest pvemanagerlib file using the find command
latest_pvemanagerlib_js=$(find "$backuplocation" -name "pvemanagerlib.js.*" -type f -printf '%T+ %p\n' 2>/dev/null | sort -r | head -n 1 | awk '{print $2}') latest_pvemanagerlib_js=$(find "$backuplocation" -name "pvemanagerlib.js.*" -type f -printf '%T+ %p\n' 2>/dev/null | sort -r | head -n 1 | awk '{print $2}')
if [ -z "$latest_pvemanagerlib_js" ]; then if [ -z "$latest_pvemanagerlib_js" ]; then
echo "No latest_pvemanagerlib_js files found" echo "No latest_pvemanagerlib_js files found"
exit 1 exit 1
fi fi
# Remove the latest Nodes.pm file # Remove the latest Nodes.pm file
echo cp "$latest_pvemanagerlib_js" "$pvemanagerlib" cp "$latest_pvemanagerlib_js" "$pvemanagerlib"
echo "Copied latest backup to $pvemanagerlib" echo "Copied latest backup to $pvemanagerlib"
# Restart pveproxy # Restart pveproxy
@ -242,7 +241,7 @@ function uninstall_mod {
# If no arguments were provided or all arguments have been processed, print the usage message # If no arguments were provided or all arguments have been processed, print the usage message
if [[ $# -eq 0 ]]; then if [[ $# -eq 0 ]]; then
usage usage
fi fi
# Process the arguments using a while loop and a case statement # Process the arguments using a while loop and a case statement
@ -265,4 +264,4 @@ while [[ $# -gt 0 ]]; do
done done
echo "" echo ""
exit 0 exit 0