-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathcheesesetup
124 lines (118 loc) · 5.93 KB
/
cheesesetup
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#!/bin/bash
#THIS SCRIPT MUST BE RAN AS ROOT
#Variables
declare -i nodes=0 #The number of nodes currently installed
declare -i addnodes=0 #The number of nodes to add
declare -i nodesadded=0 #The number of nodes added
declare -a mnkeys=() #The array to store the masternode private keys
declare -i rpcport=44766 #Default rpc port
declare -i port=44700 #Default port
#The array that holds names of all required packages
declare -a packages=("software-properties-common" "build-essential" "libtool" "autotools-dev" "automake" "pkg-config" "libssl-dev" "libevent-dev" "bsdmainutils" "libboost-all-dev" "libdb4.8-dev" "libdb4.8++-dev" "libminiupnpc-dev" "libzmq3-dev" "git" "nano" "tmux" "libgmp3-dev")
#This function checks how many nodes are installed and will install wallet if needed
check_cheese_nodes() {
echo "****************************************************************************"
echo "* Ubuntu 16.04 is the recommended opearting system for this install. *"
echo "* *"
echo "* This script will install and configure your $(tput setaf 3)CHEESE$(tput sgr0) masternodes. *"
echo "****************************************************************************"
echo "Welcome to the $(tput setaf 3)CHEESE$(tput sgr0) masternode setup script"
sleep 2
nodes+=$( find /root/ -type d -name '.Cheese*[0-9]' | wc -l ) >/dev/null 2>&1
}
#This function takes in user information for setup
config() {
echo "You currently have $(tput setaf 3)$nodes$(tput sgr0) nodes installed on this device"
sleep 2
echo "How many nodes do you want to add to this system?"
read addnodes
declare -i current=0
while [[ $current -lt $addnodes ]]
do
echo "Please enter node $((current+1)) masternode genkey."
echo "$(tput setaf 1)MAKE SURE THAT YOU ENTERED THE MASTERNODE GENKEY EXACTLY BEFORE YOU HIT [ENTER]$(tput sgr0)"
read mnkeys[$current]
echo "You entered $(tput setaf 3)${mnkeys[$current]}$(tput sgr0) as your first masternode genkey"
current+=1
done
echo "This is the end of the required user input. You may leave this running to complete on its own"
}
#This function will install the CHEESE wallet
install_wallet() {
if [ -d "/root/CheeseMasternode" ]; then
return 0
fi
echo "You do not have the $(tput setaf 3)CHEESE$(tput sgr0) wallet installed on this device"
sleep 2
echo "ADDING 2GB SWAP FILE"
sleep 2
dd if=/dev/zero of=/mnt/cheeseswap.swap bs=2M count=1000 >/dev/null 2>&1
mkswap /mnt/cheeseswap.swap >/dev/null 2>&1
swapon /mnt/cheeseswap.swap >/dev/null 2>&1
echo "RUNNING UPDATES AND INSTALLING ALL REQUIRED PACKAGES"
sudo apt-get update -y >/dev/null 2>&1
sudo add-apt-repository ppa:bitcoin/bitcoin -y >/dev/null 2>&1
sudo apt-get update -y >/dev/null 2>&1
declare -i current=0
for i in "${packages[@]}"; do
if ! { sudo apt-get install "${packages[current]}" -y >/dev/null 2>&1 || echo E: update failed; } | grep -q '^[WE]:'; then
echo "$(tput setaf 2)${packages[current]}$(tput sgr0) successfully installed or updated"
else
echo "$(tput setaf 1)${packages[current]}$(tput sgr0) failed to install"
exit 1
fi
current+=1
done
echo "DOWNLOADING CHEESE WALLET"
git clone https://github.com/CheeseCoin/CheeseMasternode >/dev/null 2>&1
echo "INSTALLING $(tput setaf 3)CHEESE$(tput sgr0) WALLET"
sleep 2
echo "THIS PROCESS WILL TAKE A LONG TIME WITHOUT ANY OUTPUT ON THE SCREEN"
cd CheeseMasternode/src/leveldb && chmod 777 * && cd .. && make -f makefile.unix >/dev/null 2>&1
}
#This function will add additional nodes
add_nodes() {
declare -i current=$((nodes+1))
declare -i total=$((nodes+addnodes))
while [[ $current -lt $total ]] || [[ $current -eq $total ]]
do
echo "Configuring $(tput setaf 3)CHEESE$(tput sgr0) node $current"
mkdir /root/.Cheese$current
touch /root/.Cheese$current/Cheese.conf
usrnam=$(tr -cd '[:alnum:]' < /dev/urandom | fold -w10 | head -n1)
usrpas=$(tr -cd '[:alnum:]' < /dev/urandom | fold -w22 | head -n1)
vpsip=$(curl -s4 icanhazip.com)
echo -e "rpcuser=$usrnam \nrpcpassword=$usrpas \nrpcport=$((rpcport+current)) \nlisten=1 \nserver=1 \ndaemon=1 \nrpcallowip=127.0.0.1 \n \nport=$((port+current)) \nmasternode=1 \nmasternodeaddr=$vpsip:$((port+current)) \nmasternodeprivkey=${mnkeys[$nodesadded]} \n" > /root/.Cheese$current/Cheese.conf
/root/CheeseMasternode/src/cheesed -datadir=/root/.Cheese$current -config=/root/.Cheese$current/Cheese.conf -daemon >/dev/null 2>&1
echo "alias cheesed$current='/root/CheeseMasternode/src/cheesed -datadir=/root/.Cheese$current -config=/root/.Cheese$current/Cheese.conf'" >> /root/.bashrc
sudo ufw allow $((port+current)) >/dev/null 2>&1
nodesadded+=1
current+=1
sleep 2
done
}
conclusion() {
echo 'Wait until the blockchain is synced to start each alias.'
sleep 2
echo 'Enjoy your Masternodes!'
sleep 2
echo "****************************************************************************"
echo "* $(tput setaf 3)USEFUL CHEESED COMMANDS$(tput sgr0) *"
echo "****************************************************************************"
echo '*-daemon - This command is used to start the daemon *'
echo '*stop - This command is used to stop the daemon *'
echo '*getinfo - This command can be used to check block height *'
echo '*masternode status - This command is used to view masternode status. *'
echo '*masternode debug - This command can be used if you do not get status 9 *'
echo "****************************************************************************"
echo "* To use each command, it must be preceeded by $(tput setaf 3)cheesed#$(tput sgr0) *"
echo "****************************************************************************"
exit 0
}
#main
clear
check_cheese_nodes
config
install_wallet
add_nodes
conclusion