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 | |
---|
22 | PATH=/bin:/usr/bin:/sbin:/usr/sbin |
---|
23 | |
---|
24 | while 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 |
---|
77 | done |
---|
78 | printed=0 |
---|
79 | |
---|
80 | if [ $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 |
---|
86 | fi |
---|
87 | |
---|
88 | if [ $syspacks ]; then |
---|
89 | echo "Linux does not use system packs." >&2 |
---|
90 | printed=1 |
---|
91 | fi |
---|
92 | |
---|
93 | if [ $ath_vers ]; then |
---|
94 | for meta in cluster workstation login-graphical login standard clients locker athena-libraries extra-software extra-software-nox thirdparty; do |
---|
95 | if dpkg-query --showformat '${Status}\n' -W "debathena-$meta" 2>/dev/null | grep -q ' installed$'; then |
---|
96 | echo "debathena-$meta" |
---|
97 | printed=1 |
---|
98 | if [ ! $verbose ]; then |
---|
99 | break |
---|
100 | fi |
---|
101 | fi |
---|
102 | done |
---|
103 | if [ $printed -eq '0' ]; then |
---|
104 | echo "debathena" |
---|
105 | printed=1 |
---|
106 | fi |
---|
107 | fi |
---|
108 | |
---|
109 | if [ $base_os_name ]; then |
---|
110 | if [ $verbose ]; then |
---|
111 | uname -sr |
---|
112 | else |
---|
113 | uname -s |
---|
114 | fi |
---|
115 | printed=1 |
---|
116 | fi |
---|
117 | |
---|
118 | if [ $base_os_ver ]; then |
---|
119 | lsb_release -sd |
---|
120 | printed=1 |
---|
121 | fi |
---|
122 | |
---|
123 | if [ $ath_sys_name ]; then |
---|
124 | echo "@ATHENA_SYS@" |
---|
125 | printed=1 |
---|
126 | fi |
---|
127 | |
---|
128 | if [ $ath_sys_compat ]; then |
---|
129 | echo "@ATHENA_SYS_COMPAT@" |
---|
130 | printed=1 |
---|
131 | fi |
---|
132 | |
---|
133 | if [ $cpu ] ; then |
---|
134 | if [ $verbose ]; then |
---|
135 | echo "`uname -s` `uname -r` on `uname -m`" |
---|
136 | else |
---|
137 | uname -m |
---|
138 | fi |
---|
139 | printed=1 |
---|
140 | fi |
---|
141 | |
---|
142 | if [ $display ] ; then |
---|
143 | lspci | awk -F: '/VGA/ {print $3}' | sed -n -e 's/^ //' -e p |
---|
144 | printed=1 |
---|
145 | fi |
---|
146 | |
---|
147 | if [ $rdsk ]; then |
---|
148 | for d in /sys/block/[fhs]d*; do |
---|
149 | echo $(basename "$d"): \ |
---|
150 | $(xargs -I @ expr @ '*' 8 / 15625 < "$d/size")MB \ |
---|
151 | $(cat "$d/device/model" || |
---|
152 | cat "/proc/ide/$(basename "$d")/model") |
---|
153 | done 2>/dev/null |
---|
154 | printed=1 |
---|
155 | fi |
---|
156 | |
---|
157 | if [ $memory ] ; then |
---|
158 | if [ $verbose ]; then |
---|
159 | awk '/^MemTotal:/ { printf "user=%d, phys=%d (%d M)\n", |
---|
160 | $2, $2, $2/1024 }' \ |
---|
161 | /proc/meminfo |
---|
162 | else |
---|
163 | awk '/^MemTotal:/ { printf "%d\n", $2 }' /proc/meminfo |
---|
164 | fi |
---|
165 | printed=1 |
---|
166 | fi |
---|
167 | |
---|
168 | if [ $printed -eq '0' ] ; then |
---|
169 | echo linux |
---|
170 | fi |
---|
171 | exit 0 |
---|