1 | #! /bin/sh |
---|
2 | # |
---|
3 | # $Revision: 1.1.1.2 $ |
---|
4 | # |
---|
5 | # This is the frontend command to SysInfo. SysInfo generally can only |
---|
6 | # be run on the OS Version it was compiled on. This wrapper script figures |
---|
7 | # out what platform it's being run on and then runs the real sysinfo |
---|
8 | # binary. All the real sysinfo binaries should exist in LIBDIR. |
---|
9 | # |
---|
10 | |
---|
11 | # |
---|
12 | # LIBDIR is where all the real executables live |
---|
13 | # |
---|
14 | if [ ! -z "${SYSINFOLIBDIR}" ]; then |
---|
15 | LIBDIR="${SYSINFOLIBDIR}" |
---|
16 | else |
---|
17 | # LIBDIR is filled in during install |
---|
18 | LIBDIR=#LIBDIR# |
---|
19 | fi |
---|
20 | |
---|
21 | # |
---|
22 | # Make sure we have a consistant execution path |
---|
23 | # |
---|
24 | PATH=/bin:/usr/bin:/usr/ucb:/sbin |
---|
25 | export PATH |
---|
26 | |
---|
27 | Program=`basename $0` |
---|
28 | RealProgram=sysinfo |
---|
29 | Debug="$METADEBUG" |
---|
30 | |
---|
31 | # |
---|
32 | # Find uname program. |
---|
33 | # |
---|
34 | if [ -f /usr/bin/uname ]; then |
---|
35 | unameprog=/usr/bin/uname |
---|
36 | elif [ -f /bin/uname ]; then |
---|
37 | unameprog=/bin/uname |
---|
38 | fi |
---|
39 | |
---|
40 | # |
---|
41 | # Determine our OS name if we can. |
---|
42 | # |
---|
43 | if [ "${unameprog}" ]; then |
---|
44 | osname="`${unameprog} -s`" |
---|
45 | fi |
---|
46 | |
---|
47 | # |
---|
48 | # Check for Convex SPP special handling |
---|
49 | # |
---|
50 | if [ "${osname}" = "HP-UX" ]; then |
---|
51 | if [ -x /bin/sysinfo ]; then |
---|
52 | altname="`/bin/sysinfo -sv | awk '{print $1}' | sed -e 's;_.*;;' 2>/dev/null`" |
---|
53 | if [ ! -z "${altname}" ]; then |
---|
54 | osname="${altname}" |
---|
55 | fi |
---|
56 | fi |
---|
57 | fi |
---|
58 | |
---|
59 | # |
---|
60 | # Try stupid file checks |
---|
61 | # |
---|
62 | if [ -z "${osname}" ]; then |
---|
63 | if [ -d /NextApps ]; then |
---|
64 | if [ -f /usr/bin/hostinfo ]; then |
---|
65 | mver="`/usr/bin/hostinfo | grep -i 'next mach' | awk '{print $3}' | sed -e 's/\..*//'`" |
---|
66 | osname="nextstep${mver}" |
---|
67 | else |
---|
68 | osname="nextstep2" |
---|
69 | fi |
---|
70 | elif [ -d /usr/alliant ]; then |
---|
71 | osname="concentrix" |
---|
72 | else |
---|
73 | echo "Unable to determine your OS type."; |
---|
74 | exit 1; |
---|
75 | fi |
---|
76 | fi |
---|
77 | |
---|
78 | osname="`echo ${osname} | tr '[A-Z]' '[a-z]' | sed -e 's;-;;g'`" |
---|
79 | |
---|
80 | # |
---|
81 | # Get OS Version |
---|
82 | # |
---|
83 | case "${osname}" in |
---|
84 | sunos) |
---|
85 | if [ -z "${unameprog}" ]; then |
---|
86 | echo "No uname program found." |
---|
87 | exit 1 |
---|
88 | fi |
---|
89 | osver="`${unameprog} -r`" |
---|
90 | ;; |
---|
91 | aix) |
---|
92 | osver="`${unameprog} -v`" |
---|
93 | if [ "$osver" -eq "4" ]; then |
---|
94 | aixosm="`${unameprog} -r`" |
---|
95 | osver=${osver}.${aixosm} |
---|
96 | fi |
---|
97 | ;; |
---|
98 | hpux) |
---|
99 | osver="`${unameprog} -r| sed -e 's;^[A-Za-z]\.;;' -e 's;^[0];;'`" |
---|
100 | ;; |
---|
101 | sppux) |
---|
102 | osver="`/bin/sysinfo -sv | awk '{print $2}'`" |
---|
103 | ;; |
---|
104 | concentrix) |
---|
105 | # We don't care what the os version is |
---|
106 | osver="" |
---|
107 | ;; |
---|
108 | *) |
---|
109 | # Default is uname -r |
---|
110 | if [ -z "${unameprog}" ]; then |
---|
111 | echo "No uname program found." |
---|
112 | exit 1 |
---|
113 | fi |
---|
114 | osver="`${unameprog} -r`" |
---|
115 | ;; |
---|
116 | esac |
---|
117 | |
---|
118 | if [ ! -z "${osver}" ]; then |
---|
119 | osmver=`echo $osver | sed -e 's;\..*;;g'` |
---|
120 | if [ -z "${osvernodot}" ]; then |
---|
121 | osvernodot=`echo $osver | sed -e 's;\.;;g'` |
---|
122 | fi |
---|
123 | fi |
---|
124 | |
---|
125 | # |
---|
126 | # Get Application Architecture |
---|
127 | # |
---|
128 | case "${osname}" in |
---|
129 | aix) |
---|
130 | # Hard code since we don't know how else to get this |
---|
131 | apparch="powerpc" |
---|
132 | ;; |
---|
133 | hpux) |
---|
134 | # Hard code since we don't know how else to get this |
---|
135 | apparch="`${unameprog} -m | sed -e 's;/.*;;' -e 's;9000;pa-risc;'`" |
---|
136 | ;; |
---|
137 | linux) |
---|
138 | apparch="`${unameprog} -m`" |
---|
139 | ;; |
---|
140 | sunos) |
---|
141 | if [ "${osmver}" -eq "4" ]; then |
---|
142 | apparch="`/bin/mach`" |
---|
143 | else |
---|
144 | apparch="`${unameprog} -p`" |
---|
145 | fi |
---|
146 | ;; |
---|
147 | *) |
---|
148 | apparch=unknown |
---|
149 | ;; |
---|
150 | esac |
---|
151 | |
---|
152 | # |
---|
153 | # Get CPU Architecture |
---|
154 | # |
---|
155 | case "${osname}" in |
---|
156 | sunos) |
---|
157 | if [ "${osmver}" = "5" ]; then |
---|
158 | if [ -x /bin/isainfo ]; then |
---|
159 | cpuarch="`/bin/isainfo -k`" |
---|
160 | else |
---|
161 | cpuarch="`${unameprog} -p`" |
---|
162 | fi |
---|
163 | else |
---|
164 | cpuarch="`${unameprog} -m`" |
---|
165 | fi |
---|
166 | ;; |
---|
167 | *) |
---|
168 | # Doesn't matter on other platforms |
---|
169 | cpuarch=${apparch} |
---|
170 | ;; |
---|
171 | esac |
---|
172 | |
---|
173 | Platform=${cpuarch}-${osname}-${osver} |
---|
174 | PlatDir=${LIBDIR}/${Platform} |
---|
175 | Bin=${PlatDir}/${RealProgram} |
---|
176 | |
---|
177 | if [ ! -f $Bin ]; then |
---|
178 | echo "${Program}: There is no executable for your platform (${Platform}) in ${PlatDir}" >&2 |
---|
179 | else |
---|
180 | if [ "$Debug" -gt 0 ]; then |
---|
181 | echo $Bin "$@" |
---|
182 | else |
---|
183 | exec $Bin "$@" |
---|
184 | fi |
---|
185 | fi |
---|
186 | |
---|