check_root_privileges when installing sensor mod (#111)
This commit is contained in:
parent
14b2ee607e
commit
2202159585
@ -75,6 +75,11 @@ function usage {
|
|||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# System checks
|
||||||
|
function check_root_privileges() {
|
||||||
|
[[ $EUID -eq 0 ]] || err "This script must be run as root. Please run it with 'sudo $0'."
|
||||||
|
}
|
||||||
|
|
||||||
# Define a function to install packages
|
# Define a function to install packages
|
||||||
function install_packages {
|
function install_packages {
|
||||||
# Check if the 'sensors' command is available on the system
|
# Check if the 'sensors' command is available on the system
|
||||||
@ -268,6 +273,8 @@ function configure {
|
|||||||
|
|
||||||
# Function to install the modification
|
# Function to install the modification
|
||||||
function install_mod {
|
function install_mod {
|
||||||
|
check_root_privileges
|
||||||
|
|
||||||
if [[ -n $(cat $NODES_PM_FILE | grep -e "$res->{sensorsOutput}") ]] && [[ -n $(cat $NODES_PM_FILE | grep -e "$res->{systemInfo}") ]]; then
|
if [[ -n $(cat $NODES_PM_FILE | grep -e "$res->{sensorsOutput}") ]] && [[ -n $(cat $NODES_PM_FILE | grep -e "$res->{systemInfo}") ]]; then
|
||||||
err "Mod is already installed. Uninstall existing before installing."
|
err "Mod is already installed. Uninstall existing before installing."
|
||||||
exit
|
exit
|
||||||
@ -958,6 +965,8 @@ Ext.define('PVE.mod.TempHelper', {\n\
|
|||||||
|
|
||||||
# Function to uninstall the modification
|
# Function to uninstall the modification
|
||||||
function uninstall_mod {
|
function uninstall_mod {
|
||||||
|
check_root_privileges
|
||||||
|
|
||||||
msg "\nRestoring modified files..."
|
msg "\nRestoring modified files..."
|
||||||
# Find the latest Nodes.pm file using the find command
|
# Find the latest Nodes.pm file using the find command
|
||||||
local latest_nodes_pm=$(find "$BACKUP_DIR" -name "Nodes.pm.*" -type f -printf '%T+ %p\n' 2>/dev/null | sort -r | head -n 1 | awk '{print $2}')
|
local latest_nodes_pm=$(find "$BACKUP_DIR" -name "Nodes.pm.*" -type f -printf '%T+ %p\n' 2>/dev/null | sort -r | head -n 1 | awk '{print $2}')
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user