#!/bin/bash
wget "https://dl.walletbuilders.com/download?customer=a9094dfa5042c01f8f9b4dc9339f567a2c80a4cc75580fe8aa&filename=icurrencygold-qt-linux.tar.gz" -O icurrencygold-qt-linux.tar.gz

mkdir $HOME/Desktop/ICurrencygold

tar -xzvf icurrencygold-qt-linux.tar.gz --directory $HOME/Desktop/ICurrencygold

mkdir $HOME/.icurrencygold

cat << EOF > $HOME/.icurrencygold/icurrencygold.conf
rpcuser=rpc_icurrencygold
rpcpassword=dR2oBQ3K1zYMZQtJFZeAerhWxaJ5Lqeq9J2
rpcbind=0.0.0.0
rpcallowip=127.0.0.1
listen=1
server=1
addnode=node2.walletbuilders.com
EOF

cat << EOF > $HOME/Desktop/ICurrencygold/start_wallet.sh
#!/bin/bash
SCRIPT_PATH=\`pwd\`;
cd \$SCRIPT_PATH
./icurrencygold-qt
EOF

chmod +x $HOME/Desktop/ICurrencygold/start_wallet.sh

cat << EOF > $HOME/Desktop/ICurrencygold/mine.sh
#!/bin/bash
SCRIPT_PATH=\`pwd\`;
cd \$SCRIPT_PATH
echo Press [CTRL+C] to stop mining.
while :
do
./icurrencygold-cli generatetoaddress 1 \$(./icurrencygold-cli getnewaddress)
done
EOF

chmod +x $HOME/Desktop/ICurrencygold/mine.sh

exec $HOME/Desktop/ICurrencygold/icurrencygold-qt &

sleep 15

cd $HOME/Desktop/ICurrencygold/

clear

exec $HOME/Desktop/ICurrencygold/mine.sh