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
|
#!/bin/sh
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
HOSTNAME=`uname -n`
OS=`uname -s`
CPUTYPE=`uname -p`
BITNESS=32
LS=/bin/ls
OSFAMILY=
DATETIME=`date -u +'%Y-%m-%d %H:%M:%S'`
if [ "${OS}" = "SunOS" ]; then
BITNESS=`isainfo -b`
OSFAMILY="SUNOS"
OSNAME="SunOS"
OSBUILD=`head -1 /etc/release | sed -e "s/^ *//"`
CPUNUM=`/usr/sbin/psrinfo -v | grep "^Status of" | wc -l | sed 's/^ *//'`
else
if [ "${OS}" = "Darwin" ]; then
sysctl hw.cpu64bit_capable | grep -q "1$"
if [ $? -eq 0 ]; then
BITNESS=64
fi
else
uname -a | egrep "x86_64|WOW64|sparc64" >/dev/null
if [ $? -eq 0 ]; then
BITNESS=64
fi
fi
if [ -f "/etc/sun-release" ]; then
OSNAME="${OS}-JDS"
OSBUILD=`head -1 /etc/sun-release`
elif [ -f /etc/SuSE-release ]; then
OSNAME="${OS}-SuSE"
OSBUILD=`cat /etc/SuSE-release | tr "\n" " "`;
elif [ -f /etc/redhat-release ]; then
OSNAME="${OS}-Redhat"
OSBUILD=`head -1 /etc/redhat-release`
elif [ -f /etc/gentoo-release ]; then
OSNAME="${OS}-Gentoo"
OSBUILD=`head -1 /etc/gentoo-release`
elif [ -f /etc/lsb-release ]; then
OSNAME="${OS}-"`cat /etc/lsb-release | grep DISTRIB_ID | sed 's/.*=//'`
OSBUILD=`cat /etc/lsb-release | grep DISTRIB_DESCRIPTION | sed 's/.*=//' | sed 's/"//g'`
fi
fi
OSFAMILY=${OSFAMILY:-`echo ${OS} | grep _NT- >/dev/null && echo WINDOWS`}
OSFAMILY=${OSFAMILY:-`test "$OS" = "Darwin" && echo MACOSX`}
OSFAMILY=${OSFAMILY:-`test "$OS" = "Linux" && echo LINUX`}
OSFAMILY=${OSFAMILY:-${OS}}
CPUFAMILY=`(echo ${CPUTYPE} | egrep "^i|x86_64|athlon|Intel" >/dev/null && echo x86) || echo ${CPUTYPE}`
if [ "${CPUFAMILY}" != "x86" -a "${CPUFAMILY}" != "sparc" -a "${CPUFAMILY}" != "sparc64" ]; then
CPUTYPE=`uname -m`
fi
CPUFAMILY=`(echo ${CPUTYPE} | egrep "^i|x86_64|athlon|Intel" >/dev/null && echo x86) || echo ${CPUTYPE}`
if [ "${CPUFAMILY}" = "sparc64" ]; then
CPUFAMILY="sparc"
fi
USERDIRBASE=${HOME}
if [ "${OSFAMILY}" = "LINUX" ]; then
if [ "${CPUFAMILY}" = "sparc" ]; then
CPUNUM=`cat /proc/cpuinfo | grep 'ncpus active' | sed 's/[^:]*.[ ]*//'`
else
CPUNUM=`cat /proc/cpuinfo | grep processor | wc -l | sed 's/^ *//'`
fi
elif [ "${OSFAMILY}" = "WINDOWS" ]; then
CPUNUM=$NUMBER_OF_PROCESSORS
OSNAME=`uname`
USERDIRBASE=${USERPROFILE}
elif [ "${OSFAMILY}" = "MACOSX" ]; then
CPUNUM=`hostinfo | awk '/processor.*logical/{print $1}'`
OSNAME="MacOSX"
OSBUILD=`hostinfo | sed -n '/kernel version/{n;p;}' | sed 's/[ ]*\([^:]*\).*/\1/'`
elif [ "${OSFAMILY}" = "FreeBSD" ]; then
CPUNUM=`sysctl hw.ncpu | awk '{print $2}'`
OSNAME=`sysctl -n kern.ostype`
OSBUILD=`sysctl -n kern.osrelease`
fi
wx_fail() {
tmp="${1}/wx_test"
touch ${tmp} 2> /dev/null
if [ $? -eq 0 ]; then
chmod u+x ${tmp} 2> /dev/null
if [ -x ${tmp} ]; then
rm ${tmp} 2> /dev/null
return 1
fi
rm ${tmp} 2> /dev/null
fi
return 0
}
USER=${USER:-`logname 2>/dev/null`}
USER=${USER:-${USERNAME}}
USER_D=`echo ${USER} | sed "s/\\\/_/"`
TMPBASE=${TMPBASE:-/var/tmp}
SUFFIX=0
TMPDIRBASE=${TMPBASE}/dlight_${USER_D}
if wx_fail ${TMPBASE}; then
if wx_fail ${TMPDIRBASE}; then
TMPBASE=/tmp
TMPDIRBASE=${TMPBASE}/dlight_${USER_D}
fi
fi
mkdir -p ${TMPDIRBASE}
while [ ${SUFFIX} -lt 5 ]; do
if wx_fail ${TMPDIRBASE}; then
echo "Warning: TMPDIRBASE is not writable: ${TMPDIRBASE}">&2
SUFFIX=`expr 1 + ${SUFFIX}`
TMPDIRBASE=${TMPBASE}/dlight_${USER_D}_${SUFFIX}
/bin/mkdir -p ${TMPDIRBASE} 2>/dev/null
else
break
fi
done
if wx_fail ${TMPDIRBASE}; then
:
else
SUFFIX=0
TMPBASE=${TMPDIRBASE}
TMPDIRBASE=${TMPBASE}/${NB_KEY}
mkdir -p ${TMPDIRBASE}
while [ ${SUFFIX} -lt 5 ]; do
if wx_fail ${TMPDIRBASE}; then
echo "Warning: TMPDIRBASE is not writable: ${TMPDIRBASE}">&2
SUFFIX=`expr 1 + ${SUFFIX}`
TMPDIRBASE=${TMPBASE}/${NB_KEY}_${SUFFIX}
/bin/mkdir -p ${TMPDIRBASE} 2>/dev/null
else
break
fi
done
fi
if wx_fail ${TMPDIRBASE}; then
TMPDIRBASE=${TMPBASE}
fi
if wx_fail ${TMPDIRBASE}; then
echo "Error: TMPDIRBASE is not writable: ${TMPDIRBASE}">&2
fi
ENVFILE="${TMPDIRBASE}/env"
ID=`LC_MESSAGES=C /usr/bin/id`
echo BITNESS=${BITNESS}
echo CPUFAMILY=${CPUFAMILY}
echo CPUNUM=${CPUNUM}
echo CPUTYPE=${CPUTYPE}
echo HOSTNAME=${HOSTNAME}
echo OSNAME=${OSNAME}
echo OSBUILD=${OSBUILD}
echo OSFAMILY=${OSFAMILY}
echo USER=${USER}
echo SH=${SHELL}
echo USERDIRBASE=${USERDIRBASE}
echo TMPDIRBASE=${TMPDIRBASE}
echo DATETIME=${DATETIME}
echo ENVFILE=${ENVFILE}
echo ID=${ID}
exit 0
|