Skip to content

Commit

Permalink
update bitcoin core to v25.0 (#133)
Browse files Browse the repository at this point in the history
* update bitcoin core to v25.0
* fix version check
* add the joinmarket user to the bitcon group
  • Loading branch information
openoms authored Jun 16, 2023
1 parent b1e933d commit ec556ab
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 39 deletions.
53 changes: 18 additions & 35 deletions scripts/_functions.bitcoincore.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,53 +9,38 @@ joininConfPath="/home/joinmarket/joinin.conf"
function downloadBitcoinCore() {
# set version
# https://bitcoincore.org/en/download/
bitcoinVersion="22.0"
bitcoinVersion="25.0"

# https://github.com/laanwj
PGPname="Wladimir J. van der Laan"
PGPpubkey="74810B012346C9A6"
if bitcoin-cli --version | grep $bitcoinVersion >/dev/null; then
echo "# Bitcoin Core $bitcoinVersion is already installed"
return 0
fi

echo
echo "# *** PREPARING BITCOIN ***"
# prepare directories
sudo -u joinmarket mkdir /home/joinmarket/download 2>/dev/null
cd /home/joinmarket/download || exit 1

# receive signer key
if ! gpg -k | grep "${PGPpubkey}"; then
if ! gpg --keyserver hkp://keyserver.ubuntu.com --recv-key "${PGPpubkey}"; then
echo "# FAIL - Couldn't download ${PGPname}'s PGP pubkey"
exit 1
fi
fi
echo "# Receive signer keys"
curl -s "https://api.github.com/repos/bitcoin-core/guix.sigs/contents/builder-keys" |
jq -r '.[].download_url' | while read url; do curl -s "$url" | gpg --import; done

# download signed binary sha256 hash sum file
if [ ! -f SHA256SUMS ]; then
sudo -u joinmarket wget --prefer-family=ipv4 --progress=bar:force https://bitcoincore.org/bin/bitcoin-core-${bitcoinVersion}/SHA256SUMS
fi
# download signed binary sha256 hash sum file and check
if [ ! -f SHA256SUMS.asc ]; then
sudo -u joinmarket wget --prefer-family=ipv4 --progress=bar:force https://bitcoincore.org/bin/bitcoin-core-${bitcoinVersion}/SHA256SUMS.asc
fi
verifyResult=$(gpg --verify SHA256SUMS.asc 2>&1)
goodSignature=$(echo ${verifyResult} | grep 'Good signature' -c)
echo "goodSignature(${goodSignature})"
correctKey=$(echo ${verifyResult} | tr -d " \t\n\r" | grep "${PGPpubkey}" -c)
echo "correctKey(${correctKey})"
if [ ${correctKey} -lt 1 ] || [ ${goodSignature} -lt 1 ]; then
echo
echo "# BUILD FAILED --> the PGP verification failed / signature(${goodSignature}) verify(${correctKey})"
echo "# Removing the conflicting files"
echo "# This is normal after an update - try to choose the option / run the script again."
sudo rm -f SHA256SUMS
sudo rm -f SHA256SUMS.asc
exit 1
else
sudo -u joinmarket wget --prefer-family=ipv4 --progress=bar:force -O SHA256SUMS https://bitcoincore.org/bin/bitcoin-core-${bitcoinVersion}/SHA256SUMS
# download the signed binary sha256 hash sum file and check
sudo -u joinmarket wget --prefer-family=ipv4 --progress=bar:force -O SHA256SUMS.asc https://bitcoincore.org/bin/bitcoin-core-${bitcoinVersion}/SHA256SUMS.asc

if gpg --verify SHA256SUMS.asc; then
echo
echo "****************************************"
echo "OK --> BITCOIN MANIFEST IS CORRECT"
echo "****************************************"
echo
else
echo
echo "# BUILD FAILED --> the PGP verification failed / signature(${goodSignature}) "
exit 1
fi

# detect CPU architecture & fitting download link
Expand Down Expand Up @@ -98,8 +83,6 @@ function downloadBitcoinCore() {
echo "OK --> VERIFIED BITCOIN CORE BINARY CHECKSUM"
echo "********************************************"
echo
sleep 10
echo
fi
echo
echo "# Extracting to /home/joinmarket/download/bitcoin-${bitcoinVersion}"
Expand Down Expand Up @@ -332,7 +315,7 @@ function checkRPCwallet {
connectionOutput=$(mktemp -p /dev/shm/)
walletFound=$(customRPC "# Check wallet" "listwallets" 2>$connectionOutput | grep -c "$rpc_wallet")
if [ $walletFound -eq 0 ]; then
echo "# Setting a watch only wallet for the remote Bitcoin Core named $rpc_wallet"
echo "# Setting a watch only wallet in Bitcoin Core named $rpc_wallet"
tor=""
if [ $(echo $rpc_host | grep -c .onion) -gt 0 ]; then
tor="torsocks"
Expand Down
15 changes: 11 additions & 4 deletions scripts/standalone/_functions.standalone.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ function addUserStore() {
echo "# Adding the user: store"
sudo adduser --disabled-password --gecos "" store
sudo -u store mkdir /home/store/app-data
echo "# Add the joinmarket user to the store group"
sudo usermod -aG store joinmarket
else
echo "# The folder /home/store/app-data is present already"
fi
Expand Down Expand Up @@ -120,9 +122,11 @@ function downloadSnapShot() {
echo "# Making sure user: bitcoin exists"
sudo adduser --disabled-password --gecos "" bitcoin
sudo chown -R bitcoin:bitcoin /home/store/app-data/.bitcoin
echo "# Add the joinmarket user to the bitcoin group"
sudo usermod -aG bitcoin joinmarket
echo "# Make sure bitcoind is not running"
sudo systemctl stop bitcoind
if [ -f /home/bitcoin/.bitcoin/bitcoin.conf ]; then
if sudo -u bitcoin ls /home/bitcoin/.bitcoin/bitcoin.conf; then
echo "# Back up bitcoin.conf"
sudo -u bitcoin mv /home/bitcoin/.bitcoin/bitcoin.conf \
/home/bitcoin/.bitcoin/bitcoin.conf.backup
Expand All @@ -135,7 +139,7 @@ function downloadSnapShot() {
echo "# Unzip ..."
sudo apt-get install -y unzip
sudo -u bitcoin unzip -o $downloadFileName -d /home/store/app-data/.bitcoin
if [ -f /home/bitcoin/.bitcoin/bitcoin.conf.backup ]; then
if sudo -u bitcoin ls /home/bitcoin/.bitcoin/bitcoin.conf.backup; then
echo "# Restore bitcoin.conf"
sudo -u bitcoin mv -f /home/bitcoin/.bitcoin/bitcoin.conf.backup \
/home/bitcoin/.bitcoin/bitcoin.conf
Expand All @@ -151,6 +155,8 @@ function installBitcoinCoreStandalone() {
else
echo "# Adding the user: bitcoin"
sudo adduser --disabled-password --gecos "" bitcoin
echo "# Add the joinmarket user to the bitcoin group"
sudo usermod -aG bitcoin joinmarket
echo "# Installing Bitcoin Core v${bitcoinVersion}"
sudo -u bitcoin mkdir -p /home/bitcoin/bitcoin
cd /home/joinmarket/download/bitcoin-${bitcoinVersion}/bin/ || exit 1
Expand All @@ -168,7 +174,8 @@ function installBitcoinCoreStandalone() {

# bitcoin.conf
if [ -f /home/store/app-data/.bitcoin/bitcoin.conf ]; then
if [ $(grep -c rpcpassword </home/store/app-data/.bitcoin/bitcoin.conf) -eq 0 ]; then
if [ $(sudo -u bitcoin grep -c rpcpassword </home/store/app-data/.bitcoin/bitcoin.conf) -eq 0 ]; then
echo "# Removing old bitcoin.conf without rpcpassword configured"
sudo rm /home/store/app-data/.bitcoin/bitcoin.conf
fi
fi
Expand Down Expand Up @@ -246,7 +253,7 @@ WantedBy=multi-user.target

sudo systemctl start bitcoind
echo
echo "# Installed $(/home/bitcoin/bitcoin/bitcoind --version | grep version)"
echo "# Installed $(sudo -u bitcoin /home/bitcoin/bitcoin/bitcoind --version | grep version)"
echo
echo "# Monitor the bitcoind with: sudo tail -f /home/bitcoin/.bitcoin/mainnet/debug.log"
echo
Expand Down

0 comments on commit ec556ab

Please sign in to comment.