#!/usr/bin/env bash
# periksa-conf.sh — pastikan directive wajib ada di berkas server block.
set -u
berkas=$1
gagal=0
for pola in \
    'server {' \
    'listen 80' \
    'server_name latihan.example.com' \
    'root /var/www/site/current' \
    'index index.html' \
    'try_files $uri $uri/ =404' \
    'gzip on' \
    'location /api/' \
    'proxy_pass http://127.0.0.1:8080/' \
    'server_tokens off' \
    'X-Content-Type-Options' \
    'X-Frame-Options' \
    'Referrer-Policy'
do
    if grep -qF -- "$pola" "$berkas"; then
        printf 'OK    %s\n' "$pola"
    else
        printf 'HILANG %s\n' "$pola"
        gagal=$((gagal + 1))
    fi
done
exit "$gagal"
