#!/bin/bash

# Проверяем наличие сертификатов для всех трёх доменов
if \
  [ -f "/etc/letsencrypt/live/yalarba.ru/fullchain.pem" ] && \
  [ -f "/etc/letsencrypt/live/easysite102.ru/fullchain.pem" ] && \
  [ -f "/etc/letsencrypt/live/valitovgaziz.ru/fullchain.pem" ] && \
  [ -f "/etc/letsencrypt/live/begushiybashkir.ru/fullchain.pem" ] && \
  [ -f "/etc/letsencrypt/live/xn--80abahjtcfl5d0a8di.xn--p1ai/fullchain.pem" ]
  [ -f "/etc/letsencrypt/live/auth.yalarba.ru/fullchain.pem" ]; then
  echo "SSL certificates found for all domains, switching to HTTPS configuration"
  ln -sf /etc/nginx/nginx-ssl.conf /etc/nginx/conf.d/default.conf
else
  echo "SSL certificates not found, using HTTP only configuration"
  ln -sf /etc/nginx/nginx-http.conf /etc/nginx/conf.d/default.conf
fi

# Проверяем конфигурацию nginx
nginx -t
