-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmasternode-setup.sh
executable file
·132 lines (130 loc) · 4.33 KB
/
masternode-setup.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
#!/bin/bash
#please do this script as root.
######################################################################
#Check option
while :
do
case "$1" in
-v | --version)
version="$2" #get version data
shift 2
;;
-u | --update)
install=0
update=1
shift
;;
-i | --install)
install=1
update=0
shift
;;
-g | --generate)
generate=1
shift
;;
-*)
echo "Error: Invalid option: $1" > $2
exit 1
;;
*)
break
;;
esac
done
# Generate masternode private key
function generate_privkey() {
mkdir -p /etc/masternodes/
echo -e "rpcuser=test\nrpcpassword=passtest" >> /etc/masternodes/phore_test.conf
phored -daemon -conf=/etc/masternodes/phore_test.conf -datadir=/etc/masternodes >> mn.log
sleep 5
mngenkey=$(phore-cli -conf=/etc/masternodes/phore_test.conf -datadir=/etc/masternodes masternode genkey)
phore-cli -conf=/etc/masternodes/phore_test.conf -datadir=/etc/masternodes stop >> mn.log
sleep 5
rm -r /etc/masternodes/
}
# Make masternode.conf for ppl
function create_mnconf() {
echo phore-MN01 $ipaddress:11771 $mngenkey TRANSACTION_ID TRANSACTION_INDEX >> tmp_masternode.conf
cat tmp_masternode.conf
}
echo " "
echo "*********** Welcome to the Phore (PHR) Masternode Setup Script ***********"
echo 'This script will install all required updates & package for Ubuntu 16.04 !'
echo 'This script will install phore masternode.'
echo 'You can run this script on VPS only.'
echo '****************************************************************************'
echo '*** Installing package ***'
apt-get update -qqy
apt-get upgrade -qqy
apt-get dist-upgrade -qqy
apt-get install -qqy nano htop git wget
echo '*** Step 2/4 ***'
echo '*** Configuring firewall ***'
apt-get install -qqy ufw
ufw allow ssh/tcp >> mn.log
ufw limit ssh/tcp >> mn.log
ufw allow 11771/tcp >> mn.log
ufw logging on >> mn.log
ufw --force enable >> mn.log
ufw status >> mn.log
phore-cli stop &>> mn.log
./phore-cli stop &>> mn.log
echo '*** Step 3/4 ***'
if [ -e /usr/local/bin/phored -o -e phored ]; then
echo '***Backup your existing phored. If you want to restore, please check PHORE_DATE ***'
mkdir PHORE_`date '+%Y%m%d'` >> mn.log
mv /usr/local/bin/phored /usr/local/bin/phore-cli /usr/local/bin/phore-tx ~/PHORE_`date '+%Y%m%d'` &>> mn.log
mv ~/phored ~/phore-cli ~/phore-tx ~/PHORE_`date '+%Y%m%d'` &>> mn.log
fi
echo '*** Step 4/4 ***'
echo '***Installing phore wallet daemon***'
wget -nv https://github.com/phoreproject/Phore/releases/download/v${version}/phore-${version}-x86_64-linux-gnu.tar.gz >> mn.log
tar -xvzf phore-${version}-x86_64-linux-gnu.tar.gz >> mn.log
version=${version:0:5}
cd phore-${version}/bin
mv phore* /usr/local/bin/
cd
rm phore-${version}-x86_64-linux-gnu.tar.gz
rm -r phore-${version}
if [ $update -eq 1 ]; then
echo "Updating"
phored -daemon
phore-cli getinfo
echo "Finish Updating"
echo "Check version data."
echo "After checking, please restart Phore masternode from phore-qt"
echo "***End***"
elif [ $install -eq 1 ]; then
echo '*** Install and configuring masternode settings ***'
mkdir .phore
rpcusr=$(more /dev/urandom | tr -d -c '[:alnum:]' | fold -w 20 | head -1)
rpcpass=$(more /dev/urandom | tr -d -c '[:alnum:]' | fold -w 20 | head -1)
ipaddress=$(curl -s inet-ip.info)
if [ $generate -eq 1 ]; then
generate_privkey
else
echo "Enter or paste masternode private key"
read mngenkey
while [ ${#mngenkey} -ne 51 ]
do
echo "Invalid masternode private key. please reinput."
read mngenkey
done
fi
echo -e "rpcuser=$rpcusr\nrpcpassword=$rpcpass\nrpcallowip=127.0.0.1\nlisten=1\nserver=1\ndaemon=1\nstaking=0\nmasternode=1\nlogtimestamps=1\nmaxconnections=256\nexternalip=$ipaddress\nbind=$ipaddress\nmasternodeaddr=$ipaddress:11771\nmasternodeprivkey=$mngenkey\n" > ~/.phore/phore.conf
echo '*** Start syncing ***'
phored -daemon &>> mn.log
echo 'After 10sec, I will show you the outputs of getinfo'
sleep 10
phore-cli getinfo
echo 'After fully syncing, you can start phore masternode.'
echo 'There is example line for masternode.conf. Please copy this line and paste to your masternode.conf'
echo " "
create_mnconf
echo " "
echo 'You can check the line by entering **cat tmp_masternode.conf** '
else
echo "Invalid command, or argument. If you want to update, use '-u', to install, use '-i'."
echo "**END**"
fi