44 lines
1.2 KiB
Bash
Executable File
44 lines
1.2 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
#~ [ $UID = 0 ] || {
|
|
#~ echo Must be run as root
|
|
#~ exit 1
|
|
#~ }
|
|
function filesize {
|
|
# Return a human readable size from integer of bytes
|
|
# Usage: filesize 10000
|
|
|
|
[ "$1" = "0" ] && {
|
|
echo "0 B"
|
|
return 0
|
|
}
|
|
|
|
awk 'BEGIN{ x = '$1'
|
|
split("B KB MB GB TB PB",type)
|
|
for(i=5;y < 1;i--)
|
|
y = x / (2^(10*i))
|
|
str=int(y*10)/10 " " type[i+2]
|
|
if (x==0) { str = "0 B" }
|
|
print str
|
|
}' || return $?
|
|
}
|
|
|
|
|
|
# Gather list of last user of machine
|
|
|
|
LASTUSER=$( who | tail -n 1 | awk '{ print $1 }' )
|
|
FULLNAME=$( getent passwd "$LASTUSER" | cut -d ':' -f 5 )
|
|
|
|
DESC_CORES=$( grep -c ^processor /proc/cpuinfo | tr -d -c [:digit:] )
|
|
DESC_TYPE=$( grep -m 1 "model name" /proc/cpuinfo | cut -d: -f2 | sed -e 's/^ *//' )
|
|
DESC_MEM=$( grep MemTotal /proc/meminfo | cut -f2 -d: | tr -d -c [:digit:] )
|
|
DESC_MEM=$( filesize $(( ${DESC_MEM}*1024 )) )
|
|
DESC_VERS=$( lsb_release -r | awk '{print $2}' )
|
|
DESC_UP=$( uptime | sed s/,.*// )
|
|
DESC_SERIAL=$( dmidecode | grep "Serial Number:" | head -n 1 | cut -d: -f2 | sed -e 's/^ *//' )
|
|
DESC="$LASTUSER/$FULLNAME/${DESC_CORES}x ${DESC_TYPE}/RAM ${DESC_MEM}/v.${DESC_VERS}/${DESC_UP}/SN ${DESC_SERIAL}"
|
|
echo "$DESC"
|
|
|
|
# exit okay
|
|
true
|