forked from dashpay/dash
-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathpacmn.sh
163 lines (140 loc) · 4.38 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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
#!/bin/bash
set -e
export LC_ALL="en_US.UTF-8"
if [ "$1" == "--testnet" ]; then
pac_rpc_port=17111
pac_port=17112
is_testnet=1
else
pac_rpc_port=7111
pac_port=7112
is_testnet=0
fi
arch=`uname -m`
version="0.12.6.0"
old_version="0.12.5.1"
base_url="https://github.com/PACCommunity/PAC/releases/download/v${version}"
if [ "${arch}" == "x86_64" ]; then
tarball_name="PAC-v${version}-linux-x86_64.tar.gz"
binary_url="${base_url}/${tarball_name}"
elif [ "${arch}" == "x86_32" ]; then
tarball_name="PAC-v${version}-linux-x86.tar.gz"
binary_url="${base_url}/${tarball_name}"
else
echo "PAC binary distribution not available for the architecture: ${arch}"
exit -1
fi
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 or newer is highly recommended."
sudo apt-get -y update
sudo apt-get -y install git python virtualenv ufw pwgen
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 $pac_port/tcp
sudo ufw logging on
sudo ufw --force enable
sudo ufw status
sudo iptables -A INPUT -p tcp --dport $pac_port -j ACCEPT
echo ""
echo "###############################"
echo "# Get/Setup binaries #"
echo "###############################"
echo ""
if test -e "${tarball_name}"; then
rm -r $tarball_name
fi
wget $binary_url
if test -e "${tarball_name}"; then
echo "Unpacking $PAC distribution"
tar -xvzf $tarball_name
chmod +x paccoind
chmod +x paccoin-cli
echo "Binaries were saved to: $PWD/$tarball_name"
rm -r $tarball_name
else
echo "There was a problem downloading the binaries, please try running again the script."
exit -1
fi
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=$pac_rpc_port" >> paccoin.conf
echo "externalip=$ipaddr" >> paccoin.conf
echo "port=$pac_port" >> paccoin.conf
echo "server=1" >> paccoin.conf
echo "daemon=1" >> paccoin.conf
echo "listen=1" >> paccoin.conf
echo "testnet=$is_testnet" >> paccoin.conf
echo "masternode=1" >> paccoin.conf
echo "masternodeaddr=$ipaddr:$pac_port" >> paccoin.conf
echo "masternodeprivkey=$mnkey" >> paccoin.conf
echo "###############################"
echo "# Running the wallet #"
echo "###############################"
echo ""
cd ~/
./paccoind
sleep 60
is_pac_running=`ps ax | grep -v grep | grep paccoind | wc -l`
if [ $is_pac_running -eq 0 ]; then
echo "The daemon is not running or there is an issue, please restart the daemon!"
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!"