#!/bin/bash
# Aria Energy VELA — on-start script for a rented NVIDIA GPU (image ubuntu:22.04).
# Docker options: -e WALLET=vela1YOURADDRESS [-e WORKER=myrig] [-e POOL=http://host:port] [-e EXTRA="--devices 0"]
set -u
: "${WALLET:?set -e WALLET=vela1YOURADDRESS in the docker options}"
WORKER=${WORKER:-rented}; POOL=${POOL:-http://159.69.194.46:3349}; EXTRA=${EXTRA:-}
V=1.1.0; K=aria-energy-vela-v$V-linux-x86_64.tar.gz; U=https://dl.ariabrain.com/vela-dl
SHA=c6ff64af916e2c69efc6701d88ed472dc7c72ce8551db4b8d638f18063e40f01
command -v wget >/dev/null || { apt-get update -qq && DEBIAN_FRONTEND=noninteractive apt-get install -y -qq wget ca-certificates >/dev/null; }
mkdir -p /root/vela && cd /root/vela || exit 1
if [ ! -x aria-energy-vela-v$V/run.sh ]; then
    wget -q "$U/$K" && echo "$SHA  $K" | sha256sum -c - && tar xzf "$K" || { echo "download or checksum failed"; exit 1; }
fi
cd aria-energy-vela-v$V || exit 1
nohup ./run.sh --wallet "$WALLET" --worker "$WORKER" -o "$POOL" --no-color $EXTRA > /root/vela/miner.log 2>&1 &
echo "Aria Energy VELA started (worker $WORKER), log: /root/vela/miner.log"
