#!/bin/bash
Nversion="`curl -s http://folivier.homelinux.org/miniminer/build.sh | awk -F "=" 'NR==2 {print$2; exit}'| awk -F "." '{print$1$2}'`"
int=${Nversion%.*}

echo -e "\e[93mMiniMiner build.sh downloader:\e[0m"

if [ -f build.sh ]
then
Oversion="`cat build.sh | awk -F "=" 'NR==2 {print$2; exit}' | awk -F "." '{print$1$2}'`"
int=${Oversion%.*}
if [ "$Oversion" -eq "$Nversion" ]
then
echo -e "\nNo update needed."
echo "You are already up to date."
echo ""
else
if [ "$Oversion" -gt "$Nversion" ]
then
echo
echo "You have a new version (dev): exit"
echo ""
exit
fi

echo "New version available : download"
rm build.sh
fi
fi

if [ ! -f build.sh ]
then
echo -e "\nDownload build.sh:"
wget -q --show-progress http://folivier.homelinux.org/miniminer/build.sh
chmod +x build.sh
echo ""
fi

echo -e "use command ./build.sh to start build miners.\n"
