Skip to content

Commit

Permalink
FreeBSD compatibility thanks to delmonta-iijima
Browse files Browse the repository at this point in the history
  • Loading branch information
Ian Foster committed May 23, 2016
1 parent 3099bac commit 8d508cf
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,20 @@ type convert >/dev/null 2>&1 || { echo >&2 "I require imagemagick but it's not i
MAGICK_CONFIGURE_PATH=$DIR
export MAGICK_CONFIGURE_PATH

# Finding MD5 calculator
#echo "finding MD5 calculator"
for f in md5sum md5
do
MD5SUM_EXE=`which $f 2> /dev/null`
if test ${MD5SUM_EXE}; then
break
fi
done
if ! test ${MD5SUM_EXE}; then
echo >&2 "not found. Aborting."
exit 1
fi

echo "testing read"
echo "Hello World" > readme
#echo "##### convert ######"
Expand Down Expand Up @@ -46,7 +60,7 @@ echo "testing http with local port: ${PORT}"
# silence job control messages
set -b
# setup a dummy http server
printf \"HTTP/1.0 200 OK\n\n\" | nc -l ${PORT} > requestheaders 2>/dev/null &
printf "HTTP/1.0 200 OK\n\n" | nc -l ${PORT} > requestheaders 2>/dev/null &
if test $? -ne 0; then
echo >&2 "failed to listen on localhost:${PORT}"
exit 1
Expand All @@ -58,13 +72,14 @@ if test -s requestheaders; then
echo "UNSAFE"
else
echo "SAFE"
echo | nc localhost ${PORT} 2>/dev/null 1>/dev/null
# terminate the dummy server
nc -z localhost ${PORT} 2>/dev/null >/dev/null
fi
rm requestheaders
set +b
echo ""

NONCE=$(echo $RANDOM | md5sum | fold -w 8 | head -n 1)
NONCE=$(echo $RANDOM | ${MD5SUM_EXE} | fold -w 8 | head -n 1)
echo "testing http with nonce: ${NONCE}"
IP=$(curl -q -s ifconfig.co)
sed "s:NONCE:${NONCE}:g" http.jpg > http1.jpg
Expand Down

0 comments on commit 8d508cf

Please sign in to comment.