#!/bin/bash

# Check if nginx process is running
if [ -z "$(pidof nginx)" ]; then
    exit 1
fi

# Check if nginx is responding over HTTP (localhost)
if [ -z "$(curl -s http://localhost/status)" ]; then
    exit 1
fi

# Check if nginx TCP/UDP-stream is connecting
if [ -z "$(echo "1337BEEF" | xxd -r -p | nc -nv 127.0.0.1 1514)" ]; then
    exit 1
fi

# Check if nginx TCP/UDP-stream is connecting
if [ -z "$(echo "1337BEEF" | xxd -r -p | nc -nv 127.0.0.1 1515)" ]; then
    exit 1
fi

exit 0
