Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
bonoproject committed Jan 22, 2020
0 parents commit 1ffe6f4
Show file tree
Hide file tree
Showing 3 changed files with 691 additions and 0 deletions.
44 changes: 44 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Guide for BonorumCoin Masternode Setup:


For **Ubuntu 16.04**
```
wget -q https://raw.githubusercontent.com/bonoproject/Masternode_Script/master/bonorum_16.04-mn.sh
sudo chmod +x bonorum_16.04-mn.sh
./bonorum_16.04-mn.sh
```
***

For **Ubuntu 18.04**
```
wget -q https://raw.githubusercontent.com/bonoproject/Masternode_Script/master/bonorum_18.04-mn.sh
sudo chmod +x bonorum_18.04-mn.sh
./bonorum_18.04-mn.sh
```
***

Do you want me to generate a masternode private key for you?[y/n]

- If you don't want to generate a masternode private key press **n**.

> Next ask for Private key:
> Enter your private key: Paste Your Masternode Private Key
> Confirm your private key: Again Paste Your Masternode Private Key for confirmation
**OR**

- If you want to generate a masternode private key press **y**.

Enter VPS Public IP Address: Paste your VPS Address

Wait till Node is fully Synced with blockchain.

`bonorumcoin-cli getinfo`

When Node is Fully Synced enter the command below to check the masternode status.

`bonorumcoin-cli getmasternodestatus`

You will get Masternode Successfully Started
324 changes: 324 additions & 0 deletions bonorum_16.04-mn.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,324 @@
#!/bin/bash
# BonorumCoin Masternode Setup Script V1 for Ubuntu 16.04 LTS
#
# Script will attempt to autodetect primary public IP address
# and generate masternode private key unless specified in command line
#
# Usage:
# bash bonorumcoin.autoinstall.sh
#

#Color codes
RED='\033[0;91m'
GREEN='\033[1;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color

#TCP port
PORT=1619
RPC=1618

#Clear keyboard input buffer
function clear_stdin { while read -r -t 0; do read -r; done; }

#Delay script execution for N seconds
function delay { echo -e "${GREEN}Sleep for $1 seconds...${NC}"; sleep "$1"; }

#Stop daemon if it's already running
function stop_daemon {
if pgrep -x 'bonorumcoin' > /dev/null; then
echo -e "${YELLOW}Attempting to stop bonorumcoin${NC}"
bonorumcoin-cli stop
sleep 30
if pgrep -x 'bonorumcoin' > /dev/null; then
echo -e "${RED}bonorumcoin daemon is still running!${NC} \a"
echo -e "${RED}Attempting to kill...${NC}"
sudo pkill -9 bonorumcoin
sleep 30
if pgrep -x 'bonorumcoin' > /dev/null; then
echo -e "${RED}Can't stop bonorumcoin! Reboot and try again...${NC} \a"
exit 2
fi
fi
fi
}
#Function detect_ubuntu

if [[ $(lsb_release -d) == *16.04* ]]; then
UBUNTU_VERSION=16
else
echo -e "${RED}You are not running Ubuntu 16.04, Installation is cancelled.${NC}"
exit 1

fi

#Process command line parameters
genkey=$1
clear

echo -e "${GREEN} ------- BonorumCoin MASTERNODE INSTALLER v1.0.0--------+
| |
| |::
| The installation will install and run |::
| the masternode under a user bonorumcoind. |::
| |::
| This version of installer will setup |::
| fail2ban and ufw for your safety. |::
| |::
+------------------------------------------------+::
::::::::::::::::::::::::::::::::::::::::::::::::::S${NC}"
echo "Do you want me to generate a masternode private key for you?[y/n]"
read DOSETUP

if [[ $DOSETUP =~ "n" ]] ; then
read -e -p "Enter your private key:" genkey;
read -e -p "Confirm your private key: " genkey2;
fi

#Confirming match
if [ $genkey = $genkey2 ]; then
echo -e "${GREEN}MATCH! ${NC} \a"
else
echo -e "${RED} Error: Private keys do not match. Try again or let me generate one for you...${NC} \a";exit 1
fi
sleep .5
clear

# Determine primary public IP address
dpkg -s dnsutils 2>/dev/null >/dev/null || sudo apt-get -y install dnsutils
publicip=$(dig +short myip.opendns.com @resolver1.opendns.com)

if [ -n "$publicip" ]; then
echo -e "${YELLOW}IP Address detected:" $publicip ${NC}
else
echo -e "${RED}ERROR: Public IP Address was not detected!${NC} \a"
clear_stdin
read -e -p "Enter VPS Public IP Address: " publicip
if [ -z "$publicip" ]; then
echo -e "${RED}ERROR: Public IP Address must be provided. Try again...${NC} \a"
exit 1
fi
fi
if [ -d "/var/lib/fail2ban/" ];
then
echo -e "${GREEN}Packages already installed...${NC}"
else
echo -e "${GREEN}Updating system and installing required packages...${NC}"

sudo DEBIAN_FRONTEND=noninteractive apt-get update -y
sudo apt-get -y upgrade
sudo apt-get -y dist-upgrade
sudo apt-get -y autoremove
sudo apt-get -y install wget nano htop jq
sudo apt-get -y install libzmq3-dev
sudo apt-get -y install libevent-dev -y
sudo apt-get install unzip
sudo apt install unzip
sudo apt -y install software-properties-common
sudo add-apt-repository ppa:bitcoin/bitcoin -y
sudo apt-get -y update
sudo apt-get -y install libdb4.8-dev libdb4.8++-dev -y
sudo apt-get -y install libminiupnpc-dev
sudo apt-get install -y unzip libzmq3-dev build-essential libssl-dev libboost-all-dev libqrencode-dev libminiupnpc-dev libboost-system1.58.0 libboost1.58-all-dev libdb4.8++ libdb4.8 libdb4.8-dev libdb4.8++-dev libevent-pthreads-2.0-5 -y
fi

#Network Settings
echo -e "${GREEN}Installing Network Settings...${NC}"
{
sudo apt-get install ufw -y
} &> /dev/null
echo -ne '[## ] (10%)\r'
{
sudo apt-get update -y
} &> /dev/null
echo -ne '[###### ] (30%)\r'
{
sudo ufw default deny incoming
} &> /dev/null
echo -ne '[######### ] (50%)\r'
{
sudo ufw default allow outgoing
sudo ufw allow ssh
} &> /dev/null
echo -ne '[########### ] (60%)\r'
{
sudo ufw allow $PORT/tcp
sudo ufw allow $RPC/tcp
} &> /dev/null
echo -ne '[############### ] (80%)\r'
{
sudo ufw allow 22/tcp
sudo ufw limit 22/tcp
} &> /dev/null
echo -ne '[################# ] (90%)\r'
{
echo -e "${YELLOW}"
sudo ufw --force enable
echo -e "${NC}"
} &> /dev/null
echo -ne '[###################] (100%)\n'

#Generating Random Password for JSON RPC
rpcuser=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)
rpcpassword=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)

#Create 2GB swap file
if grep -q "SwapTotal" /proc/meminfo; then
echo -e "${GREEN}Skipping disk swap configuration...${NC} \n"
else
echo -e "${YELLOW}Creating 2GB disk swap file. \nThis may take a few minutes!${NC} \a"
touch /var/swap.img
chmod 600 swap.img
dd if=/dev/zero of=/var/swap.img bs=1024k count=2000
mkswap /var/swap.img 2> /dev/null
swapon /var/swap.img 2> /dev/null
if [ $? -eq 0 ]; then
echo '/var/swap.img none swap sw 0 0' >> /etc/fstab
echo -e "${GREEN}Swap was created successfully!${NC} \n"
else
echo -e "${RED}Operation not permitted! Optional swap was not created.${NC} \a"
rm /var/swap.img
fi
fi

#Installing Daemon
cd ~
rm -rf /usr/local/bin/bonorumcoin*
wget https://github.com/bonoproject/Bonorum/releases/download/v1.0/Bonorumcoin-daemon-ubuntu_16.04.tar.gz
tar -xzvf Bonorumcoin-daemon-ubuntu_16.04.tar.gz
sudo chmod -R 755 bonorumcoin-cli
sudo chmod -R 755 bonorumcoind
cp -p -r bonorumcoind /usr/local/bin
cp -p -r bonorumcoin-cli /usr/local/bin

bonorumcoin-cli stop
sleep 5
#Create datadir
if [ ! -f ~/.bonorumcoin/bonorumcoin.conf ]; then
sudo mkdir ~/.bonorumcoin
fi

cd ~
clear
echo -e "${YELLOW}Creating bonorumcoin.conf...${NC}"

# If genkey was not supplied in command line, we will generate private key on the fly
if [ -z $genkey ]; then
cat <<EOF > ~/.bonorumcoin/bonorumcoin.conf
rpcuser=$rpcuser
rpcpassword=$rpcpassword
EOF

sudo chmod 755 -R ~/.bonorumcoin/bonorumcoin.conf

#Starting daemon first time just to generate masternode private key
bonorumcoind -daemon
sleep 7
while true;do
echo -e "${YELLOW}Generating masternode private key...${NC}"
genkey=$(bonorumcoin-cli createmasternodekey)
if [ "$genkey" ]; then
break
fi
sleep 7
done
fi

