#!/bin/bash

# 就绪检查， 返回0表示就绪

# 请求http://localhost:80
# status 返回5xx or 000  启动中(未就绪)
#        返回404 未实现该接口，认为就绪
#        返回2xx， 就绪
#        其他， 就绪

statusCode=`curl -I -X HEAD -o /dev/null -s -w %{http_code} -H "Connection: close" http://localhost`
echo "statusCode: ${statusCode}"

statusCodeFirst="${statusCode:0:1}"
echo "statusCodeFirst: ${statusCodeFirst}"

READY=0
UNREADY=1

if [ ${statusCodeFirst} = "5" -o ${statusCodeFirst} = "0" ]
then
  exit ${UNREADY}
fi
  exit ${READY}