forked from PACCommunity/PAC
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpacmn.sh
146 lines (126 loc) · 4.19 KB
/
pacmn.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
#!/bin/bash
set -e
echo "################################################"
echo "# Welcome to PAC Masternode's server setup #"
echo "################################################"
echo ""
read -p 'Please provide the external IP: ' ipaddr
read -p 'Please provide masternode genkey: ' mnkey
while [[ $ipaddr = '' ]] || [[ $ipaddr = ' ' ]]; do
read -p 'You did not provided an external IP, please provide one: ' ipaddr
sleep 2
done
while [[ $mnkey = '' ]] || [[ $mnkey = ' ' ]]; do
read -p 'You did not provided masternode genkey, please provide one: ' mnkey
sleep 2
done
echo "###############################"
echo "# Installing Dependencies #"
echo "###############################"
echo ""
echo "Running this script on Ubuntu 16.04 LTS is highly recommended (2GB RAM)"
sudo add-apt-repository -y ppa:bitcoin/bitcoin
sudo apt-get -y update
sudo apt-get -y install libminiupnpc-dev
sudo apt-get -y install libboost-all-dev
sudo apt-get -y install build-essential
sudo apt-get -y install libtool
sudo apt-get -y install autotools-dev
sudo apt-get -y install automake pkg-config
sudo apt-get -y install libssl-dev
sudo apt-get -y install libevent-dev bsdmainutils
sudo apt-get -y install git
sudo apt-get -y install libzmq3-dev
sudo apt-get -y install libdb4.8-dev
sudo apt-get -y install libdb4.8++-dev
sudo apt-get -y install virtualenv
sudo apt-get -y install ufw
sudo apt-get -y install pwgen
sudo apt-get -y install jq
echo "###############################"
echo "# Setting up the Firewall #"
echo "###############################"
sudo ufw status
sudo ufw disable
sudo ufw allow ssh/tcp
sudo ufw limit ssh/tcp
sudo ufw allow 7112/tcp
sudo ufw logging on
sudo ufw --force enable
sudo ufw status
sudo iptables -A INPUT -p tcp --dport '7112' -j ACCEPT
echo ""
echo "###############################"
echo "# Get/Setup binaries #"
echo "###############################"
echo ""
wget "https://github.com/PACCommunity/PAC/releases/download/v0.12.2.3/PAC-v0.12.2.3-ubuntu-16.04-x64.tar.gz"
tar xvf 'PAC-v0.12.2.3-ubuntu-16.04-x64.tar.gz'
cd ~/
rm PAC-v0.12.2.3-ubuntu-16.04-x64.tar.gz
currpath=$( pwd )
echo "Binaries got stored on: $currpath"
chmod +x paccoind
chmod +x paccoin-cli
echo "###############################"
echo "# Configure the wallet #"
echo "###############################"
echo ""
echo "The .paccoincore folder will be created, if folder already exists, it will be replaced"
if [ -d ~/.paccoincore ]; then
if [ -e ~/.paccoincore/paccoin.conf ]; then
read -p "The file paccoin.conf already exists and will be replaced. do you agree [y/n]:" cont
if [ $cont = 'y' ] || [ $cont = 'yes' ] || [ $cont = 'Y' ] || [ $cont = 'Yes' ]; then
sudo rm ~/.paccoincore/paccoin.conf
touch ~/.paccoincore/paccoin.conf
cd ~/.paccoincore
fi
fi
else
echo "Creating .paccoincore dir"
mkdir -p ~/.paccoincore
cd ~/.paccoincore
touch paccoin.conf
fi
echo "Configuring the paccoin.conf"
echo "rpcuser=$(pwgen -s 16 1)" > paccoin.conf
echo "rpcpassword=$(pwgen -s 64 1)" >> paccoin.conf
echo "rpcallowip=127.0.0.1" >> paccoin.conf
echo "rpcport=7111" >> paccoin.conf
echo "externalip=$ipaddr" >> paccoin.conf
echo "port=7112" >> paccoin.conf
echo "server=1" >> paccoin.conf
echo "daemon=1" >> paccoin.conf
echo "listen=1" >> paccoin.conf
echo "staking=0" >> paccoin.conf
echo "masternode=1" >> paccoin.conf
echo "masternodeaddr=$ipaddr:7112" >> paccoin.conf
echo "masternodeprivkey=$mnkey" >> paccoin.conf
echo "###############################"
echo "# Running the wallet #"
echo "###############################"
echo ""
cd ~/
./paccoind
sleep 60
syncedinfo=$( ./paccoin-cli mnsync status )
assetid=$( echo $syncedinfo | jq '.AssetID' )
if [ $assetid == 'null' ]; then
echo "Wallet is not running or there is an issue, please restart wallet!"
exit
fi
echo "###############################"
echo "# Running the sentinel #"
echo "###############################"
echo ""
git clone "https://github.com/PACCommunity/sentinel"
cd sentinel
virtualenv ./venv
./venv/bin/pip install -r requirements.txt
venv/bin/python bin/sentinel.py
sleep 3
crontab 'crontab.txt'
cd ~/
./paccoin-cli getinfo
echo "Your masternode server is ready!"
echo "Don't forget to run the masternode from your cold wallet!"