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