#!/bin/bash
Webmin=${Webmin^^}
MadMax=${MadMax^^}
GigaHorse=${GigaHorse^^}
BladeBit=${BladeBit^^}
ChiaPos=${ChiaPos^^}
Miner=${Miner^^}

Webmin=$(grep "Webmin=" /home/wareck/Build_Cube/build_cube.sh  | cut -d '"' -f 2)
driver=$(grep "driver=" /home/wareck/Build_Cube/build_cube.sh  | sed 's/driver=//g')
Cuda=$(grep "Cuda=" /home/wareck/Build_Cube/build_cube.sh  | sed 's/Cuda=//g')
driver=${driver^^}
Cuda=${Cuda^^}

if [ ! -d temp ]; then
mkdir temp
fi
cd temp

function download_copy {
FILE=/home/wareck/Build_Cube/pack/$box
if [ ! -f "$FILE" ]; then
wget -c -q --show-progress http://folivier.homelinux.org/cube/pack/$box
cp $box /home/wareck/Build_Cube/pack/$box
fi
}

box=cgminer.conf
download_copy

box=chia-miner.tar.xz
download_copy

box=gerbera.tar.xz
download_copy

box=start_cgminer.tar.xz
download_copy

box=$Webmin.tar.xz
download_copy

box=xmrig.tar.xz
download_copy

box=zfsmanager-0.0.4.wbm.gz
download_copy

box=flexfarmer.tar.xz
download_copy

if [ $driver = "AMD" ]
then
box=amdgpu-install_5.4.50403-1_all.deb
download_copy
fi

if [ $Cuda = "YES" ]
then
#box=cuda_11.8.0_520.61.05_linux.run
#box=cuda_12.2.2_535.104.05_linux.run
#download_copy
box=chia-x-proxy.tar.xz
download_copy
fi

box=linux-firmware.tar.xz
download_copy

box=gpu-miners.tar.xz
download_copy

cd ..
rm -r -f temp

echo -e "finish."
