Browse Source

added aarch64 architecture + refactor

main
deicidus 1 year ago
parent
commit
c37987a53f
  1. 112
      spells/menu/bitcoin/install-bitcoin

112
spells/menu/bitcoin/install-bitcoin

@ -1,21 +1,33 @@
#!/bin/sh #!/bin/sh
# This spell installs bitcoin on almost any Linux platform, from source when possible, otherwise from precompiled binary.
# Set Bitcoin version # Set Bitcoin version
BITCOIN_VERSION=24.1 BITCOIN_VERSION="25.0"
# Install Bitcoin from source # Function to get Bitcoin binary based on architecture
get_bitcoin_binary() {
local arch
arch=$(uname -m)
case "$arch" in
"x86_64")
echo "bitcoin-$BITCOIN_VERSION-x86_64-linux-gnu.tar.gz"
;;
"aarch64")
echo "bitcoin-$BITCOIN_VERSION-aarch64-linux-gnu.tar.gz"
;;
"armv7l")
echo "bitcoin-$BITCOIN_VERSION-arm-linux-gnueabihf.tar.gz"
;;
*)
echo "Unsupported architecture: $arch"
exit 1
esac
}
# Function to install Bitcoin from source
install_bitcoin_from_source() { install_bitcoin_from_source() {
say "Installing Bitcoin Core from source"
if [ ! -e bitcoin-$BITCOIN_VERSION* ]; then
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
fi
. ./path_to_install_if_needed_script.sh boost
tar -xvf bitcoin-$BITCOIN_VERSION.tar.gz tar -xvf bitcoin-$BITCOIN_VERSION.tar.gz
sleep 1 cd bitcoin-$BITCOIN_VERSION || exit 1
cd bitcoin-$BITCOIN_VERSION
chmod +x autogen.sh
./autogen.sh ./autogen.sh
./configure --disable-wallet ./configure --disable-wallet
make make
@ -23,66 +35,50 @@ install_bitcoin_from_source() {
return 1 return 1
fi fi
sudo make install sudo make install
cd .. cd .. || exit 1
return 0 return 0
} }
# Install Bitcoin ARM precompiled binary # Function to install Bitcoin binary
install_bitcoin_arm_binary() { install_bitcoin_binary() {
say "Installing Bitcoin Core ARM precompiled binary" binary_name=$(get_bitcoin_binary)
if [ ! -e bitcoin-$BITCOIN_VERSION* ]; then bitcoin_url="https://bitcoincore.org/bin/bitcoin-core-$BITCOIN_VERSION/$binary_name"
wget https://bitcoincore.org/bin/bitcoin-core-$BITCOIN_VERSION/bitcoin-$BITCOIN_VERSION-arm-linux-gnueabihf.tar.gz tmp_dir="/tmp/bitcoin-install-$(date +%s)"
tar -xzf bitcoin-$BITCOIN_VERSION-arm-linux-gnueabihf.tar.gz mkdir -p "$tmp_dir"
fi cd "$tmp_dir" || exit 1
wget "$bitcoin_url"
tar -xzf "$binary_name"
sudo install -m 0755 -o root -g root -t /usr/local/bin bitcoin-$BITCOIN_VERSION/bin/* sudo install -m 0755 -o root -g root -t /usr/local/bin bitcoin-$BITCOIN_VERSION/bin/*
cd - || exit 1
rm -rf "$tmp_dir"
echo "Bitcoin Core version $BITCOIN_VERSION has been installed successfully."
} }
# Install Bitcoin x86_64 precompiled binary # Function to install Bitcoin for macOS
install_bitcoin_x86_64_binary() { install_bitcoin_macos() {
say "Installing Bitcoin Core x86_64 precompiled binary" wget https://bitcoincore.org/bin/bitcoin-core-$BITCOIN_VERSION/bitcoin-$BITCOIN_VERSION-osx64.tar.gz
if [ ! -e bitcoin-$BITCOIN_VERSION* ]; then tar -xzf bitcoin-$BITCOIN_VERSION-osx64.tar.gz
wget https://bitcoincore.org/bin/bitcoin-core-$BITCOIN_VERSION/bitcoin-$BITCOIN_VERSION-x86_64-linux-gnu.tar.gz sudo mv bitcoin-$BITCOIN_VERSION/bin/* /usr/local/bin/
tar -xzf bitcoin-$BITCOIN_VERSION-x86_64-linux-gnu.tar.gz rm -rf bitcoin-$BITCOIN_VERSION-osx64.tar.gz bitcoin-$BITCOIN_VERSION
fi echo "Bitcoin Core version $BITCOIN_VERSION has been installed successfully on macOS."
sudo install -m 0755 -o root -g root -t /usr/local/bin bitcoin-$BITCOIN_VERSION/bin/*
} }
# Install Bitcoin macOS precompiled binary # Main function to install Bitcoin
install_bitcoin_macos_binary() { install_bitcoin() {
say "Installing Bitcoin Core macOS precompiled binary" case "$(uname -s)" in
if [ ! -e bitcoin-$BITCOIN_VERSION* ]; then
wget https://bitcoincore.org/bin/bitcoin-core-$BITCOIN_VERSION/bitcoin-$BITCOIN_VERSION-osx-signed.dmg
hdiutil attach bitcoin-$BITCOIN_VERSION-osx-signed.dmg
cp -R /Volumes/Bitcoin-Core/Bitcoin-Qt.app /Applications/
hdiutil detach /Volumes/Bitcoin-Core
fi
}
# Detect the operating system
OS=$(uname -s)
# Install Bitcoin based on the OS
case $OS in
Darwin) Darwin)
install_bitcoin_macos_binary install_bitcoin_macos
;; ;;
Linux) Linux)
ARCH=$(uname -m)
case $ARCH in
x86_64)
if ! install_bitcoin_from_source; then if ! install_bitcoin_from_source; then
install_bitcoin_x86_64_binary install_bitcoin_binary
fi fi
;; ;;
arm* | aarch64)
install_bitcoin_arm_binary
;;
*) *)
say "Unsupported architecture: $ARCH" echo "Unsupported operating system"
exit exit 1
esac esac
;; }
*)
say "Unsupported operating system: $OS" # Run the install Bitcoin function
exit install_bitcoin
esac
Loading…
Cancel
Save