forked from dArkjON/BTDX-Masternode-Setup-Ubuntu-1404
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathstart.sh
41 lines (37 loc) · 1.65 KB
/
start.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
#!/bin/bash
set -u
#
# Downloading bitcloud.conf
#
cd /tmp/
wget https://raw.githubusercontent.com/LIMXTEC/BTDX-Masternode-Setup/master/bitcloud.conf -O /tmp/bitcloud.conf
chown bitcloud:bitcloud /tmp/bitcloud.conf
#
# Set rpcuser, rpcpassword and masternode genkey
#
printf "** Set rpcuser, rpcpassword and masternode genkey ***\n"
mkdir -p /home/bitcloud/.bitcloud/
chown -R bitcloud:bitcloud /home/bitcloud/
sudo -u bitcloud cp /tmp/bitcloud.conf /home/bitcloud/.bitcloud/
sed -i "s|^\(rpcuser=\).*|rpcuser=btdxmasternode$(openssl rand -base64 32)|g" /home/bitcloud/.bitcloud/bitcloud.conf
sed -i "s|^\(rpcpassword=\).*|rpcpassword=$(openssl rand -base64 32)|g" /home/bitcloud/.bitcloud/bitcloud.conf
sed -i "s|^\(masternodeprivkey=\).*|masternodeprivkey=${MN_KEY}|g" /home/bitcloud/.bitcloud/bitcloud.conf
sed -i "s|^\(externalip=\).*|externalip=${BTDX_IP}|g" /home/bitcloud/.bitcloud/bitcloud.conf
RPC_ALLOWIP=$(ip addr | grep 'global eth0' | xargs | cut -f2 -d ' ')
sed -i "s#^\(rpcallowip=\).*#rpcallowip=${RPC_ALLOWIP}#g" /home/bitcloud/.bitcloud/bitcloud.conf
#
# Downloading bootstrap file
#
printf "** Downloading bootstrap file ***\n"
cd /home/bitcloud/.bitcloud/
if [ ! -d /home/bitcloud/.bitcloud/blocks ] && [ "$(curl -Is https://${WEB}/${BOOTSTRAP} | head -n 1 | tr -d '\r\n')" = "HTTP/1.1 200 OK" ] ; then \
sudo -u bitcloud wget https://${WEB}/${BOOTSTRAP}; \
sudo -u bitcloud tar -xvzf ${BOOTSTRAP}; \
sudo -u bitcloud rm ${BOOTSTRAP}; \
fi
#
# Starting Bitcloud Service
#
# Hint: docker not supported systemd, use of supervisord
printf "*** Starting Bitcloud Service ***\n"
exec /usr/bin/supervisord -n -c /etc/supervisor/supervisord.conf