#Stopping daemon to create bonorumcoin.conf
bonorumcoin-cli stop
sleep 5
cd ~/.bonorumcoin/ && rm -rf blocks chainstate sporks zerocoin
cd ~/.bonorumcoin/ && wget https://github.com/bonoproject/Bonorum/releases/download/v1.0/bootstrap.zip
cd ~/.bonorumcoin/ && unzip bootstrap.zip
# Create bonorumcoin.conf
cat <<EOF > ~/.bonorumcoin/bonorumcoin.conf
rpcuser=$rpcuser
rpcpassword=$rpcpassword
rpcallowip=127.0.0.1
rpcport=$RPC
port=$PORT
listen=1
server=1
daemon=1
logtimestamps=1
maxconnections=256
masternode=1
externalip=$publicip
bind=$publicip
masternodeaddr=$publicip
masternodeprivkey=$genkey
addnode=64.225.44.198
addnode=64.225.42.27
addnode=167.71.119.39
addnode=157.245.179.133
addnode=157.245.238.186
addnode=167.172.115.119
addnode=64.225.34.73
EOF
bonorumcoind -daemon
#Finally, starting daemon with new bonorumcoin.conf
printf '#!/bin/bash\nif [ ! -f "~/.bonorumcoin/bonorumcoin.pid" ]; then /usr/local/bin/bonorumcoind -daemon ; fi' > /root/bonorumcoinauto.sh
chmod -R 755 bonorumcoinauto.sh
#Setting auto start cron job for bonorumcoin
if ! crontab -l | grep "bonorumcoinauto.sh"; then
(crontab -l ; echo "*/5 * * * * /root/bonorumcoinauto.sh")| crontab -
fi

echo -e "========================================================================
${GREEN}Masternode setup is complete!${NC}
========================================================================
Masternode was installed with VPS IP Address: ${GREEN}$publicip${NC}
Masternode Private Key: ${GREEN}$genkey${NC}
Now you can add the following string to the masternode.conf file
======================================================================== \a"
echo -e "${GREEN}bonorumcoind_mn1 $publicip:$PORT $genkey TxId TxIdx${NC}"
echo -e "========================================================================
Use your mouse to copy the whole string above into the clipboard by
tripple-click + single-click (Dont use Ctrl-C) and then paste it
into your ${GREEN}masternode.conf${NC} file and replace:
${GREEN}bonorumcoind_mn1${NC} - with your desired masternode name (alias)
${GREEN}TxId${NC} - with Transaction Id from getmasternodeoutputs
${GREEN}TxIdx${NC} - with Transaction Index (0 or 1)
Remember to save the masternode.conf and restart the wallet!
To introduce your new masternode to the bonorumcoin network, you need to
issue a masternode start command from your wallet, which proves that
the collateral for this node is secured."

clear_stdin
read -p "*** Press any key to continue ***" -n1 -s

echo -e "Wait for the node wallet on this VPS to sync with the other nodes
on the network. Eventually the 'Is Synced' status will change
to 'true', which will indicate a comlete sync, although it may take
from several minutes to several hours depending on the network state.
Your initial Masternode Status may read:
${GREEN}Node just started, not yet activated${NC} or
${GREEN}Node is not in masternode list${NC}, which is normal and expected.
"
clear_stdin
read -p "*** Press any key to continue ***" -n1 -s

echo -e "
${GREEN}...scroll up to see previous screens...${NC}
Here are some useful commands and tools for masternode troubleshooting:
========================================================================
To view masternode configuration produced by this script in bonorumcoin.conf:
${GREEN}cat ~/.bonorumcoin/bonorumcoin.conf${NC}
Here is your bonorumcoin.conf generated by this script:
-------------------------------------------------${GREEN}"
echo -e "${GREEN}bonorumcoind_mn1 $publicip:$PORT $genkey TxId TxIdx${NC}"
cat ~/.bonorumcoin/bonorumcoin.conf
echo -e "${NC}-------------------------------------------------
NOTE: To edit bonorumcoin.conf, first stop the bonorumcoin daemon,
then edit the bonorumcoin.conf file and save it in nano: (Ctrl-X + Y + Enter),
then start the bonorumcoin daemon back up:
to stop: ${GREEN}bonorumcoin-cli stop${NC}
to start: ${GREEN}bonorumcoind${NC}
to edit: ${GREEN}nano ~/.bonorumcoin/bonorumcoin.conf${NC}
to check mn status: ${GREEN}bonorumcoin-cli getmasternodestatus${NC}
========================================================================
To monitor system resource utilization and running processes:
${GREEN}htop${NC}
========================================================================
"
Loading

0 comments on commit 1ffe6f4

Please sign in to comment.