jobwat
7/16/2013 - 1:26 AM

check_host.sh

#!/bin/bash
exit_code=0

tests='
echo -n "MemCache service listening... ";                   netstat -l | grep "memcache.*LISTEN" > /dev/null 2>&1
echo -n "App returning Set-Cookie: XRSF-TOKEN header... ";  curl -I localhost 2>/dev/null | grep "Set-Cookie: XSRF-TOKEN" > /dev/null
echo -n "App /status return 200... ";                       curl --connect-timeout 1 localhost/status > /dev/null 2>&1
'

IFS=$'\n'
for test in $tests; do
  eval $test
  sub_code=$?
  if [ ${sub_code} -ne 0 ]; then
    exit_code=1
    echo "FAILED(${sub_code})."
  else
    echo "Ok."
  fi
done

exit $exit_code