Merge branch 'master' of feistymeow.org:feisty_meow
[feisty_meow.git] / scripts / core / inventory.sh
1 #!/bin/bash
2
3 # a frivolous but useful script that shows information about the local
4 # computer in terms of an adventure game inventory listing.
5
6 source "$FEISTY_MEOW_SCRIPTS/core/functions.sh"
7
8 unset -v codename osname osver
9 if [ $OPERATING_SYSTEM == "UNIX" ]; then
10   which lsb_release &>/dev/null
11   if [ $? -eq 0 ]; then
12     codename="$(lsb_release -cs 2>/dev/null)"
13     osname="$(lsb_release -is 2>/dev/null)"
14     osver="$(lsb_release -rs 2>/dev/null)"
15   fi
16 fi
17 if [ -z "$codename" ]; then
18   codename="mysterioso"
19   osname="unspecified"
20   osver="0.0?"
21 fi
22
23 # test if this uptime knows the -p flag.
24 uptime -p &>/dev/null
25 if [ $? -eq 0 ]; then
26   up="$(uptime -p)"
27 else
28   up="$(uptime | awk '{print $2 " " $3 " " $4 " plus " $1 " hours" }')"
29 fi
30
31 # decide whether they've got splitter available or not.
32 if [ -f "$BINDIR/splitter" -o -f "$BINDIR/splitter.exe" ]; then
33   splitter="$BINDIR/splitter"
34 else
35   # not available, so just emit as huge overly long string.
36   splitter="cat"
37 fi
38 echo
39 echo "it is $(date +"%A at %H:%M hours on day %e of the %B moon in the gregorian year %Y" | tr A-Z a-z) and our intrepid adventurer $USER is exploring a computer named $(hostname) that is running in a thoughtspace called $osname $osver (code-name $codename), and $USER has deduced that the machine's OS platform is $(uname -m) and its current incarnation has been ${up}." | $splitter 
40 #hmmm: splitter not accepting these args properly right now:
41 #--mincol 2 --maxcol 40
42 echo
43 #echo '++++++++++++++++++++++++++++++++++++++++++'
44 #echo
45 echo "the following things appear to be lying around here..."
46 echo
47 ls -hFC $color_add
48 echo
49 #echo '++++++++++++++++++++++++++++++++++++++++++'
50 #echo
51 echo "there appear to be these entities on this host..."
52 echo
53 who -suT
54 echo
55