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