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 | # -q : Print out "quickstation" or "not_quickstation" depending on if this |
---|
22 | # workstation is a quickstation or not |
---|
23 | |
---|
24 | PATH=/bin:/usr/bin:/sbin:/usr/sbin |
---|
25 | |
---|
26 | while getopts cdk:m:rvACELMNPSq i; do |
---|
27 | case "$i" in |
---|
28 | c) |
---|
29 | cpu=1 |
---|
30 | ;; |
---|
31 | d) |
---|
32 | display=1 |
---|
33 | ;; |
---|
34 | k) |
---|
35 | # Doesn't do anything right now. |
---|
36 | kernel=1 |
---|
37 | karg=$optarg |
---|
38 | ;; |
---|
39 | m) |
---|
40 | # Also doesn't do anything right now. |
---|
41 | mem=1 |
---|
42 | memarg=$optarg |
---|
43 | ;; |
---|
44 | r) |
---|
45 | rdsk=1 |
---|
46 | ;; |
---|
47 | v) |
---|
48 | verbose=1 |
---|
49 | ;; |
---|
50 | A) |
---|
51 | at_rel=1 |
---|
52 | ;; |
---|
53 | C) |
---|
54 | ath_sys_compat=1 |
---|
55 | ;; |
---|
56 | E) |
---|
57 | base_os_ver=1 |
---|
58 | ;; |
---|
59 | L) |
---|
60 | ath_vers=1 |
---|
61 | ;; |
---|
62 | M) |
---|
63 | memory=1 |
---|
64 | ;; |
---|
65 | N) |
---|
66 | base_os_name=1 |
---|
67 | ;; |
---|
68 | P) |
---|
69 | syspacks=1 |
---|
70 | ;; |
---|
71 | S) |
---|
72 | ath_sys_name=1 |
---|
73 | ;; |
---|
74 | q) |
---|
75 | quickstation=1 |
---|
76 | ;; |
---|
77 | \?) |
---|
78 | echo "Usage: machtype [-cdrvACELMNPS]" 1>&2 |
---|
79 | exit 1 |
---|
80 | ;; |
---|
81 | esac |
---|
82 | done |
---|
83 | printed=0 |
---|
84 | |
---|
85 | if [ $at_rel ]; then |
---|
86 | if [ $verbose ]; then |
---|
87 | echo -n "Machtype version: " |
---|
88 | fi |
---|
89 | echo "@ATHENA_MAJOR_VERSION@.@ATHENA_MINOR_VERSION@" |
---|
90 | printed=1 |
---|
91 | fi |
---|
92 | |
---|
93 | if [ $syspacks ]; then |
---|
94 | echo "Linux does not use system packs." >&2 |
---|
95 | printed=1 |
---|
96 | fi |
---|
97 | |
---|
98 | if [ $ath_vers ]; then |
---|
99 | for meta in cluster workstation login-graphical login standard clients locker athena-libraries extra-software extra-software-nox thirdparty; do |
---|
100 | if dpkg-query --showformat '${Status}\n' -W "debathena-$meta" 2>/dev/null | grep -q ' installed$'; then |
---|
101 | echo "debathena-$meta" |
---|
102 | printed=1 |
---|
103 | if [ ! $verbose ]; then |
---|
104 | break |
---|
105 | fi |
---|
106 | fi |
---|
107 | done |
---|
108 | if [ $printed -eq '0' ]; then |
---|
109 | echo "debathena" |
---|
110 | printed=1 |
---|
111 | fi |
---|
112 | fi |
---|
113 | |
---|
114 | if [ $base_os_name ]; then |
---|
115 | if [ $verbose ]; then |
---|
116 | uname -sr |
---|
117 | else |
---|
118 | uname -s |
---|
119 | fi |
---|
120 | printed=1 |
---|
121 | fi |
---|
122 | |
---|
123 | if [ $base_os_ver ]; then |
---|
124 | lsb_release -sd |
---|
125 | printed=1 |
---|
126 | fi |
---|
127 | |
---|
128 | if [ $ath_sys_name ]; then |
---|
129 | echo "@ATHENA_SYS@" |
---|
130 | printed=1 |
---|
131 | fi |
---|
132 | |
---|
133 | if [ $ath_sys_compat ]; then |
---|
134 | echo "@ATHENA_SYS_COMPAT@" |
---|
135 | printed=1 |
---|
136 | fi |
---|
137 | |
---|
138 | if [ $cpu ] ; then |
---|
139 | if [ $verbose ]; then |
---|
140 | echo "`uname -s` `uname -r` on `uname -m`" |
---|
141 | else |
---|
142 | uname -m |
---|
143 | fi |
---|
144 | printed=1 |
---|
145 | fi |
---|
146 | |
---|
147 | if [ $display ] ; then |
---|
148 | lspci | awk -F: '/VGA/ {print $3}' | sed -n -e 's/^ //' -e p |
---|
149 | printed=1 |
---|
150 | fi |
---|
151 | |
---|
152 | if [ $rdsk ]; then |
---|
153 | for d in /sys/block/[fhs]d*; do |
---|
154 | echo $(basename "$d"): \ |
---|
155 | $(xargs -I @ expr @ '*' 8 / 15625 < "$d/size")MB \ |
---|
156 | $(cat "$d/device/model" || |
---|
157 | cat "/proc/ide/$(basename "$d")/model") |
---|
158 | done 2>/dev/null |
---|
159 | printed=1 |
---|
160 | fi |
---|
161 | |
---|
162 | if [ $memory ] ; then |
---|
163 | if [ $verbose ]; then |
---|
164 | awk '/^MemTotal:/ { printf "user=%d, phys=%d (%d M)\n", |
---|
165 | $2, $2, $2/1024 }' \ |
---|
166 | /proc/meminfo |
---|
167 | else |
---|
168 | awk '/^MemTotal:/ { printf "%d\n", $2 }' /proc/meminfo |
---|
169 | fi |
---|
170 | printed=1 |
---|
171 | fi |
---|
172 | |
---|
173 | if [ $quickstation ]; then |
---|
174 | if (mount | grep -q '^AFS on /afs' && |
---|
175 | grep -Fxqi "$(hostname --fqdn)" /afs/athena.mit.edu/system/config/quick/quickstations) || |
---|
176 | [ "$FORCE_QUICKSTATION" = 1 ]; then |
---|
177 | echo quickstation |
---|
178 | else |
---|
179 | echo not_quickstation |
---|
180 | fi |
---|
181 | printed=1 |
---|
182 | fi |
---|
183 | |
---|
184 | if [ $printed -eq '0' ] ; then |
---|
185 | echo linux |
---|
186 | fi |
---|
187 | exit 0 |
---|