Created
November 29, 2018 00:12
-
-
Save mikepsinn/4cb3aca1a1fe0021627508579f8cac41 to your computer and use it in GitHub Desktop.
Checks a url every 30 seconds and sleeps until 200 response
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set +x | |
url=${1:-${url}} | |
#url=https://qm-staging.quantimo.do/ionic/Modo/www/scripts/combined-head-libraries-6fcc81560c.js | |
echo "CHECKING $url" | |
timeout=${2:-'3'} | |
# ^in seconds | |
flag=${3:-'--status'} | |
# curl options, e.g. -L to follow redirects | |
arg4=${4:-''} | |
arg5=${5:-''} | |
arg6=${6:-''} | |
arg7=${7:-''} | |
curl_options="$arg4 $arg5 $arg6 $arg7" | |
sleepTime=30 | |
while : | |
do | |
if [[ ${url} =~ "staging" ]]; | |
then | |
response_code=`echo $(curl --write-out %{http_code} --silent -S --connect-timeout $timeout \ | |
--no-keepalive -H 'authority: qm-staging.quantimo.do' -H 'pragma: no-cache' -H 'cache-control: no-cache' -H 'upgrade-insecure-requests: 1' -H 'user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36' -H 'accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8' -H 'accept-encoding: gzip, deflate, br' -H 'accept-language: en-US,en;q=0.9' -H 'cookie: _ga=GA1.2.1173720470.1541540783; _gid=GA1.2.1963482554.1541540783; __cfduid=d4f4b397902e846e58d3b6447af48667d1541541114;' -H 'x-firelogger: 1.3' --compressed --output /dev/null ${url})` | |
else | |
response_code=`echo $(curl --write-out %{http_code} --silent -S --connect-timeout $timeout \ | |
--no-keepalive -H 'authority: quantimodo.quantimo.do' -H 'pragma: no-cache' -H 'cache-control: no-cache' -H 'upgrade-insecure-requests: 1' -H 'user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36' -H 'accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8' -H 'accept-encoding: gzip, deflate, br' -H 'accept-language: en-US,en;q=0.9' -H 'cookie: _ga=GA1.2.1173720470.1541540783; _gid=GA1.2.1963482554.1541540783; __cfduid=d4f4b397902e846e58d3b6447af48667d1541541114;' -H 'x-firelogger: 1.3' --compressed --output /dev/null ${url})` | |
fi | |
now=$(date +"%T") | |
if [[ ${response_code} -eq 200 ]] | |
then | |
echo "$response_code response from $url at $now." | |
break; | |
else | |
echo "$response_code response from $url at $now. Sleeping $sleepTime seconds and checking again..." | |
sleep ${sleepTime} | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment