forked from Singular/Singular
-
Notifications
You must be signed in to change notification settings - Fork 0
/
singuname.sh
executable file
·258 lines (255 loc) · 6.3 KB
/
singuname.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
#!/bin/sh
#
# FILE: singuname
# USAGE: singuname
# PURPOSE: prints to stdout a unique identifier of known uname(s)
# AUTHOR: obachman
# CREATED: 5/26/98
#
###########################################################################
egrep="egrep"
uname_a=`uname -a`
uname_m=`uname -m`
devnull='/dev/null'
file=file
binary='/bin/ls'
ldd='ldd'
# HPUX ########################################################
if (echo $uname_m | $egrep "HP-UX" > $devnull)
then
prefix=HPUX
# HPUX-9
if (echo $uname_a | $egrep "\.09\." > $devnull)
then
echo ${prefix}-9
exit 0
# HPUX-10
elif (echo $uname_a | $egrep "\.10\." > $devnull)
then
echo ${prefix}-10
exit 0
elif (echo $uname_a | $egrep " ia64 " > $devnull)
then
echo IA64-${prefix}
exit 0
else
echo ${prefix}-Unknown
exit 1
fi
# Intel ########################################################
elif (echo $uname_a | $egrep "i[3,4,5,6]86" > $devnull)
then
prefix=ix86
# Win ################
if (echo $uname_a | $egrep "CYGWIN" > $devnull)
then
echo ${prefix}-Win
exit 0
elif (echo $uname_a | $egrep "MINGW" > $devnull)
then
echo ${prefix}-Win
exit 0
# FreeBSD ###############
elif (echo $uname_a | $egrep "FreeBSD" > $devnull)
then
echo ${prefix}-freebsd
exit 0
# Linux ###############
elif (echo $uname_a | $egrep "Linux" > $devnull)
then
prefix=${prefix}-Linux
if (test -x $file && -x $binary)
then
# LinuxAOUT only if file does not match ELF
if ($file $binary | $egrep -v "ELF" > $devnull)
then
echo ${prefix}AOUT
exit 0
fi
fi
# everything else is assumed to be Linux ELF
# check for libc5
if (echo `$ldd $binary` | $egrep "libc.so.5" > $devnull)
then
echo "${prefix}-libc5"
else
echo ${prefix}
fi
exit 0
elif (echo $uname_a | $egrep "Darwin" >$devnull)
then
echo ix86Mac-darwin
exit 0
elif (echo $uname_a | $egrep "SunOS" >$devnull)
then
# NexentaOS ###############
if (echo $uname_a | $egrep "NexentaOS" > $devnull)
then
echo ${prefix}-nexentaos
else
echo ix86-SunOS
fi
exit 0
else
echo ${prefix}-Unknown
exit 1
fi
# AMD-Opteron ########################################################
elif (echo $uname_m | $egrep "x86_64" > $devnull)
then
prefix=x86_64
if (echo $uname_a | $egrep "Linux" > $devnull)
then
echo ${prefix}-Linux
exit 0
elif (echo $uname_a | $egrep "Darwin" >$devnull)
then
echo x86_64Mac-darwin
exit 0
else
echo ${prefix}-Unknown
exit 1
fi
# AMD-Opteron ########################################################
elif (echo $uname_m | $egrep "amd64" > $devnull)
then
prefix=x86_64
if (echo $uname_a | $egrep "FreeBSD" > $devnull)
then
echo ${prefix}-freebsd
exit 0
else
echo ${prefix}-Unknown
exit 1
fi
# HPPA ################################################################
elif (echo $uname_m | $egrep "hppa" > $devnull)
then
prefix=hppa
if (echo $uname_a | $egrep "Linux" > $devnull)
then
echo ${prefix}-Linux
exit 0
else
echo ${prefix}-Unknown
exit 1
fi
# SunOS ########################################################
elif (echo $uname_a | $egrep "SunOS" > $devnull)
then
if (echo $uname_a | $egrep "sun3" > $devnull)
then
prefix=Sun3OS
else
prefix=SunOS
fi
if (echo $uname_a | $egrep "4\.[0-9]" > $devnull)
then
echo ${prefix}-4
exit 0
# Solaris
elif (echo $uname_a | $egrep "5\.[0-9]" > $devnull)
then
echo ${prefix}-5
exit 0
else
echo ${prefix}-Unknown
exit 1
fi
# DecAlpha ########################################################
elif (echo $uname_m | $egrep "alpha" > $devnull)
then
prefix=DecAlpha
if (echo $uname_a | $egrep "Linux" > $devnull)
then
echo ${prefix}-Linux
exit 0
elif (echo $uname_a | $egrep "OSF1" > $devnull)
then
echo ${prefix}-OSF1
exit 0
else
echo ${prefix}-Unknown
exit 1
fi
# IRIX ########################################################
elif (echo $uname_m | $egrep "IRIX" > $devnull)
then
prefix=IRIX
if (echo $uname_a | $egrep "6\.[0-9]" > $devnull)
then
echo ${prefix}-6
exit 0
else
echo ${prefix}-Unknown
exit 1
fi
# AIX ########################################################
elif (echo $uname_a | $egrep "AIX" > $devnull)
then
prefix=AIX
if (uname -v | $egrep "4" > $devnull)
then
echo ${prefix}-4
exit 0
elif (uname -v | $egrep "5" > $devnull)
then
echo ${prefix}-5
exit 0
else
echo ${prefix}-Unknown
exit 1
fi
# Darwin/MacOS X ##############################################
elif (echo $uname_m | $egrep "Power Macintosh" > $devnull)
then
prefix="ppcMac"
if( uname -s | $egrep "Darwin" > $devnull)
then
echo ${prefix}-darwin
exit 0
else
echo ${prefix}-Unknown
exit 1
fi
# other PowerPC ##############################################
elif (echo $uname_m | $egrep "ppc" > $devnull)
then
prefix="ppc"
if (echo $uname_a | $egrep "Linux" > $devnull)
then
echo ${prefix}-Linux
exit 0
else
echo ${prefix}-Unknown
exit 1
fi
# itanium ########################################################
elif (echo $uname_m | $egrep "ia64" > $devnull)
then
# IA64-HPUX: see HPUX
prefix=IA64
if (echo $uname_a | $egrep "Linux" > $devnull)
then
echo ${prefix}-Linux
exit 0
else
echo ${prefix}-Unknown
exit 1
fi
# sparc64-Linux ############################################
elif (echo $uname_m | $egrep "sparc64" >$devnull)
then
prefix=sparc64
if (echo $uname_a | $egrep "Linux" > $devnull)
then
echo ${prefix}-Linux
exit 0
else
echo ${prefix}-Unknown
exit 1
fi
else # Unknown ########################################################
echo Unknown
exit 2
fi