From 6bbfa17e1c8100682d983926d623b937bb4749a7 Mon Sep 17 00:00:00 2001 From: heavybullets8 Date: Sun, 18 Dec 2022 13:26:56 -0700 Subject: [PATCH] Hot patch --- functions/menu.sh | 4 +++ functions/misc.sh | 73 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+) diff --git a/functions/menu.sh b/functions/menu.sh index 164bdd7b..67543d08 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -13,6 +13,7 @@ echo "4) Backup Options" echo "5) Update HeavyScript" echo "6) Update Applications" echo "7) Command to Container" +echo "8) Patch 22.12.0" echo echo "0) Exit" read -rt 120 -p "Please select an option by number: " selection || { echo -e "\nFailed to make a selection in time" ; exit; } @@ -79,6 +80,9 @@ case $selection in 7) cmd_to_container ;; + 8) + patch_2212_backups + ;; *) echo "\"$selection\" was not an option, please try agian" && sleep 3 && menu ;; diff --git a/functions/misc.sh b/functions/misc.sh index 66b93410..decf8899 100644 --- a/functions/misc.sh +++ b/functions/misc.sh @@ -98,3 +98,76 @@ echo exit } export -f help + + + +patch_2212_backups(){ +clear -x +#Check TrueNAS version, skip if not 22.12.0 +if ! [ "$(cli -m csv -c 'system version' | awk -F '-' '{print $3}')" == "22.12.0" ]; then + echo "This patch does not apply to your version of TrueNAS" + return +fi + + +#Description +echo "This patch will fix the issue with backups not restoring properly" +echo "Due to Ix-Systems not saving PVC in backups, this patch will fix that" +echo "Otherwise backups will not restore properly" +echo "You only need to run this patch once, it will not run again" +echo + + +#Download patch +echo "Downloading Backup Patch" +if ! wget -q https://github.com/truecharts/truetool/raw/main/hotpatch/2212/HP1.patch; then + echo "Failed to download Backup Patch" + exit +else + echo "Downloaded Backup Patch" +fi + +echo + +# Apply patch +echo "Applying Backup Patch" +if patch -N --reject-file=/dev/null -s -p0 -d /usr/lib/python3/dist-packages/middlewared/ < HP1.patch &>/dev/null; then + echo "Backup Patch applied" + rm -rf HP1.patch +else + echo "Backup Patch already applied" + rm -rf HP1.patch + exit +fi + +echo + +#Restart middlewared +while true +do + echo "We need to restart middlewared to finish the patch" + echo "This will cause a short downtime for your system" + read -rt 120 -p "Would you like to proceed? (y/N): " yesno || { echo -e "\nFailed to make a selection in time" ; exit; } + case $yesno in + [Yy] | [Yy][Ee][Ss]) + echo "Restarting middlewared" + service middlewared restart & + wait $! + break + ;; + [Nn] | [Nn][Oo]) + echo "Exiting" + echo "Please restart middlewared manually" + echo "You can do: service middlewared restart" + exit + ;; + *) + echo "That was not an option, try again" + sleep 3 + continue + ;; + esac +done +} +export -f patchv22120 +