#!/bin/bash
#
# Check the ubuntu branding exists
set -uxe -o pipefail

ubuntu_logo_path="icons/ubuntu-logo.png"

# Use curl to fetch the HTML content and check its exit status
if html_content=$(curl -s http://localhost); then
  # The curl command succeeded, so proceed with further processing
  if ! [[ "$html_content" =~ "$ubuntu_logo_path" ]]; then
    echo "ERROR: $ubuntu_logo_path string not found in html page"
    exit 1
  fi
else
  # The curl command encountered an error
  echo "ERROR: Curl command failed to fetch web content"
  exit 1
fi

# Check the type of $ubuntu_logo_path
content_type=$(curl -s -I http://localhost/$ubuntu_logo_path \
	| grep Content-Type | cut -d ' ' -f 2- | tr -d '[:space:]')
expected="image/png"
if [ "$content_type" != "$expected" ]; then
  echo "Content-Type is not $expected it is $content_type"
  exit 1
fi
