source: trunk/third/sysinfo/metasysinfo.sh @ 12269

Revision 12269, 3.5 KB checked in by ghudson, 26 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r12268, which included commits to RCS files with non-trunk default branches.
Line 
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#
14if [ ! -z "${SYSINFOLIBDIR}" ]; then
15    LIBDIR="${SYSINFOLIBDIR}"
16else
17    # LIBDIR is filled in during install
18    LIBDIR=#LIBDIR#
19fi
20
21#
22# Make sure we have a consistant execution path
23#
24PATH=/bin:/usr/bin:/usr/ucb:/sbin
25export PATH
26
27Program=`basename $0`
28RealProgram=sysinfo
29Debug="$METADEBUG"
30
31#
32# Find uname program.
33#
34if [ -f /usr/bin/uname ]; then
35        unameprog=/usr/bin/uname
36elif [ -f /bin/uname ]; then
37        unameprog=/bin/uname
38fi
39
40#
41# Determine our OS name if we can.
42#
43if [ "${unameprog}" ]; then
44        osname="`${unameprog} -s`"
45fi
46
47#
48# Check for Convex SPP special handling
49#
50if [ "${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
57fi
58
59#
60# Try stupid file checks
61#
62if [ -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
76fi
77
78osname="`echo ${osname} | tr '[A-Z]' '[a-z]' | sed -e 's;-;;g'`"
79
80#
81# Get OS Version
82#
83case "${osname}" in
84sunos)
85        if [ -z "${unameprog}" ]; then
86                echo "No uname program found."
87                exit 1
88        fi
89        osver="`${unameprog} -r`"
90        ;;
91aix)
92        osver="`${unameprog} -v`"
93        if [ "$osver" -eq "4" ]; then
94            aixosm="`${unameprog} -r`"
95            osver=${osver}.${aixosm}
96        fi
97        ;;
98hpux)
99        osver="`${unameprog} -r| sed -e 's;^[A-Za-z]\.;;' -e 's;^[0];;'`"
100        ;;
101sppux)
102        osver="`/bin/sysinfo -sv | awk '{print $2}'`"
103        ;;
104concentrix)
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        ;;
116esac
117
118if [ ! -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   
123fi
124
125#
126# Get Application Architecture
127#
128case "${osname}" in
129aix)
130    # Hard code since we don't know how else to get this
131    apparch="powerpc"
132    ;;
133hpux)
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    ;;
137linux)
138    apparch="`${unameprog} -m`"
139    ;;
140sunos)
141    if [ "${osmver}" -eq "4" ]; then
142        apparch="`/bin/mach`"
143    else
144        apparch="`${unameprog} -p`"
145    fi
146    ;;
147*)
148    apparch=unknown
149    ;;
150esac
151
152#
153# Get CPU Architecture
154#
155case "${osname}" in
156sunos)
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    ;;
171esac
172
173Platform=${cpuarch}-${osname}-${osver}
174PlatDir=${LIBDIR}/${Platform}
175Bin=${PlatDir}/${RealProgram}
176
177if [ ! -f $Bin ]; then
178    echo "${Program}: There is no executable for your platform (${Platform}) in ${PlatDir}" >&2
179else
180    if [ "$Debug" -gt 0 ]; then
181        echo $Bin "$@"
182    else
183        exec $Bin "$@"
184    fi
185fi
186
Note: See TracBrowser for help on using the repository browser.