add move info to uninstall. Refactor setbackupdir
This commit is contained in:
parent
02eacd21a9
commit
4187de4b05
@ -924,14 +924,9 @@ Ext.define('PVE.mod.TempHelper', {\n\
|
|||||||
|
|
||||||
# Function to uninstall the modification
|
# Function to uninstall the modification
|
||||||
function uninstall_mod {
|
function uninstall_mod {
|
||||||
msg "\nRestoring modified files..."
|
setBackupDirectory
|
||||||
|
|
||||||
if [[ -z "$BACKUP_DIR" ]]; then
|
msg "\nRestoring modified files..."
|
||||||
# If not set, use the default backup directory, which is based on the home directory and PVE-MODS
|
|
||||||
local DEFAULT_BACKUP_DIR="$HOME/PVE-MODS"
|
|
||||||
msg "Backup directory not set. Using default: $DEFAULT_BACKUP_DIR"
|
|
||||||
BACKUP_DIR="$DEFAULT_BACKUP_DIR"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# 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}')
|
||||||
@ -939,7 +934,7 @@ function uninstall_mod {
|
|||||||
if [ -n "$latest_nodes_pm" ]; then
|
if [ -n "$latest_nodes_pm" ]; then
|
||||||
# Remove the latest Nodes.pm file
|
# Remove the latest Nodes.pm file
|
||||||
cp "$latest_nodes_pm" "$NODES_PM_FILE"
|
cp "$latest_nodes_pm" "$NODES_PM_FILE"
|
||||||
msg "Copied latest backup to $NODES_PM_FILE."
|
msg "Restoring latest Nodes.pm from backup: $latest_nodes_pm to \"$NODES_PM_FILE\"."
|
||||||
else
|
else
|
||||||
warn "No Nodes.pm backup files found."
|
warn "No Nodes.pm backup files found."
|
||||||
fi
|
fi
|
||||||
@ -950,7 +945,7 @@ function uninstall_mod {
|
|||||||
if [ -n "$latest_pvemanagerlibjs" ]; then
|
if [ -n "$latest_pvemanagerlibjs" ]; then
|
||||||
# Remove the latest pvemanagerlib.js file
|
# Remove the latest pvemanagerlib.js file
|
||||||
cp "$latest_pvemanagerlibjs" "$PVE_MANAGER_LIB_JS_FILE"
|
cp "$latest_pvemanagerlibjs" "$PVE_MANAGER_LIB_JS_FILE"
|
||||||
msg "Copied latest backup to \"$PVE_MANAGER_LIB_JS_FILE\"."
|
msg "Restoring latest pvemanagerlib.js from backup: $latest_pvemanagerlibjs to \"$PVE_MANAGER_LIB_JS_FILE\"."
|
||||||
else
|
else
|
||||||
warn "No pvemanagerlib.js backup files found."
|
warn "No pvemanagerlib.js backup files found."
|
||||||
fi
|
fi
|
||||||
@ -996,7 +991,7 @@ function save_sensors_data {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function makeBackupDirectory {
|
function setBackupDirectory {
|
||||||
# Check if the BACKUP_DIR variable is set, if not, use the default backup
|
# Check if the BACKUP_DIR variable is set, if not, use the default backup
|
||||||
if [[ -z "$BACKUP_DIR" ]]; then
|
if [[ -z "$BACKUP_DIR" ]]; then
|
||||||
# If not set, use the default backup directory, which is based on the home directory and PVE-MODS
|
# If not set, use the default backup directory, which is based on the home directory and PVE-MODS
|
||||||
@ -1005,6 +1000,14 @@ function makeBackupDirectory {
|
|||||||
BACKUP_DIR="$DEFAULT_BACKUP_DIR"
|
BACKUP_DIR="$DEFAULT_BACKUP_DIR"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Ensure the BACKUP_DIR variable is an absolute path
|
||||||
|
BACKUP_DIR=$(realpath "$BACKUP_DIR")
|
||||||
|
msg "Using backup directory: $BACKUP_DIR"
|
||||||
|
}
|
||||||
|
|
||||||
|
function makeBackupDirectory {
|
||||||
|
setBackupDirectory
|
||||||
|
|
||||||
# Create the backup directory if it does not exist
|
# Create the backup directory if it does not exist
|
||||||
if [[ ! -d "$BACKUP_DIR" ]]; then
|
if [[ ! -d "$BACKUP_DIR" ]]; then
|
||||||
mkdir -p "$BACKUP_DIR" 2>/dev/null || {
|
mkdir -p "$BACKUP_DIR" 2>/dev/null || {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user