2020-07-10 03:57:17 +00:00
|
|
|
#!/bin/bash
|
2022-01-16 21:56:10 +00:00
|
|
|
SERIAL_NUM="UNKNOWN"
|
2022-04-09 17:41:25 +00:00
|
|
|
BACKUP_SERIAL="UNKNOWN_BACKUP"
|
|
|
|
|
|
|
|
if [ -f /home/bitcoin/.mynode/mynode_serial ]; then
|
|
|
|
BACKUP_SERIAL=$(cat /home/bitcoin/.mynode/mynode_serial)
|
|
|
|
else
|
|
|
|
# Backup, use eth0 mac (some are duplicate?)
|
|
|
|
if [ -f /sys/class/net/eth0/address ]; then
|
|
|
|
MAC=$(cat /sys/class/net/eth0/address)
|
|
|
|
BACKUP_SERIAL=$(echo "${MAC//:}")
|
|
|
|
else
|
|
|
|
BACKUP_SERIAL="UNKNOWN_BACKUP_SERIAL"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
2022-01-16 21:56:10 +00:00
|
|
|
if [ -f /sys/firmware/devicetree/base/serial-number ]; then
|
|
|
|
SERIAL_NUM=$(tr -d '\0' </sys/firmware/devicetree/base/serial-number)
|
|
|
|
else
|
|
|
|
SERIAL_NUM=$(cat /proc/cpuinfo | grep Serial | cut -d ' ' -f 2)
|
|
|
|
if [[ "$SERIAL_NUM" == "" ]]; then
|
|
|
|
# Caution - dmidecode seem to cause issues on some platforms (used on VM)
|
|
|
|
SERIAL_NUM=$(sudo dmidecode | grep UUID | cut -d ' ' -f 2)
|
2022-04-09 17:41:25 +00:00
|
|
|
if [[ "$SERIAL_NUM" == "03000200-0400-0500-0006-000700080009" ]]; then
|
|
|
|
# Some mini PCs return this hard coded value
|
|
|
|
SERIAL_NUM=$BACKUP_SERIAL
|
|
|
|
fi
|
2022-01-16 21:56:10 +00:00
|
|
|
elif [[ "$SERIAL_NUM" == "0000000000000000" ]]; then
|
|
|
|
# RockPro64 returns 0s (base serial-num should work now)
|
2022-04-09 17:41:25 +00:00
|
|
|
SERIAL_NUM=$BACKUP_SERIAL
|
2021-02-26 05:24:56 +00:00
|
|
|
fi
|
2020-07-10 03:57:17 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
echo $SERIAL_NUM
|