mynodebtc / mynode

The easiest way to run Bitcoin and Lightning!
Other
646 stars 148 forks source link

Suggested: Ability to detect OS and Architecture #696

Open InsaneSplash opened 2 years ago

InsaneSplash commented 2 years ago

Hi,

I built this to allow me to install mynode on a NanoPi4S. I thought it might help kick things off to support more types of devices. This is an extract of the setup_device.sh script to determine the type of hardware being used. I had to make a number of changes throughout the installation and templates (standard etc), but the below worked well. I removed some 32bit support, and I don't have a RasberryPi to test the below, but I think it should work based on some friends devices.

#Device Architecture
IS_ARMBIAN=0
IS_X86=0
IS_RASBIAN=0

#32/64 Architecture
IS_64_BIT=0
IS_32_BIT=0

#Unknown
IS_UNKNOWN=1

#legacy
IS_ROCKPRO64=0

#Determine device architecture
ARCHITECTURE=$(lscpu | grep "Architecture" | awk '{ print $2 }')
CPU=$(lscpu | grep -E "^Vendor ID" | awk '{ print $3 }')
DEBIAN_VERSION=$(lsb_release -c | awk '{ print $2 }')

if [ $CPU == "ARM" ] && [ $ARCHITECTURE == "aarch64" ]; then
    IS_ARMBIAN=1
    IS_64_BIT=1
    IS_UNKNOWN=0
elif [ $CPU == "ARM" ] && [ $ARCHITECTURE == "armv7l" ]; then
    IS_RASBIAN=1
    IS_64_BIT=1
    IS_UNKNOWN=0
elif [ $CPU == "GenuineIntel" ] || [ $CPU == "AuthenticAMD" ] && [ $ARCHITECTURE == "x86_64" ]; then
    IS_X86=1
    IS_64_BIT=1
    IS_UNKNOWN=0
fi

if [ $IS_UNKNOWN = 1 ]; then
    echo "UNKNOWN DEVICE TYPE"
    exit 1
fi

Example BitCoin installation

# Install Bitcoin
ARCH="UNKNOWN"
if [ $IS_RASBIAN = 1 ] && [ $IS_32_BIT = 1 ]; then
    ARCH="arm-linux-gnueabihf"
elif [ $IS_ARMBIAN=1 ] || [ $IS_RASBIAN = 1 ] && [ $IS_64_BIT = 1 ]; then
    ARCH="aarch64-linux-gnu"
elif [ $IS_X86 = 1 ]; then
    ARCH="x86_64-linux-gnu"
else
    echo "Unknown Bitcoin Version"
    exit 1
fi
BTC_UPGRADE_URL=https://bitcoincore.org/bin/bitcoin-core-$BTC_VERSION/bitcoin-$BTC_VERSION-$ARCH.tar.gz

I hope we could adapt the setup script to allow for other devices to be natively supported.

tehelsper commented 2 years ago

Thanks, I've been thinking about this a bit to better handle generic Armbian / aarch64. The legacy devices still need detection though - they get used in some other locations and determine which filesystem overlay gets used.

InsaneSplash commented 2 years ago

image

xiezhaoye commented 1 year ago

I installed ubuntu on my macbook mini. I want to install mynode on ubuntu and run [sudo bash ./ mynode_ setup.sh ] Prompt [UNKNOWN DEVICE TYPE ,Exit] what should I do?

tehelsper commented 1 year ago

@xiezhaoye I know there are issues running directly on Ubuntu. In your case, I would install Virtualbox and run it as a virtual machine.