forked from dArkjON/BSD-Masternode-Setup-1604
-
Notifications
You must be signed in to change notification settings - Fork 1
/
start.sh
executable file
·60 lines (53 loc) · 1.9 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/bin/bash
set -u
CONFIG=${CONFIG_PATH}/bitsend.conf
CONFIG_REUSE=${CONFIG_PATH}/.bitsend.conf
#
# Downloading bitsend.conf
#
cd /tmp/
wget https://raw.githubusercontent.com/dalijolijo/BSD-Masternode-Setup/master/bitsend.conf -O /tmp/bitsend.conf
chown bitsend:bitsend /tmp/bitsend.conf
#
# Configure bitsend.conf
#
printf "** Configure bitsend.conf ***\n"
mkdir -p ${CONFIG_PATH}
chown -R bitsend:bitsend /home/bitsend/
if [ -f ${CONFIG_REUSE} ] ; then
sudo -u bitsend mv ${CONFIG_REUSE} ${CONFIG}
else
sudo -u bitsend cp /tmp/bitsend.conf ${CONFIG}
sed -i "s#^\(rpcuser=\).*#rpcuser=bsd$(openssl rand -base64 32 | tr -d '[:punct:]')#g" ${CONFIG}
sed -i "s#^\(rpcpassword=\).*#rpcpassword=$(openssl rand -base64 32 | tr -d '[:punct:]')#g" ${CONFIG}
sed -i "s|^\(masternode=\).*|masternode=${MASTERNODE}|g" ${CONFIG}
sed -i "s|^\(txindex=\).*|txindex=${TXINDEX}|g" ${CONFIG}
sed -i "s|^\(masternodeprivkey=\).*|masternodeprivkey=${MN_KEY}|g" ${CONFIG}
sed -i "s|^\(externalip=\).*|externalip=${BSD_IP}|g" ${CONFIG}
RPC_ALLOWIP=$(ip addr | grep 'global eth0' | xargs | cut -f2 -d ' ')
sed -i "s#^\(rpcallowip=\).*#rpcallowip=${RPC_ALLOWIP}#g" ${CONFIG}
fi
#
# Changes for ElectrumX
#
if [[ "$ELECTRUM" == "y" ]]; then
sed -i -e '/mnconflock/d' ${CONFIG}
sed -i -e '/promode/d' ${CONFIG}
sed -i -e '/masternodeprivkey/d' ${CONFIG}
fi
#
# Downloading bootstrap file
#
printf "** Downloading bootstrap file ***\n"
cd ${CONFIG_PATH}
if [ ! -d ${CONFIG_PATH}/blocks ] && [ "$(curl -Is https://${WEB}/${BOOTSTRAP} | head -n 1 | tr -d '\r\n')" = "HTTP/1.1 200 OK" ] ; then \
sudo -u bitsend wget https://${WEB}/${BOOTSTRAP}; \
sudo -u bitsend tar -xvzf ${BOOTSTRAP}; \
sudo -u bitsend rm ${BOOTSTRAP}; \
fi
#
# Step Starting BitSend Service
#
# Hint: docker not supported systemd, use of supervisord
printf "*** Starting BitSend Service ***\n"
exec /usr/bin/supervisord -n -c /etc/supervisor/supervisord.conf