scripts/FreeBSD/other/url-check.csh

24 lines
461 B
Tcsh
Raw Permalink Normal View History

2020-05-23 18:12:16 +02:00
#!/bin/csh -f
2020-05-23 18:59:02 +02:00
set MODE=$1
2020-05-23 19:31:38 +02:00
set CURL=/usr/local/bin/curl
2020-05-23 18:59:02 +02:00
if ($MODE == no_auth) then
set URL=$2
set HS=$3
2020-05-23 19:31:38 +02:00
set STATUS=`$CURL -L -o /dev/null -s -w "%{http_code}\n" -m 1 $URL`
2020-05-23 18:59:02 +02:00
else if ($MODE == auth) then
set AUTH=$2
set URL=$3
set HS=$4
2020-05-23 19:31:38 +02:00
set STATUS=`$CURL -L -o /dev/null -s -w "%{http_code}\n" -m 1 --user $AUTH $URL`
2020-05-23 18:59:02 +02:00
else
exit 1
endif
2020-05-23 18:12:16 +02:00
if ($STATUS == 200) then
2020-05-23 19:31:38 +02:00
$CURL -fsS --retry 3 $HS > /dev/null
2020-05-23 18:12:16 +02:00
else
exit 1
2020-05-23 18:59:02 +02:00
endif