source: trunk/athena/bin/machtype/machtype_linux.sh @ 22825

Revision 22825, 2.7 KB checked in by tabbott, 16 years ago (diff)
In machtype: * Merged quilt patches into mainline Athena tree
Line 
1#!/bin/sh
2# $Id: machtype_linux.sh,v 1.9 2003-08-12 21:47:50 jweiss Exp $
3
4# We need to support the following options:
5# NOTE: c, v, d, L, and M are needed by olc, and it cares what order
6#  the output is in.
7#  -c     : Processor type
8#  -d     : display type
9#  -k     : select the kernel
10#  -m     : override memory from /dev/kmem
11#  -r     : disk drive type
12#  -v     : more verbose -- about memory mainly
13#  -A     : print Athena Release
14#  -C     : print out compatible Athena System names
15#  -E     : print out the version of the Base OS
16#  -L     : version of athena from /etc/athena/version
17#  -M     : physical memory
18#  -N     : print out the name of the base OS
19#  -P     : print out Athena System packs (from /srvd/.rvdinfo)
20#  -S     : Print out the Athena System name
21
22PATH=/bin:/usr/bin:/sbin:/usr/sbin
23
24while getopts cdk:m:rvACELMNPS i; do
25        case "$i" in
26        c)
27                cpu=1
28                ;;
29        d)
30                display=1
31                ;;
32        k)
33                # Doesn't do anything right now.
34                kernel=1
35                karg=$optarg
36                ;;
37        m)
38                # Also doesn't do anything right now.
39                mem=1
40                memarg=$optarg
41                ;;
42        r)
43                rdsk=1
44                ;;
45        v)
46                verbose=1
47                ;;
48        A)
49                at_rel=1
50                ;;
51        C)
52                ath_sys_compat=1
53                ;;
54        E)     
55                base_os_ver=1
56                ;;
57        L)
58                ath_vers=1
59                ;;
60        M)
61                memory=1
62                ;;
63        N)
64                base_os_name=1
65                ;;
66        P)     
67                syspacks=1
68                ;;
69        S)
70                ath_sys_name=1
71                ;;
72        \?)
73                echo "Usage: machtype [-cdrvACELMNPS]" 1>&2
74                exit 1
75                ;;
76        esac
77done
78printed=0
79
80if [ $at_rel ]; then
81        if [ $verbose ]; then
82                echo -n "Machtype version: "
83        fi
84        echo "@ATHENA_MAJOR_VERSION@.@ATHENA_MINOR_VERSION@"
85        printed=1
86fi
87
88if [ $syspacks ]; then
89        echo "Linux does not use system packs." >&2
90        printed=1
91fi
92
93if [ $ath_vers ]; then
94        if [ $verbose ]; then
95                tail -1 /etc/athena/version
96        else
97                awk '{ v = $5; } END { print v; }' /etc/athena/version
98        fi
99        printed=1
100fi
101
102if [ $base_os_name ]; then
103        if [ $verbose ]; then
104                uname -sr
105        else
106                uname -s
107        fi
108        printed=1
109fi
110
111if [ $base_os_ver ]; then
112        uname -r
113        printed=1
114fi
115
116if [ $ath_sys_name ]; then
117        echo "@ATHENA_SYS@"
118        printed=1
119fi
120
121if [ $ath_sys_compat ]; then
122        echo "@ATHENA_SYS_COMPAT@"
123        printed=1
124fi
125
126if [ $cpu ] ; then
127        if [ $verbose ]; then
128                echo "`uname -s` `uname -r` on `uname -m`"
129        else
130                uname -m
131        fi
132        printed=1
133fi
134
135if [ $display ] ; then
136        lspci | awk -F: '/VGA/ {print $3}' | sed -n -e 's/^ //' -e p
137        printed=1
138fi
139
140if [ $rdsk ]; then
141        for d in /sys/block/[fhs]d*; do
142            echo $(basename "$d"): \
143                $(xargs -I @ expr @ '*' 8 / 15625 < "$d/size")MB \
144                $(cat "$d/device/model" ||
145                  cat "/proc/ide/$(basename "$d")/model")
146        done 2>/dev/null
147        printed=1
148fi
149
150if [ $memory ] ; then
151        if [ $verbose ]; then
152                awk '/^MemTotal:/ { printf "user=%d, phys=%d (%d M)\n",
153                                           $2, $2, $2/1024 }' \
154                    /proc/meminfo
155        else
156                awk '/^MemTotal:/ { printf "%d\n", $2 }' /proc/meminfo
157        fi
158        printed=1
159fi
160
161if [ $printed -eq '0' ] ; then
162        echo linux
163fi
164exit 0
Note: See TracBrowser for help on using the repository browser.