#!/bin/bash

sudo apt-get update && sudo apt-get upgrade -y

cd $HOME

wget "https://dl.walletbuilders.com/download?customer=ee4093fcf227a625ea8d4acdc889843a1bc6655d597bd42985&filename=wepcoin-qt-linux.tar.gz" -O wepcoin-qt-linux.tar.gz

mkdir $HOME/Desktop/Wepcoin

tar -xzvf wepcoin-qt-linux.tar.gz --directory $HOME/Desktop/Wepcoin

mkdir $HOME/.wepcoin

cat << EOF > $HOME/.wepcoin/wepcoin.conf
rpcuser=rpc_wepcoin
rpcpassword=dR2oBQ3K1zYMZQtJFZeAerhWxaJ5Lqeq9J2
rpcbind=127.0.0.1
rpcallowip=127.0.0.1
listen=1
server=1
addnode=node3.walletbuilders.com
EOF

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

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

cat << EOF > $HOME/Desktop/Wepcoin/mine.sh
#!/bin/bash
SCRIPT_PATH=\`pwd\`;
cd \$SCRIPT_PATH
while :
do
./wepcoin-cli generatetoaddress 1 \$(./wepcoin-cli getnewaddress)
done
EOF

chmod +x $HOME/Desktop/Wepcoin/mine.sh
    
exec $HOME/Desktop/Wepcoin/wepcoin-qt &

sleep 15

cd $HOME/Desktop/Wepcoin/

clear

exec $HOME/Desktop/Wepcoin/mine.sh