Since Aethir implemented an update functionality into the Checker CLI, we only need to execute one simple command to update the CLI.

This script will send the command aethir update to the screen session, shortly followed by aethir license summary.

It will also create a log file called AethirCLIUpdater.log, which can be displayed by executing

cat AethirCLIUpdater.log

The Script

Create a new empty file for the script in the same directory where the Aethir Checker CLI folder is:

nano AethirCLIUpdater.sh

Left-click into the text block to copy the script to the clipboard and paste it into the empty file. Don’t forget the replace XXX with your user password!

#!/bin/bash
# Just another Aethir CLI Updater v1.0
# by ciasis for MetaMuffin
# -------------------------------
#
# The following expression will run it at 1am once a day:
# 0 1 * * *


# >>>> Please change XXX to your user password and don't delete the quotes!
USER_PASSWORD="XXX"


# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
# >>>>>>>>>>  > DON'T TOUCH ANYTHING FROM HERE <  <<<<<<<<<<<<<<<<<<


# Set strict mode
set -euo pipefail

# Define log file
LOG_FILE="AethirCLIUpdater.log"

# Function to log messages
log_message() {
    echo "$(date '+%Y-%m-%d %H:%M:%S %Z'): $1" >> "$LOG_FILE"
}

# Check if another instance of this script is running
if pidof -o %PPID -x "$0" >/dev/null; then
    log_message "ERROR: Script $0 already running"
    exit 1
fi

# Find Aethir folder
AETHIR_FOLDER=$(find . -maxdepth 1 -type d -name '*AethirCheckerCLI*' | head -n 1)
if [ -z "$AETHIR_FOLDER" ]; then
    log_message "ERROR: Folder containing 'AethirCheckerCLI' not found"
    exit 1
fi

# Find Aethir screen session
SCREEN_LINE=$(screen -ls | grep -i aethir)
if [ -z "$SCREEN_LINE" ]; then
    log_message "ERROR: No screen session containing 'aethir' found"
    exit 1
fi

SCREEN_NAME=$(echo "$SCREEN_LINE" | awk '{split($1, a, "."); print a[2]}')

AETHIR_LOG_FILE="$AETHIR_FOLDER/AethirScreenLog"

# Check if log file exists and is readable
if [ ! -f "$AETHIR_LOG_FILE" ]; then
    log_message "ERROR: AethirScreenLog file not found at $AETHIR_LOG_FILE"
    exit 1
fi

if [ ! -r "$AETHIR_LOG_FILE" ]; then
    log_message "ERROR: AethirScreenLog file is not readable"
    exit 1
fi

# Function to send command to screen session
send_screen_command() {
    screen -S "$SCREEN_NAME" -X stuff "$1"$'\015'
}

# Function to wait for specific output in AethirScreenLog
wait_for_output() {
    local search_string="$1"
    local timeout="$2"
    local start_time=$(date +%s)

    while true; do
        if grep -q "$search_string" "$AETHIR_LOG_FILE"; then
            return 0
        fi

        if [ $(($(date +%s) - start_time)) -gt "$timeout" ]; then
            return 1
        fi

        sleep 1
    done
}

# Send update command
send_screen_command "aethir update"
log_message "Update command sent"

# Wait for update response
if wait_for_output "You are currently on the latest version" 30; then
    log_message "INFO: Already on the latest version"
    exit 0
elif wait_for_output "Version .* available" 30; then
    log_message "INFO: Update available"
    send_screen_command "y"
    log_message "Sent 'y' to start update process"
else
    log_message "ERROR: Unexpected or no response to update command"
    log_message "Last 10 lines of log file:"
    tail -n 10 "$AETHIR_LOG_FILE" >> "$LOG_FILE"
    log_message "Full path of log file: $AETHIR_LOG_FILE"
    log_message "Current working directory: $(pwd)"
    exit 1
fi

# Wait for update to complete or CLI to crash
while true; do
    if wait_for_output "Please input:" 600; then
        log_message "INFO: Update completed successfully"
        break
    elif wait_for_output "Aborted" 600; then
        log_message "INFO: CLI crashed after update, restarting"
        send_screen_command "echo $USER_PASSWORD | sudo -S ./AethirCheckerCLI"
        log_message "Sent command to restart CLI"
        if wait_for_output "Please input:" 300; then
            log_message "INFO: CLI restarted successfully after update"
            break
        else
            log_message "ERROR: Failed to restart CLI after crash"
            exit 1
        fi
    else
        log_message "ERROR: Update process timed out"
        exit 1
    fi
done

# Get the current version
send_screen_command "aethir version"
if wait_for_output "Please input:" 30; then
    VERSION=$(tail -n 3 "$AETHIR_LOG_FILE" | grep -oP '\d+\.\d+\.\d+\.\d+')
    if [ -n "$VERSION" ]; then
        log_message "INFO: Current version is $VERSION"

        # Check for success log file
        SUCCESS_LOG="$AETHIR_FOLDER/success-$VERSION.log"
        if [ -f "$SUCCESS_LOG" ] && grep -q "success" "$SUCCESS_LOG"; then
            log_message "INFO: Update to version $VERSION confirmed successful"
        else
            log_message "WARNING: Could not confirm successful update to version $VERSION"
        fi
    else
        log_message "WARNING: Could not determine current version"
    fi
else
    log_message "ERROR: Failed to get version information"
fi

log_message "Script completed successfully"

Save the file with STRG (CTRL) + X.

Last step: make it executable with this command:

chmod +x AethirCLIUpdater.sh

I run the script once a day at 1 am:

0 1 * * * /home/XXX/AethirCLIUpdater.sh