db33f74cf5b0afddab17b93f6fd0e5b96f3ebaa6
[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/launch_feisty_meow.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 # see if uptime even exists.
24 uptime &>/dev/null
25 if [ $? -eq 0 ]; then
26   # test if this uptime knows the -p flag.
27   uptime -p &>/dev/null
28   if [ $? -eq 0 ]; then
29     up="$(uptime -p)"
30   else
31     up="$(uptime | awk '{print $2 " " $3 " " $4 " plus " $1 " hours" }')"
32   fi
33 else
34   # if we can't do this, then we're not even on windows cygwin.  wth are we?
35   up="up a whole $(cat /proc/uptime|awk '{print $1}') seconds, yo"
36 fi
37
38 # decide whether they've got splitter available or not.
39 if [ -f "$FEISTY_MEOW_BINARIES/splitter" -o -f "$FEISTY_MEOW_BINARIES/splitter.exe" ]; then
40   # calculate the number of columsn in the terminal.
41   cols=$(get_maxcols)
42   splitter="$FEISTY_MEOW_BINARIES/splitter --maxcol $(($cols - 1))"
43 else
44   # not available, so just emit as huge overly long string.
45   splitter="cat"
46 fi
47 echo
48 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 
49 echo
50 echo "the following things appear to be lying around here..."
51 echo
52 ls -hFC $color_add
53 echo
54 echo "there appear to be these entities on this host..."
55 echo
56 who -suT
57 echo
58