#!/bin/bash
# Check if process is running
if pgrep -x "start_qrl" >/dev/null
then
	echo "Your QRL node is running."
	exit;
fi

echo "Downloading latest.tar.gz + sha512sums"

# Download files
curl -O https://bootstrap.theqrlcontributors.org/latest.tar.gz
curl -O https://bootstrap.theqrlcontributors.org/sha512sums.txt 

# Checking sha512sum
echo "Checking sha512sum"
if sha512sum -c sha512sums.txt; then
	echo "latest.tar.gz passed the checksum"
	echo "Decompressing to ~/.qrl/data/state"
	mkdir -p ~/.qrl/data/state/
	tar -xzf latest.tar.gz --directory ~/.qrl/data/
else 
	echo "latest.tar.gz didn't pass the checksum."
	exit;
fi

echo "Great! Now you can start your qrl node with: start_qrl"
