-
Notifications
You must be signed in to change notification settings - Fork 16
/
clone-build-install-bitcoind.sh
executable file
·45 lines (37 loc) · 1.25 KB
/
clone-build-install-bitcoind.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
#!/bin/bash
set -x
REPOURL=$1
BRANCH=$2
REPODIR=$3
BTCRPC_CONNECT=$4
BTCRPC_USER=$5
BTCRPC_PASSWORD=$6
BTCRPC_SSL=$7
BTCRPC_ALLOWIP=$8
USERNAME=`whoami`
BTCDIR="/var/lib/bitcoind"
# Clone and checkout using passed (usually from Vagrant) parameters
git clone --no-checkout $REPOURL $REPODIR
cd $REPODIR
git checkout $BRANCH
# Build bitcoind (Master Core)
./autogen.sh
./configure
make
# Install as an Upstart service
sudo ./contrib/msc-ubuntu/install-mastercore-upstart.sh
# Put the vagrant user (usually 'vagrant' or 'ubuntu') in the bitcoin group
# so that /etc/bitcoin/bitcoin.conf can be seen by bitcoin-cli/mastercore-cli
sudo usermod -a -G bitcoin $USERNAME
if [ $BTCRPC_SSL == "1" ] ; then
echo "Creating self-signed SSL certificate..."
# cd /var/lib/bitcoind
sudo openssl genrsa -out "${BTCDIR}/server.pem" 2048
sudo openssl req -new -x509 -nodes -sha1 -days 3650 -key "${BTCDIR}/server.pem" -batch -config /vagrant/openssl.cnf -out "${BTCDIR}/server.cert"
fi
sudo sed -i.bak -e "s#^.\(rpcuser=\)\(.*\)#\1${BTCRPC_USER}#" \
-e "s#^.\(rpcpassword=\)\(.*\)#\1${BTCRPC_PASSWORD}#" \
-e "s#^.\(rpcssl=\)\(.*\)#\1${BTCRPC_SSL}#" \
-e "s#^.\(rpcallowip=\)\(.*\)#\1${BTCRPC_ALLOWIP}#" \
/etc/bitcoin/bitcoin.conf
sudo service mastercored start