Refactor bash scripts

This commit is contained in:
Taylor Helsper 2022-04-21 22:21:05 -05:00
parent d5f313b395
commit bd29d4d886
3 changed files with 65 additions and 60 deletions

View File

@ -1,5 +1,7 @@
#!/bin/bash
source /usr/share/mynode/mynode_device_info.sh
BTC_VERSION="22.0"
BTC_VERSION_FILE=/home/bitcoin/.mynode/bitcoin_version
BTC_LATEST_VERSION_FILE=/home/bitcoin/.mynode/bitcoin_version_latest

View File

@ -1,65 +1,6 @@
#!/bin/bash
# Device info
IS_ARMBIAN=0
IS_ROCK64=0
IS_ROCKPRO64=0
IS_RASPI=0
IS_RASPI3=0
IS_RASPI4=0
IS_RASPI4_ARM64=0
IS_ROCKPI4=0
IS_X86=0
IS_32_BIT=0
IS_64_BIT=0
DEVICE_TYPE="unknown"
MODEL=$(tr -d '\0' < /proc/device-tree/model) || MODEL="unknown"
uname -a | grep amd64 && IS_X86=1 || true
if [[ $MODEL == *"Rock64"* ]]; then
IS_ARMBIAN=1
IS_ROCK64=1
IS_64_BIT=1
elif [[ $MODEL == *"RockPro64"* ]]; then
IS_ARMBIAN=1
IS_ROCKPRO64=1
IS_64_BIT=1
elif [[ $MODEL == *"Raspberry Pi 3"* ]]; then
IS_RASPI=1
IS_RASPI3=1
IS_32_BIT=1
elif [[ $MODEL == *"Raspberry Pi 4"* ]]; then
IS_RASPI=1
IS_RASPI4=1
IS_32_BIT=1
UNAME=$(uname -a)
if [[ $UNAME == *"aarch64"* ]]; then
IS_RASPI4_ARM64=1
IS_32_BIT=0
IS_64_BIT=1
fi
elif [[ $MODEL == *"ROCK Pi 4"* ]]; then
IS_ARMBIAN=1
IS_ROCKPI4=1
IS_64_BIT=1
fi
if [ $IS_RASPI3 -eq 1 ]; then
DEVICE_TYPE="raspi3"
elif [ $IS_RASPI4 -eq 1 ]; then
DEVICE_TYPE="raspi4"
elif [ $IS_ROCKPI4 -eq 1 ]; then
DEVICE_TYPE="rockpi4"
elif [ $IS_ROCK64 -eq 1 ]; then
DEVICE_TYPE="rock64"
elif [ $IS_ROCKPRO64 -eq 1 ]; then
DEVICE_TYPE="rockpro64"
elif [ $IS_X86 -eq 1 ]; then
DEVICE_TYPE="debian"
fi
TOTAL_RAM_GB=$(free --giga | grep Mem | awk '{print $2}')
SERIAL_NUM=$(mynode-get-device-serial)
source /usr/share/mynode/mynode_device_info.sh
# Set all default / standard bash config settings
MYNODE_DIR=/mnt/hdd/mynode

View File

@ -0,0 +1,62 @@
#!/bin/bash
# Device info
IS_ARMBIAN=0
IS_ROCK64=0
IS_ROCKPRO64=0
IS_RASPI=0
IS_RASPI3=0
IS_RASPI4=0
IS_RASPI4_ARM64=0
IS_ROCKPI4=0
IS_X86=0
IS_32_BIT=0
IS_64_BIT=0
DEVICE_TYPE="unknown"
MODEL=$(tr -d '\0' < /proc/device-tree/model) || MODEL="unknown"
uname -a | grep amd64 && IS_X86=1 || true
if [[ $MODEL == *"Rock64"* ]]; then
IS_ARMBIAN=1
IS_ROCK64=1
IS_64_BIT=1
elif [[ $MODEL == *"RockPro64"* ]]; then
IS_ARMBIAN=1
IS_ROCKPRO64=1
IS_64_BIT=1
elif [[ $MODEL == *"Raspberry Pi 3"* ]]; then
IS_RASPI=1
IS_RASPI3=1
IS_32_BIT=1
elif [[ $MODEL == *"Raspberry Pi 4"* ]]; then
IS_RASPI=1
IS_RASPI4=1
IS_32_BIT=1
UNAME=$(uname -a)
if [[ $UNAME == *"aarch64"* ]]; then
IS_RASPI4_ARM64=1
IS_32_BIT=0
IS_64_BIT=1
fi
elif [[ $MODEL == *"ROCK Pi 4"* ]]; then
IS_ARMBIAN=1
IS_ROCKPI4=1
IS_64_BIT=1
fi
if [ $IS_RASPI3 -eq 1 ]; then
DEVICE_TYPE="raspi3"
elif [ $IS_RASPI4 -eq 1 ]; then
DEVICE_TYPE="raspi4"
elif [ $IS_ROCKPI4 -eq 1 ]; then
DEVICE_TYPE="rockpi4"
elif [ $IS_ROCK64 -eq 1 ]; then
DEVICE_TYPE="rock64"
elif [ $IS_ROCKPRO64 -eq 1 ]; then
DEVICE_TYPE="rockpro64"
elif [ $IS_X86 -eq 1 ]; then
DEVICE_TYPE="debian"
fi
TOTAL_RAM_GB=$(free --giga | grep Mem | awk '{print $2}')
SERIAL_NUM=$(mynode-get-device-serial)