#!/bin/bash
set -euo pipefail

# Detect OS
if [ -f /etc/redhat-release ]; then
    # Rocky Linux / CentOS / RHEL
    yum install -y nginx
    systemctl enable nginx
    systemctl start nginx

elif [ -f /etc/debian_version ]; then
    # Ubuntu / Debian
    apt-get update
    apt-get install -y nginx
    systemctl enable nginx
    systemctl start nginx

fi

echo "Nginx installed successfully"
