-
Notifications
You must be signed in to change notification settings - Fork 1
/
luq_vps_masternode_hot_wallet.sh
189 lines (159 loc) · 5.47 KB
/
luq_vps_masternode_hot_wallet.sh
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
#!/bin/bash
TMP_FOLDER=$(mktemp -d)
CONFIG_FILE='luq.conf'
CONFIGFOLDER='.luq'
COIN_DAEMON='luqd'
COIN_CLI='luq-cli'
COIN_TGZ='https://github.com/luniquecoin/LuniqueCoin/releases/download/v3.0/luq_Linux.zip'
COIN_ZIP='luq_Linux.zip'
COIN_NAME='luq'
COIN_PORT=30000
RPC_PORT=30001
NODEIP=$(curl -s4 icanhazip.com)
RED='\033[0;31m'
GREEN='\033[0;32m'
NC='\033[0m'
function download_node() {
echo -e "Prepare to download $COIN_NAME binaries"
cd
wget -q $COIN_TGZ
unzip $COIN_ZIP
rm $COIN_ZIP
chmod +x $COIN_DAEMON $COIN_CLI
clear
}
function create_config() {
mkdir $CONFIGFOLDER >/dev/null 2>&1
RPCUSER=$(tr -cd '[:alnum:]' < /dev/urandom | fold -w10 | head -n1)
RPCPASSWORD=$(tr -cd '[:alnum:]' < /dev/urandom | fold -w22 | head -n1)
cat << EOF > $CONFIGFOLDER/$CONFIG_FILE
rpcuser=$RPCUSER
rpcpassword=$RPCPASSWORD
rpcallowip=127.0.0.1
listen=0
server=1
daemon=1
EOF
}
function create_key() {
echo -e "Leave it blank to generate a new ${RED}Masternode Private Key${NC} for you:"
if [[ -z "$COINKEY" ]]; then
./$COIN_DAEMON -daemon
sleep 30
if [ -z "$(ps axo cmd:100 | grep $COIN_DAEMON)" ]; then
echo -e "${RED}$COIN_NAME server couldn not start. Check /var/log/syslog for errors.{$NC}"
exit 1
fi
COINKEY=$(./$COIN_CLI masternode genkey)
if [ "$?" -gt "0" ];
then
echo -e "${RED}Wallet not fully loaded. Let us wait and try again to generate the Private Key${NC}"
sleep 30
COINKEY=$(./$COIN_CLI masternode genkey)
fi
./$COIN_CLI stop
fi
clear
}
function update_config() {
cat << EOF >> $CONFIGFOLDER/$CONFIG_FILE
masternode=1
externalip=$NODEIP
bind=$NODEIP
masternodeaddr=$NODEIP:$COIN_PORT
masternodeprivkey=$COINKEY
EOF
}
function get_ip() {
declare -a NODE_IPS
for ips in $(netstat -i | awk '!/Kernel|Iface|lo/ {print $1," "}')
do
NODE_IPS+=($(curl --interface $ips --connect-timeout 2 -s4 icanhazip.com))
done
if [ ${#NODE_IPS[@]} -gt 1 ]
then
echo -e "${GREEN}More than one IP. Please type 0 to use the first IP, 1 for the second and so on...${NC}"
INDEX=0
for ip in "${NODE_IPS[@]}"
do
echo ${INDEX} $ip
let INDEX=${INDEX}+1
done
read -e choose_ip
NODEIP=${NODE_IPS[$choose_ip]}
else
NODEIP=${NODE_IPS[0]}
fi
}
function checks() {
if [[ $(lsb_release -d) != *16.04* ]]; then
echo -e "${RED}You are not running Ubuntu 16.04. Installation is cancelled.${NC}"
exit 1
fi
if [[ $EUID -ne 0 ]]; then
echo -e "${RED}$0 must be run as root.${NC}"
exit 1
fi
if [ -n "$(pidof $COIN_DAEMON)" ] || [ -e "$COIN_DAEMOM" ] ; then
echo -e "${RED}$COIN_NAME is already installed.${NC}"
exit 1
fi
}
function prepare_system() {
echo -e "Prepare the system to install ${GREEN}$COIN_NAME${NC} master node."
apt-get update >/dev/null 2>&1
DEBIAN_FRONTEND=noninteractive apt-get update > /dev/null 2>&1
DEBIAN_FRONTEND=noninteractive apt-get -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" -y -qq upgrade >/dev/null 2>&1
apt install -y software-properties-common >/dev/null 2>&1
echo -e "${GREEN}Adding bitcoin PPA repository"
apt-add-repository -y ppa:bitcoin/bitcoin >/dev/null 2>&1
echo -e "Installing required packages, it may take some time to finish.${NC}"
apt-get update >/dev/null 2>&1
apt-get install -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" make software-properties-common \
build-essential libtool autoconf libssl-dev libboost-dev libboost-chrono-dev libboost-filesystem-dev libboost-program-options-dev \
libboost-system-dev libboost-test-dev libboost-thread-dev sudo automake git wget curl libdb4.8-dev bsdmainutils libdb4.8++-dev \
libminiupnpc-dev libgmp3-dev ufw pkg-config libevent-dev libdb5.3++ libzmq5 unzip>/dev/null 2>&1
if [ "$?" -gt "0" ];
then
echo -e "${RED}Not all required packages were installed properly. Try to install them manually by running the following commands:${NC}\n"
echo "apt-get update"
echo "apt -y install software-properties-common"
echo "apt-add-repository -y ppa:bitcoin/bitcoin"
echo "apt-get update"
echo "apt install -y make build-essential libtool software-properties-common autoconf libssl-dev libboost-dev libboost-chrono-dev libboost-filesystem-dev \
libboost-program-options-dev libboost-system-dev libboost-test-dev libboost-thread-dev sudo automake git curl libdb4.8-dev \
bsdmainutils libdb4.8++-dev libminiupnpc-dev libgmp3-dev ufw fail2ban pkg-config libevent-dev libzmq5"
exit 1
fi
clear
}
function important_information() {
echo
echo -e "================================================================================================================================"
echo -e "$COIN_NAME Masternode is up and running listening on port ${RED}$COIN_PORT${NC}."
echo -e "Configuration file is: ${RED}$CONFIGFOLDER/$CONFIG_FILE${NC}"
#echo -e "Start: ${RED}systemctl start $COIN_NAME.service${NC}"
#echo -e "Stop: ${RED}systemctl stop $COIN_NAME.service${NC}"
echo -e "VPS_IP:PORT ${RED}$NODEIP:$COIN_PORT${NC}"
echo -e "MASTERNODE PRIVATEKEY is: ${RED}$COINKEY${NC}"
#echo -e "Please check ${RED}$COIN_NAME${NC} is running with the following command: ${RED}systemctl status $COIN_NAME.service${NC}"
echo -e "================================================================================================================================"
}
function luq_start() {
sleep 10
./luqd
}
function setup_node() {
get_ip
create_config
create_key
update_config
important_information
luq_start
}
##### Main #####
clear
checks
prepare_system
download_node
setup_node