diff --git a/rootfs/standard/usr/bin/mynode-get-device-serial b/rootfs/standard/usr/bin/mynode-get-device-serial new file mode 100755 index 00000000..328ca159 --- /dev/null +++ b/rootfs/standard/usr/bin/mynode-get-device-serial @@ -0,0 +1,12 @@ +#!/bin/bash + +SERIAL_NUM=$(cat /proc/cpuinfo | grep Serial | cut -d ' ' -f 2) +if [[ "$SERIAL_NUM" == "" ]]; then + SERIAL_NUM=$(sudo dmidecode | grep UUID | cut -d ' ' -f 2) +elif [[ "$SERIAL_NUM" == "0000000000000000" ]]; then + # RockPro64 returns 0s, so use eth0 mac + MAC=$(cat /sys/class/net/eth0/address) + SERIAL_NUM=$(echo "${MAC//:}") +fi + +echo $SERIAL_NUM \ No newline at end of file diff --git a/rootfs/standard/usr/share/mynode/mynode_config.sh b/rootfs/standard/usr/share/mynode/mynode_config.sh index eda55dfd..dd2f8b4a 100644 --- a/rootfs/standard/usr/share/mynode/mynode_config.sh +++ b/rootfs/standard/usr/share/mynode/mynode_config.sh @@ -39,10 +39,7 @@ fi TOTAL_RAM_GB=$(free --giga | grep Mem | awk '{print $2}') -SERIAL_NUM=$(cat /proc/cpuinfo | grep Serial | cut -d ' ' -f 2) -if [[ "$SERIAL_NUM" == "" ]]; then - SERIAL_NUM=$(sudo dmidecode | grep UUID | cut -d ' ' -f 2) -fi +SERIAL_NUM=$(mynode-get-device-serial) # Set all default / standard bash config settings MYNODE_DIR=/mnt/hdd/mynode diff --git a/rootfs/standard/var/www/mynode/device_info.py b/rootfs/standard/var/www/mynode/device_info.py index 143bde33..2a783eca 100644 --- a/rootfs/standard/var/www/mynode/device_info.py +++ b/rootfs/standard/var/www/mynode/device_info.py @@ -225,12 +225,8 @@ def get_device_serial(): if "serial" in cached_data: return cached_data["serial"] - serial = subprocess.check_output("cat /proc/cpuinfo | grep Serial | cut -d ' ' -f 2", shell=True) + serial = subprocess.check_output("mynode-get-device-serial", shell=True) serial = serial.strip() - if serial == "": - # For VMs, use the UUID - serial = subprocess.check_output("sudo dmidecode | grep UUID | cut -d ' ' -f 2", shell=True) - serial = serial.strip() cached_data["serial"] = serial return serial