Update auto-fix-qortal.sh
updated code for readability and updated comments for readability and wording improvements.
This commit is contained in:
parent
68e7c8b88a
commit
df19bb813a
@ -38,6 +38,7 @@ else
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
check_for_pi(){
|
check_for_pi(){
|
||||||
if command -v raspi-config >/dev/null 2>&1 ; then
|
if command -v raspi-config >/dev/null 2>&1 ; then
|
||||||
|
|
||||||
@ -75,6 +76,7 @@ else echo "${YELLOW} Not a Raspberry pi machine, continuing...${NC}\n"
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
check_qortal() {
|
check_qortal() {
|
||||||
echo "${YELLOW} Checking the version of qortal on local machine VS the version on github... ${NC}\n"
|
echo "${YELLOW} Checking the version of qortal on local machine VS the version on github... ${NC}\n"
|
||||||
|
|
||||||
@ -95,8 +97,9 @@ else
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
check_hash_update_qortal() {
|
check_hash_update_qortal() {
|
||||||
echo "${YELLOW} Your Qortal version is outdated or initial API call check failed. Proceeding to hash check, checking hash of qortal.jar on local machine VS newest released qortal.jar on github and updating your qortal.jar if needed... ${NC}\n"
|
echo "${RED}API-call-based version checking FAILED${NC}${YELLOW}. ${NC}${CYAN}Proceeding to HASH CHECK${NC}${YELLOW}, checking hash of qortal.jar on local machine VS newest released qortal.jar on github and updating your qortal.jar if needed... ${NC}\n"
|
||||||
cd ~/qortal || exit
|
cd ~/qortal || exit
|
||||||
md5sum qortal.jar > "local.md5"
|
md5sum qortal.jar > "local.md5"
|
||||||
cd
|
cd
|
||||||
@ -108,11 +111,11 @@ LOCAL=$(cat ~/qortal/local.md5)
|
|||||||
REMOTE=$(cat ~/remote.md5)
|
REMOTE=$(cat ~/remote.md5)
|
||||||
|
|
||||||
if [ "$LOCAL" = "$REMOTE" ]; then
|
if [ "$LOCAL" = "$REMOTE" ]; then
|
||||||
echo "${YELLOW} Hash check says your Qortal core is UP-TO-DATE, checking environment... ${NC}\n"
|
echo "${CYAN} Hash check says your Qortal core is UP-TO-DATE, checking environment... ${NC}\n"
|
||||||
check_for_GUI
|
check_for_GUI
|
||||||
exit 1
|
exit 1
|
||||||
else
|
else
|
||||||
echo "${RED} Hash check confirmed your qortal core is OUTDATED, updating, bootstrapping, and starting qortal...then checking environment and updating scripts... ${NC}\n"
|
echo "${RED} Hash check confirmed your qortal core is OUTDATED, ${NC}${YELLOW}updating, bootstrapping, and starting qortal...then checking environment and updating scripts... ${NC}\n"
|
||||||
cd qortal
|
cd qortal
|
||||||
killall -9 java
|
killall -9 java
|
||||||
sleep 3
|
sleep 3
|
||||||
@ -122,11 +125,13 @@ else
|
|||||||
rm ~/remote.md5 local.md5
|
rm ~/remote.md5 local.md5
|
||||||
./start.sh
|
./start.sh
|
||||||
cd
|
cd
|
||||||
|
|
||||||
check_for_GUI_already_bootstrapped
|
check_for_GUI_already_bootstrapped
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
check_for_GUI(){
|
|
||||||
|
check_for_GUI() {
|
||||||
if [ -n "$DISPLAY" ]; then
|
if [ -n "$DISPLAY" ]; then
|
||||||
echo "${CYAN} Machine is logged in via GUI, setting up auto-fix-visible for GUI-based machines... ${NC}\n"
|
echo "${CYAN} Machine is logged in via GUI, setting up auto-fix-visible for GUI-based machines... ${NC}\n"
|
||||||
echo "${YELLOW} Setting up auto-fix-visible on GUI-based system... first, creating new crontab entry without auto-fix-startup... ${NC}\n"
|
echo "${YELLOW} Setting up auto-fix-visible on GUI-based system... first, creating new crontab entry without auto-fix-startup... ${NC}\n"
|
||||||
@ -139,7 +144,7 @@ if [ -n "$DISPLAY" ]; then
|
|||||||
mkdir -p ~/.config/autostart
|
mkdir -p ~/.config/autostart
|
||||||
cp auto-fix-qortal-GUI.desktop ~/.config/autostart
|
cp auto-fix-qortal-GUI.desktop ~/.config/autostart
|
||||||
rm -rf ~/auto-fix-qortal-GUI.desktop
|
rm -rf ~/auto-fix-qortal-GUI.desktop
|
||||||
echo "${YELLOW} Your machine will now run 'auto-fix-qortal.sh' script in a fashion you can SEE, 7 MIN AFTER YOU REBOOT your machine. The normal 'background' process for auto-fix-qortal will continue as normal.${NC}\n"
|
echo "${YELLOW} Your machine will now run 'auto-fix-qortal.sh' script in a pop-up terminal, 7 MIN AFTER YOU REBOOT your machine. The normal 'background' process for auto-fix-qortal will continue as normal.${NC}\n"
|
||||||
echo "${CYAN} continuing to verify node height...${NC}\n"
|
echo "${CYAN} continuing to verify node height...${NC}\n"
|
||||||
|
|
||||||
check_height
|
check_height
|
||||||
@ -153,7 +158,8 @@ else echo "${YELLOW} Non-GUI system detected, skipping 'auto-fix-visible' setup.
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
check_for_GUI_already_bootstrapped(){
|
|
||||||
|
check_for_GUI_already_bootstrapped() {
|
||||||
if [ -n "$DISPLAY" ]; then
|
if [ -n "$DISPLAY" ]; then
|
||||||
echo "${CYAN} Machine is logged in via GUI, setting up auto-fix-visible for GUI-based machines... ${NC}\n"
|
echo "${CYAN} Machine is logged in via GUI, setting up auto-fix-visible for GUI-based machines... ${NC}\n"
|
||||||
echo "${YELLOW} Setting up auto-fix-visible on GUI-based system... first, creating new crontab entry without auto-fix-startup... ${NC}\n"
|
echo "${YELLOW} Setting up auto-fix-visible on GUI-based system... first, creating new crontab entry without auto-fix-startup... ${NC}\n"
|
||||||
@ -178,8 +184,8 @@ else echo "${YELLOW} Non-GUI system detected, skipping 'auto-fix-visible' setup
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
check_height() {
|
|
||||||
|
|
||||||
|
check_height() {
|
||||||
local_height=$(curl -sS "http://localhost:12391/blocks/height")
|
local_height=$(curl -sS "http://localhost:12391/blocks/height")
|
||||||
|
|
||||||
if [ -f auto_fix_last_height.txt ]; then
|
if [ -f auto_fix_last_height.txt ]; then
|
||||||
@ -210,6 +216,7 @@ fi
|
|||||||
remote_height_checks
|
remote_height_checks
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
no_local_height() {
|
no_local_height() {
|
||||||
# height checks failed, is qortal running?
|
# height checks failed, is qortal running?
|
||||||
# make another action here...
|
# make another action here...
|
||||||
@ -229,7 +236,7 @@ else
|
|||||||
for log_file in ~/qortal/log.t*; do
|
for log_file in ~/qortal/log.t*; do
|
||||||
if [ -f "$log_file" ]; then
|
if [ -f "$log_file" ]; then
|
||||||
old_log_found=true
|
old_log_found=true
|
||||||
echo "Old log method found, backing up old logs and updating logging method..."
|
echo "${YELLOW}Old log method found, backing up old logs and updating logging method...${NC}\n"
|
||||||
mkdir -p ~/qortal/backup/logs
|
mkdir -p ~/qortal/backup/logs
|
||||||
# Move old log files to the backup directory
|
# Move old log files to the backup directory
|
||||||
mv ~/qortal/log.t* ~/qortal/backup/logs
|
mv ~/qortal/log.t* ~/qortal/backup/logs
|
||||||
@ -266,11 +273,12 @@ if [ -n ${local_height_check} ]; then
|
|||||||
echo "${GREEN} node is GOOD, re-trying height check and continuing...${NC}\n"
|
echo "${GREEN} node is GOOD, re-trying height check and continuing...${NC}\n"
|
||||||
check_height_2
|
check_height_2
|
||||||
else
|
else
|
||||||
echo "${RED} starting Qortal Core FAILED... script will exit now until future updates add additional features...sorry the script couldn't resolve your issues! It will update automatically if you h ave it configured to run automatically! It is possible that the script will fix the issue IF YOU RESTART YOUR COMPUTER AND WAIT 15 MINUTES...${NC}\n"
|
echo "${RED} starting Qortal Core FAILED... script will exit now until future updates add additional features...sorry the script couldn't resolve your issues! It will update automatically if you have it configured to run automatically! ${NC}${CYAN}It is possible that the script will fix the issue IF YOU RESTART YOUR COMPUTER AND WAIT 15 MINUTES...${NC}\n"
|
||||||
update_script
|
update_script
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
remote_height_checks() {
|
remote_height_checks() {
|
||||||
height_api_qortal_org=$(curl -sS --connect-timeout 10 "https://api.qortal.org/blocks/height")
|
height_api_qortal_org=$(curl -sS --connect-timeout 10 "https://api.qortal.org/blocks/height")
|
||||||
height_qortal_link=$(curl -sS --connect-timeout 10 "https://qortal.link/blocks/height")
|
height_qortal_link=$(curl -sS --connect-timeout 10 "https://qortal.link/blocks/height")
|
||||||
@ -298,8 +306,8 @@ remote_height_checks() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
check_height_2() {
|
|
||||||
|
|
||||||
|
check_height_2() {
|
||||||
local_height=$(curl -sS "http://localhost:12391/blocks/height")
|
local_height=$(curl -sS "http://localhost:12391/blocks/height")
|
||||||
|
|
||||||
if [ -f auto_fix_last_height.txt ]; then
|
if [ -f auto_fix_last_height.txt ]; then
|
||||||
@ -321,8 +329,8 @@ fi
|
|||||||
|
|
||||||
if [ -z ${local_height} ]; then
|
if [ -z ${local_height} ]; then
|
||||||
echo "${RED} SECOND height check failed, unsure what is going on, but a restart of the node and waiting may fix it... ${NC}\n"
|
echo "${RED} SECOND height check failed, unsure what is going on, but a restart of the node and waiting may fix it... ${NC}\n"
|
||||||
echo "${RED} TRY RESTARTING THE COMPUTER and WAITING 15 MINUTES... ${NC}\n"
|
echo "${CYAN} TRY RESTARTING THE COMPUTER and WAITING 15 MINUTES... ${NC}\n"
|
||||||
echo "Updating script and continuing..."
|
|
||||||
update_script
|
update_script
|
||||||
else
|
else
|
||||||
echo ${local_height} > auto_fix_last_height.txt
|
echo ${local_height} > auto_fix_last_height.txt
|
||||||
@ -331,6 +339,7 @@ fi
|
|||||||
remote_height_checks
|
remote_height_checks
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
force_bootstrap() {
|
force_bootstrap() {
|
||||||
echo "${RED} height check found issues, forcing bootstrap... ${NC}\n"
|
echo "${RED} height check found issues, forcing bootstrap... ${NC}\n"
|
||||||
cd qortal
|
cd qortal
|
||||||
@ -343,7 +352,9 @@ cd
|
|||||||
update_script
|
update_script
|
||||||
}
|
}
|
||||||
|
|
||||||
update_script(){
|
|
||||||
|
update_script() {
|
||||||
|
echo "${YELLOW}Updating script to newest version and backing up old one...${NC}\n"
|
||||||
mkdir -p ~/qortal/new-scripts
|
mkdir -p ~/qortal/new-scripts
|
||||||
mkdir -p ~/qortal/new-scripts/backups
|
mkdir -p ~/qortal/new-scripts/backups
|
||||||
cp ~/qortal/new-scripts/auto-fix-qortal.sh ~/qortal/new-scripts/backups
|
cp ~/qortal/new-scripts/auto-fix-qortal.sh ~/qortal/new-scripts/backups
|
||||||
|
Loading…
x
Reference in New Issue
Block a user