#!/bin/rc
# Warning, parts of this script have been STOLEN!
# TODO:
# fs usage
# kernel
fn storage {
bind -b '#S' /dev
disks = `{ls -d /dev/sd* | uniq}
anydisk = 'false'
for(i in $disks){
if(test -f $i/data){
full = `{ls -l $i/data}
disk = `{echo $full | awk -F '/' '{print $3}'}
size = `{echo $full | awk '{print $6}'}
echo $disk^': '^`{echo $size^' / 1024 / 1024 /1024' | bc}^GB
anydisk = 'true'
}
}
if(~ $anydisk -c 'false')
echo Running in the diskless
}
fn fs {
if(ls /srv | grep -s '*.cmd')
ls /srv/*.cmd | sed 's/.cmd//g' | sed 's/\/srv\///g'
if(test -f /srv/fscons)
echo fossil
# Logic from storage to scrape for venti arenas
v='false'
disks = `{ls -d /dev/sd* | uniq}
for(i in $disks){
if(ls $i | grep -s arena)
v='true'
}
if(~ $v -c 'true')
echo venti
}
fn cpuid {
if(test -f /bin/aux/cpuid)
aux/cpuid | grep procname | sed 's/.*procname//'
}
os=`{
if(grep -s 'zrv' /dev/drivers)
echo 9ants
if not if(grep -s 'vmx' /dev/drivers)
echo 9front
if not
echo Bell Labs
}
arch=`{echo $cputype}
shell=/bin/rc
uptime=`{uptime| sed 's/.*up//; s/..........$//'}
scr=`{dd -count 1 < /dev/screen|[2];}
scr=($scr(4) x $scr(5))
ram=(`{tr / ' '</dev/swap})
free=`{echo $ram(1)'/1024^2'|bc}
used=`{echo '('$ram(3)'*('$ram(7)^+$ram(5)^'))/1024^2'|bc}
cpu=`{cpuid}
files=`{fs}
strg=`{storage}
cat <<EOF
$user@$sysname
(\(\ -----------
j". .. os: Plan 9 from $os/$arch
( . .) shell: $shell
| ° ¡ uptime: $uptime
¿ ; ram: $used/$free MiB
c?".UJ cpu: $cputype $cpu
resolution: $scr
fs: $files
$strg
EOF