Contribs, Fribidi: allow to not build bins nor tests
[vlc.git] / extras / ci / check-url.sh
blob5e9f50af482ccdf67cc37efa92ab67282296e1f7
1 #!/usr/bin/env bash
2 # Copyright (C) Marvin Scholz
4 # License: see COPYING
6 # Check if a given URL exists or not
7 set -e
9 # Print error message and terminate script with status 1
10 # Arguments:
11 # Message to print
12 abort_err()
14 echo "ERROR: $1" >&2
15 exit 1
18 # Return the HTTP status code for a specific URL
19 # Arguments:
20 # URL
21 # Globals:
22 # HTTP_STATUS_CODE
23 get_http_status()
25 HTTP_STATUS_CODE=$(curl -s -o /dev/null -L -I -w "%{http_code}" "$1")
28 command -v "curl" >/dev/null 2>&1 || abort_err "cURL was not found!"
30 if [ $# -eq 0 ]; then
31 abort_err "No URL to check provided!"
34 get_http_status "$1"
36 if [ "$HTTP_STATUS_CODE" -eq 200 ]; then
37 true
38 else
39 abort_err "'$1' returned HTTP Status Code '$HTTP_STATUS_CODE'"