From cbf6dca5e32d59f3fa7057152dba229d418033f4 Mon Sep 17 00:00:00 2001 From: "Joseph.Rawlings" Date: Sat, 29 Nov 2025 16:03:08 +0100 Subject: [PATCH] Add Install_Script.sh --- Install_Script.sh | 51 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 Install_Script.sh diff --git a/Install_Script.sh b/Install_Script.sh new file mode 100644 index 0000000..f11c1ac --- /dev/null +++ b/Install_Script.sh @@ -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"