From 06e10c3349fdb65668ca3719fb9577a70aac746c Mon Sep 17 00:00:00 2001 From: Simon Cornet Date: Sat, 23 May 2020 18:59:02 +0200 Subject: [PATCH] [FreeBSD] Added authentication support --- FreeBSD/url-check.csh | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/FreeBSD/url-check.csh b/FreeBSD/url-check.csh index 78bf628..238b85c 100644 --- a/FreeBSD/url-check.csh +++ b/FreeBSD/url-check.csh @@ -1,10 +1,23 @@ #!/bin/csh -f -set URL=$1 -set HS=$2 -set STATUS=`curl -L -o /dev/null -s -w "%{http_code}\n" -m 1 $URL` +set MODE=$1 + +if ($MODE == no_auth) then + set URL=$2 + set HS=$3 + set STATUS=`curl -L -o /dev/null -s -w "%{http_code}\n" -m 1 $URL` + + else if ($MODE == auth) then + set AUTH=$2 + set URL=$3 + set HS=$4 + set STATUS=`curl -L -o /dev/null -s -w "%{http_code}\n" -m 1 --user $AUTH $URL` + + else + exit 1 +endif if ($STATUS == 200) then /usr/local/bin/curl -fsS --retry 3 $HS > /dev/null else exit 1 -endif +endif \ No newline at end of file