#!/usr/bin/env bash # SSL for dyapi + dyadmin only (dy.nomadro.cn is used by another service) set -euo pipefail sed -i 's/\r$//' /opt/dymini/deploy/*.sh 2>/dev/null || true DOMAINS=(dyapi.nomadro.cn dyadmin.nomadro.cn) PANEL=/www/server/panel/vhost/nginx REMOTE=/opt/dymini ensure_http_bootstrap() { local domain="$1" local root="/www/wwwroot/${domain}" local conf="${PANEL}/${domain}.conf" sudo mkdir -p "$root/.well-known/acme-challenge" if ! sudo test -f "/etc/letsencrypt/live/${domain}/fullchain.pem"; then sudo tee "$conf" >/dev/null </dev/null || sudo nginx -s reload for d in "${DOMAINS[@]}"; do if sudo test -f "/etc/letsencrypt/live/${d}/fullchain.pem"; then echo "cert exists: $d" continue fi echo "issuing cert: $d" sudo certbot certonly --webroot \ -w "/www/wwwroot/${d}" \ -d "$d" \ --non-interactive --agree-tos \ -m admin@nomadro.cn \ || echo "WARN: certbot failed for $d" done for f in dyapi.nomadro.cn.conf dyadmin.nomadro.cn.conf; do domain="${f%.conf}" if ! sudo test -f "/etc/letsencrypt/live/${domain}/fullchain.pem"; then echo "skip SSL restore for $domain (no cert)" continue fi echo "install SSL nginx conf: $f" sudo cp "$REMOTE/deploy/$f" "$PANEL/$f" done sudo rsync -a --delete /opt/dymini/admin/dist/ /www/wwwroot/dyadmin.nomadro.cn/ if id www >/dev/null 2>&1; then sudo chown -R www:www /www/wwwroot/dyadmin.nomadro.cn || true fi sudo nginx -t sudo /etc/init.d/nginx reload 2>/dev/null || sudo nginx -s reload echo "--- verify ---" curl -sk https://127.0.0.1/health -H 'Host: dyapi.nomadro.cn' || true echo curl -sI https://dyapi.nomadro.cn/health | head -n 5 || true curl -sI https://dyadmin.nomadro.cn/ | head -n 5 || true echo "issue-certs done"