From 196e8ae0fcb1e7f562a8e87473e235c58bdc7f50 Mon Sep 17 00:00:00 2001 From: crowetic <5431064+crowetic@users.noreply.github.com> Date: Mon, 14 Nov 2022 14:27:59 -0800 Subject: [PATCH] auto-fix-qortal script for automated core update This script will check the hash of the release version of Qortal (in a way that will surely be modified in the future) - It will then verify that the installed qortal.jar is the same hash as the new release. If so, it will exit. If the installed qortal.jar is a DIFFERENT hash than release version, it will remove existing version, replace with new version, remove db, log files, update start script to use a version that uses max RAM for the JVM of 2.2GB, then start Qortal so that it will auto-bootstrap. This is a VERY early and VERY 'rough' version of the script, but it works. It needs a lot more checks to ensure it doesn't remove qortal with nothing to replace it, etc... it NEEDS internet connectivity, and checks for that. Many other additions will happen as well. --- auto-fix-qortal.sh | 56 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 auto-fix-qortal.sh diff --git a/auto-fix-qortal.sh b/auto-fix-qortal.sh new file mode 100644 index 0000000..b4fb604 --- /dev/null +++ b/auto-fix-qortal.sh @@ -0,0 +1,56 @@ +#!/bin/sh + +# Regular Colors +BLACK='\033[0;30m' # Black +RED='\033[0;31m' # Red +GREEN='\033[0;32m' # Green +YELLOW='\033[0;33m' # Yellow +BLUE='\033[0;34m' # Blue +PURPLE='\033[0;35m' # Purple +CYAN='\033[0;36m' # Cyan +WHITE='\033[0;37m' # White +NC='\033[0m' # No Color + +echo "${PURPLE} Checking hash of qortal.jar on local machine VS newest released qortal.jar on github ${NC}\n" + +cd qortal +md5sum qortal.jar > "local.md5" +cd + + +echo "${RED} Grabbing newest released jar to check hash ${NC}\n" + +curl -L -O https://github.com/qortal/qortal/releases/latest/download/qortal.jar + +md5sum qortal.jar > "remote.md5" + + +LOCAL=$(cat ~/qortal/local.md5) +REMOTE=$(cat ~/remote.md5) + + +if [ "$LOCAL" = "$REMOTE" ]; then + + echo "${BLUE} Your Qortal Core is up-to-date! No action needed. ${NC}\n" + sleep 5 + rm ~/qortal.jar + rm ~/qortal/local.md5 remote.md5 + exit 1 + +else + echo "${CYAN} Your Qortal Core is OUTDATED, refreshing and starting qortal... ${NC}\n" + cd qortal + killall -9 java + sleep 5 + rm -R db + rm start.sh + rm qortal.jar + rm log.t* + mv ~/qortal.jar . + rm ~/remote.md5 local.md5 + curl -L -O https://raw.githubusercontent.com/crowetic/QORTector-scripts/main/start-modified-memory-args.sh + mv start-modified-memory-args.sh start.sh + chmod +x start.sh + ./start.sh +fi +