예제 소스
SGF 기보로 학습하는 바둑 LLM 인공지능 · 파일 169개
idc_install_othello_nginx.sh
#!/usr/bin/env bash
# IDC에서 실행: othello.mariago.kr nginx
#
# chmod +x ~/idc_install_othello_nginx.sh
# sudo ~/idc_install_othello_nginx.sh
#
# DNS: othello.mariago.kr A → ********
set -euo pipefail
REAL_HOME="${SUDO_USER:+$(getent passwd "$SUDO_USER" | cut -d: -f6)}"
REAL_HOME="${REAL_HOME:-$HOME}"
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
CONF_AVAIL=/etc/nginx/sites-available/othello.mariago.kr.conf
CONF_EN=/etc/nginx/sites-enabled/othello.mariago.kr.conf
if [[ "$(id -u)" -ne 0 ]]; then
echo "sudo 로 실행해 주세요: sudo $0" >&2
exit 1
fi
CONF_SRC=""
if [[ "${1:-}" != "" && -f "$1" ]]; then
CONF_SRC="$1"
else
for c in \
"$REAL_HOME/othello.mariago.kr.conf" \
"$SCRIPT_DIR/othello.mariago.kr.conf" \
"$REAL_HOME/deploy/othello.mariago.kr.conf"
do
if [[ -f "$c" ]]; then
CONF_SRC="$c"
break
fi
done
fi
if [[ -z "$CONF_SRC" || ! -f "$CONF_SRC" ]]; then
echo "설정 파일 없음. 아래로 올린 뒤 다시 실행하세요:" >&2
echo " (Mac) scp .../othello.mariago.kr.conf ethtrade:~/" >&2
echo "찾는 위치: $REAL_HOME/othello.mariago.kr.conf" >&2
exit 1
fi
echo "사용 conf: $CONF_SRC"
cp -a "$CONF_SRC" "$CONF_AVAIL"
ln -sfn "$CONF_AVAIL" "$CONF_EN"
if [[ ! -f /etc/letsencrypt/live/othello.mariago.kr/fullchain.pem ]]; then
if [[ -f /etc/letsencrypt/live/go.mariago.kr/fullchain.pem ]]; then
sed -i 's|/etc/letsencrypt/live/othello.mariago.kr/|/etc/letsencrypt/live/go.mariago.kr/|g' "$CONF_AVAIL"
# 이미 go 경로면 유지
sed -i 's|ssl_certificate /etc/letsencrypt/live/othello.mariago.kr/|ssl_certificate /etc/letsencrypt/live/go.mariago.kr/|g' "$CONF_AVAIL" || true
echo "임시 SSL: go.mariago.kr 인증서 사용 (이름 불일치 경고 가능)"
elif [[ -f /etc/letsencrypt/live/omook.mariago.kr/fullchain.pem ]]; then
sed -i 's|/etc/letsencrypt/live/go.mariago.kr/|/etc/letsencrypt/live/omook.mariago.kr/|g' "$CONF_AVAIL"
sed -i 's|/etc/letsencrypt/live/othello.mariago.kr/|/etc/letsencrypt/live/omook.mariago.kr/|g' "$CONF_AVAIL"
echo "임시 SSL: omook.mariago.kr 인증서 사용"
else
echo "경고: Let's Encrypt 인증서가 없습니다. certbot 발급이 필요합니다." >&2
fi
else
sed -i 's|/etc/letsencrypt/live/go.mariago.kr/|/etc/letsencrypt/live/othello.mariago.kr/|g' "$CONF_AVAIL" || true
fi
if [[ ! -f /etc/letsencrypt/ssl-dhparams.pem ]]; then
sed -i '/ssl_dhparam/d' "$CONF_AVAIL" || true
fi
sed -i 's/listen 443 ssl http2;/listen 443 ssl;/' "$CONF_AVAIL" || true
nginx -t
systemctl reload nginx
echo "nginx 등록: othello.mariago.kr → 127.0.0.1:18085"
echo ""
echo "인증서 (DNS 확인 후):"
echo " sudo certbot --nginx -d othello.mariago.kr"
echo " # 또는 기존 인증서에 확장:"
echo " sudo certbot certonly --nginx -d baduk.mariago.kr -d go.mariago.kr -d mariago.kr -d stoku.mariago.kr -d omook.mariago.kr -d othello.mariago.kr --expand"
echo ""
curl -sS -o /dev/null -w "local18085=%{http_code}\n" http://127.0.0.1:18085/ \
|| echo "local18085=DOWN (집 Mac 터널·Next :3004 확인)"