diff --git a/original/etc/cronscripts/change_pve_task_history_size/update_pve_max_task_history_size.sh b/original/etc/cronscripts/change_pve_task_history_size/update_pve_max_task_history_size.sh new file mode 100644 index 0000000..c939fa9 --- /dev/null +++ b/original/etc/cronscripts/change_pve_task_history_size/update_pve_max_task_history_size.sh @@ -0,0 +1,35 @@ +#!/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 \ No newline at end of file