[12361] | 1 | #!/bin/sh |
---|
[19711] | 2 | # $Id: machtype_linux.sh,v 1.9 2003-08-12 21:47:50 jweiss Exp $ |
---|
[12361] | 3 | |
---|
| 4 | # We need to support the following options: |
---|
[13315] | 5 | # NOTE: c, v, d, L, and M are needed by olc, and it cares what order |
---|
| 6 | # the output is in. |
---|
[12361] | 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 |
---|
[13316] | 14 | # -C : print out compatible Athena System names |
---|
[12361] | 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 |
---|
[24053] | 21 | # -q : Print out "quickstation" or "not_quickstation" depending on if this |
---|
| 22 | # workstation is a quickstation or not |
---|
[12361] | 23 | |
---|
[22825] | 24 | PATH=/bin:/usr/bin:/sbin:/usr/sbin |
---|
[12361] | 25 | |
---|
[24053] | 26 | while getopts cdk:m:rvACELMNPSq i; do |
---|
[12361] | 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 | ;; |
---|
[13316] | 53 | C) |
---|
| 54 | ath_sys_compat=1 |
---|
| 55 | ;; |
---|
[12361] | 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 | ;; |
---|
[24053] | 74 | q) |
---|
| 75 | quickstation=1 |
---|
| 76 | ;; |
---|
[12361] | 77 | \?) |
---|
| 78 | echo "Usage: machtype [-cdrvACELMNPS]" 1>&2 |
---|
| 79 | exit 1 |
---|
| 80 | ;; |
---|
| 81 | esac |
---|
| 82 | done |
---|
| 83 | printed=0 |
---|
| 84 | |
---|
[13315] | 85 | if [ $at_rel ]; then |
---|
[13317] | 86 | if [ $verbose ]; then |
---|
| 87 | echo -n "Machtype version: " |
---|
| 88 | fi |
---|
[14823] | 89 | echo "@ATHENA_MAJOR_VERSION@.@ATHENA_MINOR_VERSION@" |
---|
[12361] | 90 | printed=1 |
---|
| 91 | fi |
---|
| 92 | |
---|
[13315] | 93 | if [ $syspacks ]; then |
---|
[14379] | 94 | echo "Linux does not use system packs." >&2 |
---|
[12361] | 95 | printed=1 |
---|
| 96 | fi |
---|
| 97 | |
---|
| 98 | if [ $ath_vers ]; then |
---|
[23683] | 99 | for meta in cluster workstation login-graphical login standard clients locker athena-libraries extra-software extra-software-nox thirdparty; do |
---|
[23493] | 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 |
---|
[23539] | 108 | if [ $printed -eq '0' ]; then |
---|
| 109 | echo "debathena" |
---|
| 110 | printed=1 |
---|
| 111 | fi |
---|
[12361] | 112 | fi |
---|
| 113 | |
---|
| 114 | if [ $base_os_name ]; then |
---|
[13317] | 115 | if [ $verbose ]; then |
---|
| 116 | uname -sr |
---|
| 117 | else |
---|
| 118 | uname -s |
---|
| 119 | fi |
---|
[12361] | 120 | printed=1 |
---|
| 121 | fi |
---|
| 122 | |
---|
[13315] | 123 | if [ $base_os_ver ]; then |
---|
[23493] | 124 | lsb_release -sd |
---|
[12361] | 125 | printed=1 |
---|
| 126 | fi |
---|
| 127 | |
---|
| 128 | if [ $ath_sys_name ]; then |
---|
[14823] | 129 | echo "@ATHENA_SYS@" |
---|
[12361] | 130 | printed=1 |
---|
| 131 | fi |
---|
| 132 | |
---|
| 133 | if [ $ath_sys_compat ]; then |
---|
[14823] | 134 | echo "@ATHENA_SYS_COMPAT@" |
---|
[12361] | 135 | printed=1 |
---|
| 136 | fi |
---|
| 137 | |
---|
[13315] | 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 |
---|
[22825] | 148 | lspci | awk -F: '/VGA/ {print $3}' | sed -n -e 's/^ //' -e p |
---|
[13315] | 149 | printed=1 |
---|
| 150 | fi |
---|
| 151 | |
---|
[12361] | 152 | if [ $rdsk ]; then |
---|
[22825] | 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 |
---|
[12361] | 159 | printed=1 |
---|
| 160 | fi |
---|
| 161 | |
---|
[13315] | 162 | if [ $memory ] ; then |
---|
| 163 | if [ $verbose ]; then |
---|
[22825] | 164 | awk '/^MemTotal:/ { printf "user=%d, phys=%d (%d M)\n", |
---|
| 165 | $2, $2, $2/1024 }' \ |
---|
| 166 | /proc/meminfo |
---|
[13315] | 167 | else |
---|
[22825] | 168 | awk '/^MemTotal:/ { printf "%d\n", $2 }' /proc/meminfo |
---|
[13315] | 169 | fi |
---|
| 170 | printed=1 |
---|
| 171 | fi |
---|
| 172 | |
---|
[24053] | 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 | |
---|
[12361] | 184 | if [ $printed -eq '0' ] ; then |
---|
| 185 | echo linux |
---|
| 186 | fi |
---|
| 187 | exit 0 |
---|