Update simple/Install_Logic.sh

This commit is contained in:
2025-11-29 16:38:16 +01:00
parent af3b96b28f
commit de3e863341

51
simple/Install_Logic.sh Normal file
View File

@@ -0,0 +1,51 @@
#!/bin/bash
# Create parent directory if it does not exist
mkdir -p /etc/cronscripts/change_pve_task_history_size
# Path to the target script
TARGET="/etc/cronscripts/change_pve_task_history_size/update_pve_max_task_history_size.sh"
# Write the script contents
cat << 'EOF' > "$TARGET"
#!/bin/bash
# /etc/cronscripts/change_pve_task_history_size/update_pve_max_task_history_size.sh
# Path to the RESTEnvironment.pm file
FILE="/usr/share/perl5/PVE/RESTEnvironment.pm"
# Search and replacement strings
SEARCH="my \$maxsize = 50000; # about 1000 entries"
REPLACE="my \$maxsize = 1000000; # about 20000 entries, around 1 year task history"
# Check if the file exists
if [[ -f "$FILE" ]]; then
# Check if the target string exists in the file
if grep -qF "$SEARCH" "$FILE"; then
logger -t change_pve_task_history_size "String found in $FILE. Replacing '$SEARCH' with '$REPLACE'."
# Create a backup of the file
BACKUP_FILE="$FILE.$(date +%Y%m%d_%H%M%S)"
cp "$FILE" "$BACKUP_FILE"
logger -t change_pve_task_history_size "Backup created: $BACKUP_FILE"
# Replace the target string in the file
sed -i "s|$SEARCH|$REPLACE|" "$FILE"
logger -t change_pve_task_history_size "String replaced successfully in $FILE."
# Restart Proxmox services
systemctl restart pvedaemon.service pveproxy.service
logger -t change_pve_task_history_size "Services restarted."
else
logger -t change_pve_task_history_size "Search string not found in $FILE. No changes made."
fi
else
logger -t change_pve_task_history_size "File $FILE does not exist!"
fi
EOF
# Make script executable
chmod +x "$TARGET"
echo "Script created at $TARGET"