From fb79c43edaf97571ff83de03f491786e7996feca Mon Sep 17 00:00:00 2001 From: deicidus Date: Fri, 16 Jun 2023 03:26:58 -0700 Subject: [PATCH] improved cleanup and raspbian support --- spells/menu/bitcoin/install-bitcoin | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/spells/menu/bitcoin/install-bitcoin b/spells/menu/bitcoin/install-bitcoin index e60215e..5b160f7 100755 --- a/spells/menu/bitcoin/install-bitcoin +++ b/spells/menu/bitcoin/install-bitcoin @@ -1,7 +1,7 @@ #!/bin/sh # Set Bitcoin version -BITCOIN_VERSION="25.0" +BITCOIN_VERSION="0.21.1" # Function to get Bitcoin binary based on architecture get_bitcoin_binary() { @@ -25,6 +25,9 @@ get_bitcoin_binary() { # Function to install Bitcoin from source install_bitcoin_from_source() { + tmp_dir="/tmp/bitcoin-install-$(date +%s)" + mkdir -p "$tmp_dir" + cd "$tmp_dir" || exit 1 wget https://bitcoincore.org/bin/bitcoin-core-$BITCOIN_VERSION/bitcoin-$BITCOIN_VERSION.tar.gz tar -xvf bitcoin-$BITCOIN_VERSION.tar.gz cd bitcoin-$BITCOIN_VERSION || exit 1 @@ -35,7 +38,8 @@ install_bitcoin_from_source() { return 1 fi sudo make install - cd .. || exit 1 + cd ../.. || exit 1 + rm -rf "$tmp_dir" return 0 } @@ -56,10 +60,14 @@ install_bitcoin_binary() { # Function to install Bitcoin for macOS install_bitcoin_macos() { + tmp_dir="/tmp/bitcoin-install-$(date +%s)" + mkdir -p "$tmp_dir" + cd "$tmp_dir" || exit 1 wget https://bitcoincore.org/bin/bitcoin-core-$BITCOIN_VERSION/bitcoin-$BITCOIN_VERSION-osx64.tar.gz tar -xzf bitcoin-$BITCOIN_VERSION-osx64.tar.gz sudo mv bitcoin-$BITCOIN_VERSION/bin/* /usr/local/bin/ - rm -rf bitcoin-$BITCOIN_VERSION-osx64.tar.gz bitcoin-$BITCOIN_VERSION + cd - || exit 1 + rm -rf "$tmp_dir" echo "Bitcoin Core version $BITCOIN_VERSION has been installed successfully on macOS." } @@ -70,8 +78,13 @@ install_bitcoin() { install_bitcoin_macos ;; Linux) - if ! install_bitcoin_from_source; then + # If the operating system is Raspbian, we will skip compiling from source and go directly to binary installation. + if grep -q 'Raspbian' /etc/os-release; then install_bitcoin_binary + else + if ! install_bitcoin_from_source; then + install_bitcoin_binary + fi fi ;; *)