#!/bin/bash

# 1. Check if Apache (Web Server) is responding locally
if curl -s --head http://localhost | grep "200\|301\|302\|403" > /dev/null
then
    # Everything is fine! Send a success ping to Healthchecks.io
    curl -fsS --retry 3 https://hc-ping.com/ed99ae1d-b5fd-4aac-86b1-53f7bc377108 > /dev/null
else
    # Web server is down! Optional: Send a failure signal immediately
    curl -fsS --retry 3 https://hc-ping.com/ed99ae1d-b5fd-4aac-86b1-53f7bc377108/fail > /dev/null
fi
