2014-12-25 01:22:47 +08:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
#NOEMBED=1
|
|
|
|
#NOLOCAL=1
|
|
|
|
#NOHOME=1
|
2015-03-04 12:01:43 +08:00
|
|
|
#NOENV=1
|
2014-12-25 01:22:47 +08:00
|
|
|
|
|
|
|
#DBG=1
|
2015-03-04 12:01:43 +08:00
|
|
|
#SHOW=1
|
|
|
|
|
|
|
|
# Choose at most 1
|
2014-12-25 01:22:47 +08:00
|
|
|
#GDB=1
|
2015-03-04 12:01:43 +08:00
|
|
|
#VG=1
|
2014-12-25 01:22:47 +08:00
|
|
|
|
2015-03-04 12:01:43 +08:00
|
|
|
NFL=1
|
2014-12-25 01:22:47 +08:00
|
|
|
|
2015-01-01 13:29:36 +08:00
|
|
|
WD=`pwd`
|
|
|
|
|
|
|
|
NETRCFILE=$WD/test_auth_netrc
|
2014-12-25 01:22:47 +08:00
|
|
|
# This is the control variable
|
|
|
|
NETRC=$NETRCFILE
|
2015-03-04 12:01:43 +08:00
|
|
|
|
2015-01-01 13:29:36 +08:00
|
|
|
COOKIES="${WD}/test_auth_cookies"
|
|
|
|
|
2015-03-04 12:01:43 +08:00
|
|
|
RC=.daprc
|
|
|
|
|
|
|
|
NCLOGFILE=stderr
|
|
|
|
if test "x$DBG" = x1 ; then
|
|
|
|
SHOW=1
|
|
|
|
fi
|
2014-12-25 01:22:47 +08:00
|
|
|
|
|
|
|
# Major parameters
|
|
|
|
|
|
|
|
BASICCOMBO="tiggeUser:tigge"
|
|
|
|
URLSERVER="remotetest.unidata.ucar.edu"
|
|
|
|
URLPATH="thredds/dodsC/restrict/testData.nc"
|
|
|
|
|
|
|
|
# See if we need to override
|
|
|
|
if test "x$URS" != "x" ; then
|
|
|
|
#https://54.86.135.31/opendap/data/nc/fnoc1.nc.dds
|
|
|
|
URLSERVER="54.86.135.31"
|
|
|
|
URLPATH="opendap/data/nc/fnoc1.nc"
|
|
|
|
BASICCOMBO="$URS"
|
|
|
|
NOEMBED=1
|
|
|
|
NETRC=$NETRCFILE
|
|
|
|
else
|
|
|
|
NETRC=
|
|
|
|
fi
|
|
|
|
|
2015-03-04 12:01:43 +08:00
|
|
|
if test "x$DBG" = x1 ; then
|
|
|
|
URLPATH="${URLPATH}#log&show=fetch"
|
|
|
|
fi
|
2015-01-01 13:29:36 +08:00
|
|
|
|
2014-12-25 01:22:47 +08:00
|
|
|
# Split the combo
|
|
|
|
BASICUSER=`echo $BASICCOMBO | cut -d: -f1`
|
|
|
|
BASICPWD=`echo $BASICCOMBO | cut -d: -f2`
|
|
|
|
|
2015-03-04 12:01:43 +08:00
|
|
|
NCDUMP=
|
|
|
|
for o in ./.libs/ncdump.exe ./.libs/ncdump ./ncdump.exe ./ncdump ; do
|
|
|
|
if test -f $o ; then
|
|
|
|
NCDUMP=$o
|
|
|
|
break;
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
if test "x$NCDUMP" = x ; then
|
|
|
|
echo "no ncdump"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if test "x$SHOW" = x ; then
|
|
|
|
OUTPUT="> /dev/null"
|
|
|
|
else
|
|
|
|
OUTPUT=
|
|
|
|
fi
|
|
|
|
|
|
|
|
if test "x$TEMP" = x ; then
|
|
|
|
TEMP="/tmp"
|
|
|
|
fi
|
|
|
|
TEMP=`echo "$TEMP" | sed -e "s|/$||"`
|
2014-12-25 01:22:47 +08:00
|
|
|
|
|
|
|
LOCALRC=./$RC
|
|
|
|
HOMERC=${HOME}/$RC
|
|
|
|
HOMERC=`echo "$HOMERC" | sed -e "s|//|/|g"`
|
2015-03-04 12:01:43 +08:00
|
|
|
ENVRC="$TEMP/$RC"
|
|
|
|
|
|
|
|
cd `pwd`
|
|
|
|
builddir=`pwd`
|
|
|
|
# Hack for CYGWIN
|
|
|
|
cd $srcdir
|
|
|
|
srcdir=`pwd`
|
|
|
|
cd ${builddir}
|
2014-12-25 01:22:47 +08:00
|
|
|
|
|
|
|
function createrc {
|
2015-03-04 12:01:43 +08:00
|
|
|
if test "x$1" != x ; then
|
|
|
|
RCP=$1
|
|
|
|
|
|
|
|
rm -f $RCP
|
|
|
|
echo "Creating rc file $RCP"
|
|
|
|
if test "x${DBG}" != x ; then
|
|
|
|
echo "HTTP.VERBOSE=1" >>$RCP
|
|
|
|
fi
|
|
|
|
echo "HTTP.COOKIEJAR=${COOKIES}" >>$RCP
|
|
|
|
if test "x${URS}" = x ; then
|
|
|
|
echo "HTTP.CREDENTIALS.USERPASSWORD=${BASICCOMBO}" >>$RCP
|
|
|
|
fi
|
|
|
|
if test "x${NETRC}" != x && test "x$NFL" = x ; then
|
|
|
|
echo "HTTP.NETRC=${NETRC}" >>$RCP
|
|
|
|
fi
|
|
|
|
fi
|
2014-12-25 01:22:47 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
function createnetrc {
|
2015-03-04 12:01:43 +08:00
|
|
|
if test "x$1" != x ; then
|
|
|
|
rm -f $1
|
|
|
|
echo "Creating netrc file $1"
|
|
|
|
echo "machine uat.urs.earthdata.nasa.gov login $BASICUSER password $BASICPWD" >>$1
|
|
|
|
#echo "machine 54.86.135.31 login $BASICUSER password $BASICPWD" >>$1
|
|
|
|
fi
|
2014-12-25 01:22:47 +08:00
|
|
|
}
|
|
|
|
|
2015-03-04 12:01:43 +08:00
|
|
|
# Forcibly remove all and do not restore with save
|
2014-12-25 01:22:47 +08:00
|
|
|
function reset {
|
2015-03-04 12:01:43 +08:00
|
|
|
for f in ./$RC $HOMERC $ENVRC $COOKIES $NETRC ; do
|
|
|
|
rm -f ${f}
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
# Restore from .save files
|
|
|
|
function restore {
|
|
|
|
for f in ./$RC $HOMERC $ENVRC $COOKIES $NETRC ; do
|
2015-01-01 13:29:36 +08:00
|
|
|
rm -f ${f}
|
|
|
|
if test -f ${f}.save ; then
|
2015-03-04 12:01:43 +08:00
|
|
|
echo "restoring old ${f}"
|
2015-01-01 13:29:36 +08:00
|
|
|
cp ${f}.save ${f}
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
function save {
|
2015-03-04 12:01:43 +08:00
|
|
|
for f in ./$RC $HOMERC $ENVRC $COOKIES $NETRC ; do
|
2015-01-01 13:29:36 +08:00
|
|
|
if test -f $f ; then
|
|
|
|
if test -f ${f}.save ; then
|
|
|
|
ignore=1
|
|
|
|
else
|
2015-03-04 12:01:43 +08:00
|
|
|
echo "saving $f"
|
2015-01-01 13:29:36 +08:00
|
|
|
cp ${f} ${f}.save
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
done
|
2014-12-25 01:22:47 +08:00
|
|
|
}
|
|
|
|
|
2015-03-04 12:01:43 +08:00
|
|
|
export LD_LIBRARY_PATH="../liblib/.libs:/usr/local/lib:/usr/lib64:$LD_LIBRARY_PATH"
|
2015-01-01 13:29:36 +08:00
|
|
|
|
2014-12-25 01:22:47 +08:00
|
|
|
if test "x$GDB" = x1 ; then
|
2015-03-04 12:01:43 +08:00
|
|
|
NCDUMP="gdb --args $NCDUMP"
|
|
|
|
fi
|
|
|
|
if test "x$VG" = x1 ; then
|
|
|
|
NCDUMP="valgrind --leak-check=full $NCDUMP"
|
2014-12-25 01:22:47 +08:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Initialize
|
2015-01-01 13:29:36 +08:00
|
|
|
save
|
2014-12-25 01:22:47 +08:00
|
|
|
reset
|
|
|
|
|
|
|
|
if test "x$NOEMBED" != x1 ; then
|
|
|
|
echo "***Testing rc file with embedded user:pwd"
|
|
|
|
URL="https://${BASICCOMBO}@${URLSERVER}/$URLPATH"
|
2015-03-04 12:01:43 +08:00
|
|
|
# Invoke ncdump to extract a file from the URL
|
|
|
|
echo "command: ${NCDUMP} -h $URL ${OUTPUT}"
|
|
|
|
${NCDUMP} -h "$URL" ${OUTPUT}
|
2014-12-25 01:22:47 +08:00
|
|
|
fi
|
|
|
|
|
|
|
|
URL="https://${URLSERVER}/$URLPATH"
|
|
|
|
if test "x$NOLOCAL" != x1 ; then
|
2015-03-04 12:01:43 +08:00
|
|
|
echo "***Testing rc file in local directory"
|
|
|
|
# Create the rc file and (optional) netrc file in ./
|
|
|
|
reset
|
|
|
|
createnetrc $NETRC
|
|
|
|
createrc $LOCALRC
|
|
|
|
|
|
|
|
# Invoke ncdump to extract a file the URL
|
|
|
|
echo "command: ${NCDUMP} -h $URL ${OUTPUT}"
|
|
|
|
${NCDUMP} -h "$URL" ${OUTPUT}
|
2014-12-25 01:22:47 +08:00
|
|
|
fi
|
|
|
|
|
|
|
|
if test "x$NOHOME" != x1 ; then
|
2015-03-04 12:01:43 +08:00
|
|
|
echo "***Testing rc file in home directory"
|
|
|
|
# Create the rc file and (optional) netrc fil in ./
|
|
|
|
reset
|
|
|
|
createnetrc $NETRC
|
|
|
|
createrc $HOMERC
|
|
|
|
|
|
|
|
# Invoke ncdump to extract a file the URL
|
|
|
|
echo "command: ${NCDUMP} -h $URL ${OUTPUT}"
|
|
|
|
${NCDUMP} -h "$URL" ${OUTPUT}
|
2014-12-25 01:22:47 +08:00
|
|
|
fi
|
|
|
|
|
2015-03-04 12:01:43 +08:00
|
|
|
if test "x$NOENV" != x1 ; then
|
|
|
|
echo "*** Testing rc file from env variable"
|
|
|
|
# Create the rc file and (optional) netrc file
|
2014-12-25 01:22:47 +08:00
|
|
|
reset
|
2015-03-04 12:01:43 +08:00
|
|
|
createnetrc $NETRC
|
|
|
|
export NCRCFILE=$ENVRC
|
|
|
|
createrc $NCRCFILE
|
|
|
|
|
|
|
|
# Invoke ncdump to extract a file the URL
|
|
|
|
echo "command: ${NCDUMP} -h $URL ${OUTPUT}"
|
|
|
|
${NCDUMP} -h "$URL" ${OUTPUT}
|
|
|
|
fi
|
|
|
|
|
|
|
|
set +x
|
|
|
|
#restore
|
2014-12-25 01:22:47 +08:00
|
|
|
|