Skip to content

Instantly share code, notes, and snippets.

@mariodian
Last active November 7, 2019 04:55
Show Gist options
  • Save mariodian/c8ed248ad12e65020ec56546614e4ef8 to your computer and use it in GitHub Desktop.
Save mariodian/c8ed248ad12e65020ec56546614e4ef8 to your computer and use it in GitHub Desktop.
Update crypto nodes and services
#!/bin/bash
ARGS=$*
sudo apt-get update && sudo apt-get upgrade -y
needs_update() {
if [[ "$ARGS" == *force* ]]; then
git pull > /dev/null
else
git pull | grep "Already up to date."
fi
}
if [[ "$ARGS" == *all* || "$ARGS" == *nodes* || "$ARGS" == *bitcoin* ]]; then
echo "Updating Bitcoin"
cd ~/source/bitcoin
if [ -z "$(needs_update)" ]; then
git checkout 0.19
BDB_PREFIX=/home/satoshi/source/db-4.8.30.NC/build_unix/build
./autogen.sh
./configure BDB_LIBS="-L${BDB_PREFIX}/lib -ldb_cxx-4.8" BDB_CFLAGS="-I${BDB_PREFIX}/include" --disable-shared --enable-cxx --with-pic --without-gui
# ./configure --disable-shared --enable-cxx --with-pic --without-gui
make -j8
sudo service bitcoind stop
sudo cp ~/source/bitcoin/src/bitcoind /usr/local/bin/
sudo cp ~/source/bitcoin/src/bitcoin-cli /usr/local/bin/
sudo cp ~/source/bitcoin/src/bitcoin-tx /usr/local/bin/
sudo service bitcoind start
echo ""
else
echo "Nothing to build"
echo ""
fi
fi
if [[ "$ARGS" == *all* || "$ARGS" == *nodes* || "$ARGS" == *monero* ]]; then
echo "Updating Monero"
cd ~/source/monero
if [ -z "$(needs_update)" ]; then
git checkout master
git submodule update --init --force
make -j8 release
sudo service monerod stop
sudo cp ~/source/monero/build/Linux/master/release/bin/* /usr/local/bin/
sudo service monerod start
else
echo "Nothing to build"
echo ""
fi
fi
if [[ "$ARGS" == *all* || "$ARGS" == *nodes* || "$ARGS" == *grin* ]]; then
echo "Updating Grin"
cd ~/source/grin
if [ -z "$(needs_update)" ]; then
#git checkout master
git checkout current/3.0.x || git checkout current/2.1.x
cargo build --release
sudo service grin stop
sudo cp ~/source/grin/target/release/grin /usr/local/bin/grin
sudo service grin start
else
echo "Nothing to build"
echo ""
fi
fi
if [[ "$ARGS" == *all* || "$ARGS" == *services* || "$ARGS" == *lnd* ]]; then
echo "Updating LND"
cd $GOPATH/src/github.com/lightningnetwork/lnd
if [ -z "$(needs_update)" ]; then
git checkout master
make -j8 tags="autopilotrpc signrpc walletrpc chainrpc invoicesrpc routerrpc"
make install tags="autopilotrpc signrpc walletrpc chainrpc invoicesrpc routerrpc"
sudo service lnd stop && sudo service lnd start &
sleep 2s
lncli unlock
sleep 2s
lncli debuglevel --level DISC=critical
sudo service lndash restart
echo ""
else
echo "Nothing to build"
echo ""
fi
fi
if [[ "$ARGS" == *all* || "$ARGS" == *services* || "$ARGS" == *nbxplorer* ]]; then
echo "Updating NBXplorer"
cd ~/source/NBXplorer
if [ -z "$(needs_update)" ]; then
git checkout master
./build.sh
sudo service nbxplorer restart
echo ""
else
echo "Nothing to build"
echo ""
fi
fi
if [[ "$ARGS" == *all* || "$ARGS" == *services* || "$ARGS" == *btcpay* ]]; then
echo "Updating btcpayserver"
cd ~/source/btcpayserver
if [ -z "$(needs_update)" ]; then
git checkout master
./build.sh
sudo service btcpayserver restart
echo ""
else
echo "Nothing to build"
echo ""
fi
fi
if [[ "$ARGS" == *all* || "$ARGS" == *services* || "$ARGS" == *electrs* ]]; then
echo "Updating Electrs"
cd ~/source/electrs
if [ -z "$(needs_update)" ]; then
git checkout master
cargo build --release
sudo service electrs restart
echo ""
else
echo "Nothing to build"
echo ""
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment