#!/bin/bash hostname=$(hostname); operating_system=$(hostnamectl | grep "Operating System" | cut -d ':' -f2- | sed 's/^[ \t]*//'); architecture=$(arch); processor_model=$(cat /proc/cpuinfo | grep -E '^(model name|Model)\s*:' | sort -u | cut -d ':' -f2- | cut -d ' ' -f2-); memory=$(free -h --si --total | grep -oP '^Total:\s+([\d,]+[.]*[\d]*)[ ]*([A-Za-z]+)' | awk '{print $2}'); system_main_ip=$(hostname -I); # Hacky way to check for multiple possibilities cat /proc/cpuinfo | grep -q 'Raspberry'; rc=$? systemtype=$(if [[ $rc -eq 0 ]]; then echo "Raspberry"; else echo "Generic"; fi) cat /proc/cpuinfo | grep -q 'Intel'; rc=$? systemtype=$(if [[ $rc -eq 0 ]]; then echo "Intel"; else echo "$systemtype"; fi) if [ -f /sys/devices/virtual/dmi/id/product_name ]; then productname=$(cat /sys/devices/virtual/dmi/id/product_name) elif [ -d /sys/devices/platform/CLK ]; then productname="CloudKey" elif [[ "$systemtype" == "Raspberry" ]]; then productname=$processor_model else productname="Unknown" fi if [ -f /sys/devices/virtual/dmi/id/bios_vendor ]; then bios=$(cat /sys/devices/virtual/dmi/id/bios_vendor | awk '{print $1}') else bios="Unknown" fi if [ "$bios" == "coreboot" ]; then libreboot="installed" else libreboot="not present" fi if [ -f /sys/devices/virtual/dmi/id/board_vendor ]; then manufacturer=$(cat /sys/devices/virtual/dmi/id/board_vendor | awk '{print $1}') elif [[ "$systemtype" == "Raspberry" ]]; then manufacturer="Raspberry Pi Foundation" elif [[ "$productname" == "CloudKey" ]]; then manufacturer="Ubiquiti" else manufacturer="Unknown" fi printf '{"libreboot":"%s","systemtype":"%s","manufacturer":"%s","productname":"%s","hostname":"%s","operating_system":"%s","architecture":"%s","processor_name":"%s","memory":"%s","system_main_ip":"%s"}'\ "$libreboot" "$systemtype" "$manufacturer" "$productname" "$hostname" "$operating_system" "$architecture" "$processor_model" "$memory" "$system_main_ip"