1
0

check.sh 722 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. #!/bin/bash
  2. DOMAINS=(
  3. "glamour.ovh"
  4. "expired.badssl.com"
  5. )
  6. NAMES=(
  7. "GLAM"
  8. "BAD"
  9. )
  10. check_domain() {
  11. local domain="$1"
  12. local name="$2"
  13. local url="https://${domain}"
  14. local status="FAIL"
  15. http_code=$(curl -s -o /dev/null -w "%{http_code}" --max-time 10 --head "$url")
  16. curl_exit=$?
  17. if [ $curl_exit -eq 0 ] && [ "$http_code" -ge 200 ] && [ "$http_code" -lt 400 ]; then
  18. status="OK"
  19. else
  20. status="NOK:ALERT"
  21. fi
  22. echo "${name}: ${status}"
  23. }
  24. if [ "${#DOMAINS[@]}" -ne "${#NAMES[@]}" ]; then
  25. echo "Error: Domain and Name array lengths do not match."
  26. exit 1
  27. fi
  28. for i in "${!DOMAINS[@]}"; do
  29. check_domain "${DOMAINS[$i]}" "${NAMES[$i]}"
  30. done