#!/usr/bin/bash

CU='\033[4m'    # underline
C0='\033[0m'    # clear
C1='\033[31m'   # red
C2='\033[32m'   # green
C3='\033[33m'   # yellow
C4='\033[34m'   # blue

MODEL=$(/usr/bin/tr --delete '\0' < '/sys/firmware/devicetree/base/model')
PROCESSOR_VENDOR=$(/usr/bin/lscpu | /usr/bin/grep --word-regexp 'Vendor ID:' | /usr/bin/sed --expression='s/Vendor ID:[[:space:]]*//g')
PROCESSOR_MODEL=$(/usr/bin/lscpu | /usr/bin/grep --word-regexp 'Model name:' | /usr/bin/sed --expression='s/Model name:[[:space:]]*//g')
PROCESSOR_ARCHITECTURE=$(/usr/bin/lscpu | /usr/bin/grep --word-regexp 'Architecture:' | /usr/bin/sed --expression='s/Architecture:[[:space:]]*//g')
PROCESSOR_CORES=$(/usr/bin/lscpu | /usr/bin/grep --word-regexp 'Core(s) per cluster:' | /usr/bin/sed --expression='s/Core(s) per cluster:[[:space:]]*//g')
PROCESSOR_THREADS=$(/usr/bin/lscpu | /usr/bin/grep --word-regexp 'Thread(s) per core:' | /usr/bin/sed --expression='s/Thread(s) per core:[[:space:]]*//g')
PROCESSOR_FREQUENCY=$(/usr/bin/lscpu | /usr/bin/grep --word-regexp 'CPU max MHz:' | /usr/bin/sed --expression='s/CPU max MHz:[[:space:]]*//g')
RAM=$(/usr/bin/free --mebi | /usr/bin/mawk 'NR==2{printf "%sM / %sM (%.2f%%)", $3,$2,$3*100/$2 }')
SWAP=$(/usr/bin/free --mebi | /usr/bin/mawk 'NR==3{printf "%sM / %sM (%.2f%%)", $3,$2,$3*100/$2 }')
LXC1=$(/usr/bin/df --human-readable | /usr/bin/mawk '$NF=="/"{printf "%s / %s (%s)", $3,$2,$5}')

/usr/bin/echo -e "\t${C3}Model:${C0}\t\t\t\t\t\t${MODEL}"
/usr/bin/echo -e "\t${C3}Processor:${C0}\t\t\t\t\t${PROCESSOR_VENDOR} ${PROCESSOR_MODEL} (${PROCESSOR_ARCHITECTURE})"
/usr/bin/echo -e "\t- ${C3}Cores:${C0}\t\t\t\t\t${PROCESSOR_CORES}"
/usr/bin/echo -e "\t- ${C3}Threads:${C0}\t\t\t\t\t${PROCESSOR_THREADS}"
/usr/bin/echo -e "\t- ${C3}Frequency:${C0}\t\t\t\t\t${PROCESSOR_FREQUENCY} MHz"
/usr/bin/echo -e "\t${C3}RAM:${C0}\t\t\t\t\t\t${RAM}"
/usr/bin/echo -e "\t${C3}SWAP:${C0}\t\t\t\t\t\t${SWAP}"
/usr/bin/echo -e "\t${C3}LXC (Root):${C0}\t\t\t\t\t${LXC1}"
