Since Aethir implemented an automated update function with version 1.0.2.6, I wanted to release my Node Checker Script without its update functionality, just to be on the safe side regarding the API access we use.
Remove the script first (it’s faster than deleting its content by holding the backspace key):
rm AethirNodeChecker.sh
Create a new script using nano:
nano AethirNodeChecker.sh
It’s important to replace XXX with the password of the user you logged into the VPS with. Don’t remove the quotation marks, the password must be inside them like on the screenshot:
Left-click into the text block to copy the script:
#! /bin/bash
#
# Aethir Node Checker v1.0 without auto-updates
# by ciasis for MetaMuffin
# ------------------------
#
# Disclaimer:
# The script should be used at one's own risk.
# I don't take responsibility for any losses.
# >>>> Please change XXX to your user password and don't delete the quotes!
USER_PASSWORD="XXX"
# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
# >>>>>>>>>> > DON'T TOUCH ANYTHING FROM HERE < <<<<<<<<<<<<<<<<<<
# ---------------------------------------------------------------
# Check if another instance of this script is running:
# ---------------------------------------------------------------
pidof -o %PPID -x $0 >/dev/null && echo "ERROR: Script $0 already running" >> AethirNodeChecker.log && exit 1
# ---------------------------------------------------------------
# Save the current Aethir node working directory:
# ---------------------------------------------------------------
FOLDER_NAME=$(ls -d */ | grep 'AethirCheckerCLI')
# ---------------------------------------------------------------
# Function to start the node:
# ---------------------------------------------------------------
function StartNode()
{
if [ -f "AethirScreenLog" ]; then
rm AethirScreenLog
fi
screen -mdS "Aethir" -L -Logfile "AethirScreenLog"
screen -S "Aethir" -X stuff 'bash'`echo -ne '\015'`
sleep 1
screen -S "Aethir" -X stuff 'sudo ./AethirCheckerCLI'`echo -ne '\015'`
sleep 2
screen -S "Aethir" -X stuff $USER_PASSWORD`echo -ne '\015'`
sleep 20
screen -S "Aethir" -X stuff 'aethir license summary'`echo -ne '\015'`
}
# ---------------------------------------------------------------
# Restart the node if the screen session is gone for some reason:
# ---------------------------------------------------------------
if ! screen -ls | grep -q "Aethir"; then
cd $FOLDER_NAME
StartNode
cd
echo "$(date): There was no active Aethir screen session found." >> AethirNodeChecker.log
echo "$(date): The Aethir node has been restarted in a new screen session." >> AethirNodeChecker.log
fi
# ---------------------------------------------------------------
# Restart the node if the screen session throws an error:
# ---------------------------------------------------------------
cd $FOLDER_NAME
if [ -f "AethirScreenLog" ]; then
lastline=$(tail -n 1 AethirScreenLog)
if [[ $lastline =~ "error" ]]; then
cd
echo "$(date): The Aethir node experienced an error and will be restarted now." >> AethirNodeChecker.log
ID=$(screen -ls | awk '/[0-9]+\.(.*Aethir.*)/ {print $1}' | cut -d'.' -f1)
screen -XS $ID quit
cd $FOLDER_NAME
StartNode
cd
echo "$(date): The Aethir node has been restarted in a new screen session." >> AethirNodeChecker.log
fi
else
cd
echo "$(date): There was no AethirScreenLog file found." >> AethirNodeChecker.log
fi
When pasting it into nano, don’t forget to set your user password which which you log in to the server. Replace XXX with this password.
Press STRG (CTRL) + X on your keyboard, then y, then the enter key.
Make the script executable:
chmod +x AethirNodeChecker.sh
That’s it, nothing else to do.