Browse Source

improved cleanup and raspbian support

main
deicidus 1 year ago
parent
commit
fb79c43eda
  1. 21
      spells/menu/bitcoin/install-bitcoin

21
spells/menu/bitcoin/install-bitcoin

@ -1,7 +1,7 @@
#!/bin/sh #!/bin/sh
# Set Bitcoin version # Set Bitcoin version
BITCOIN_VERSION="25.0" BITCOIN_VERSION="0.21.1"
# Function to get Bitcoin binary based on architecture # Function to get Bitcoin binary based on architecture
get_bitcoin_binary() { get_bitcoin_binary() {
@ -25,6 +25,9 @@ get_bitcoin_binary() {
# Function to install Bitcoin from source # Function to install Bitcoin from source
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 wget https://bitcoincore.org/bin/bitcoin-core-$BITCOIN_VERSION/bitcoin-$BITCOIN_VERSION.tar.gz
tar -xvf bitcoin-$BITCOIN_VERSION.tar.gz tar -xvf bitcoin-$BITCOIN_VERSION.tar.gz
cd bitcoin-$BITCOIN_VERSION || exit 1 cd bitcoin-$BITCOIN_VERSION || exit 1
@ -35,7 +38,8 @@ install_bitcoin_from_source() {
return 1 return 1
fi fi
sudo make install sudo make install
cd .. || exit 1 cd ../.. || exit 1
rm -rf "$tmp_dir"
return 0 return 0
} }
@ -56,10 +60,14 @@ install_bitcoin_binary() {
# Function to install Bitcoin for macOS # Function to install Bitcoin for macOS
install_bitcoin_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 wget https://bitcoincore.org/bin/bitcoin-core-$BITCOIN_VERSION/bitcoin-$BITCOIN_VERSION-osx64.tar.gz
tar -xzf bitcoin-$BITCOIN_VERSION-osx64.tar.gz tar -xzf bitcoin-$BITCOIN_VERSION-osx64.tar.gz
sudo mv bitcoin-$BITCOIN_VERSION/bin/* /usr/local/bin/ 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." echo "Bitcoin Core version $BITCOIN_VERSION has been installed successfully on macOS."
} }
@ -70,8 +78,13 @@ install_bitcoin() {
install_bitcoin_macos install_bitcoin_macos
;; ;;
Linux) 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 install_bitcoin_binary
else
if ! install_bitcoin_from_source; then
install_bitcoin_binary
fi
fi fi
;; ;;
*) *)

Loading…
Cancel
Save