Last active
September 13, 2021 02:38
-
-
Save royalgarter/834662e43944a94ba56e65b0e0408c39 to your computer and use it in GitHub Desktop.
Setup Bitcoin Prune Node & LND on DigitalOcean Ubuntu 18.04 LTS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Prerequisites: | |
# 1/ ZeroMQ (for LN): https://gist.github.com/royalgarter/71abc75e1214bb39a1ef14a64639c17d | |
# Test after install bitcoin: btc getzmqnotifications | |
echo "########### This script was tested with DigitalOcean Ubuntu 18.04 LTS" | |
echo "########### The server will reboot when the script is complete" | |
echo "########### Changing to home dir" | |
cd ~ | |
echo "########### Updating Ubuntu" | |
add-apt-repository -y ppa:bitcoin/bitcoin | |
apt-get -y update | |
apt-get -y install software-properties-common python-software-properties htop | |
apt-get -y install software-properties-common | |
apt-get -y install git build-essential autoconf autotools-dev automake libboost-all-dev libssl-dev pkg-config libevent-dev bsdmainutils | |
apt-get -y install libprotobuf-dev protobuf-compiler libqt4-dev libqrencode-dev libtool | |
apt-get -y install libcurl4-openssl-dev db4.8 | |
apt-get -y install libdb4.8-dev libdb4.8++-dev | |
apt-get -y install screen nano | |
apt-get -y install libzmq3-dev | |
echo "########### Creating Swap" | |
dd if=/dev/zero of=/swapfile bs=1M count=2048 ; mkswap /swapfile ; swapon /swapfile | |
echo "/swapfile swap swap defaults 0 0" >> /etc/fstab | |
echo "########### Cloning Bitcoin and Compiling" | |
mkdir -p ~/src && cd ~/src | |
git clone https://github.com/bitcoin/bitcoin.git | |
cd bitcoin | |
./autogen.sh | |
./configure --without-gui --without-upnp --disable-tests --with-zmq --enable-zmq | |
make | |
make install | |
echo "########### Create Bitcoin User" | |
useradd -m bitcoin | |
echo "########### Creating config" | |
cd ~bitcoin | |
sudo -u bitcoin mkdir .bitcoin | |
config=".bitcoin/bitcoin.conf" | |
sudo -u bitcoin touch $config | |
echo "server=1" > $config | |
echo "daemon=1" >> $config | |
echo "connections=40" >> $config | |
randUser=`< /dev/urandom tr -dc A-Za-z0-9 | head -c30` | |
randPass=`< /dev/urandom tr -dc A-Za-z0-9 | head -c30` | |
echo "rpcuser=$randUser" >> $config | |
echo "rpcpassword=$randPass" >> $config | |
echo "zmqpubrawblock=tcp://127.0.0.1:28332" >> $config | |
echo "zmqpubrawtx=tcp://127.0.0.1:28333" >> $config | |
# uncomment if you want to run through Tor Proxy | |
# echo "proxy=127.0.0.1:9050" >> $config | |
# comment this prune line if you want to run a fullnode without prune (it will cost about 150GB at 2018-05-01) | |
# set prune amount to size of `/` 60% (and then by /1000 to turn KB to MB) => /1666 | |
echo "prune="$(expr $(df | grep '/$' | tr -s ' ' | cut -d ' ' -f 2) / 1666) >> $config # safe enough for now | |
cat .bitcoin/bitcoin.conf | |
echo "########### Changing to home dir" | |
cd ~ | |
echo "########### Setting up autostart (cron)" | |
echo -e '#!/bin/bash\nsudo -u bitcoin /usr/local/bin/bitcoind -datadir=/home/bitcoin/.bitcoin' > start.sh | |
chmod +x start.sh | |
cat start.sh | |
crontab -l > tempcron | |
echo "0 3 * * * reboot" >> tempcron | |
echo "@reboot sh /root/start.sh" >> tempcron | |
crontab tempcron | |
rm tempcron | |
echo "############ Add an alias for easy use" | |
echo "alias btc=\"sudo -u bitcoin bitcoin-cli -datadir=/home/bitcoin/.bitcoin\"" >> ~/.bashrc # example use: btc getinfo | |
reboot | |
# Install Go: https://tecadmin.net/install-go-on-ubuntu/ | |
# Install LND: https://github.com/lightningnetwork/lnd | |
# lnd.conf | |
# bitcoin.active=1 | |
# bitcoin.mainnet=1 | |
# debuglevel=debug | |
# bitcoin.node=bitcoind | |
# bitcoind.rpcuser= | |
# bitcoind.rpcpass= | |
# bitcoind.zmqpubrawblock=tcp://127.0.0.1:28332 | |
# bitcoind.zmqpubrawtx=tcp://127.0.0.1:28333 | |
# externalip=<Your public IP> | |
# Install Node: https://www.digitalocean.com/community/tutorials/how-to-install-node-js-on-ubuntu-18-04 | |
# Install RTL: https://github.com/ShahanaFarooqui/RTL |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Which disk block is it using?