예제 소스
바둑 on-policy 학습: 대국 로그를 KataGo 라벨로 바꾸기 · 파일 169개
idc_install_stoku_nginx.sh
#!/usr/bin/env bash
# IDC에서 실행: stoku.mariago.kr nginx
#
# chmod +x ~/idc_install_stoku_nginx.sh
# sudo ~/idc_install_stoku_nginx.sh
#
# DNS: stoku.mariago.kr A → ********
set -euo pipefail
# sudo 시 HOME=/root 이므로 실제 유저 홈을 사용
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/stoku.mariago.kr.conf
CONF_EN=/etc/nginx/sites-enabled/stoku.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/stoku.mariago.kr.conf" \
"$SCRIPT_DIR/stoku.mariago.kr.conf" \
"$REAL_HOME/mariago-landing/stoku.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 .../stoku.mariago.kr.conf ethtrade:~/" >&2
echo "찾는 위치: $REAL_HOME/stoku.mariago.kr.conf" >&2
exit 1
fi
echo "사용 conf: $CONF_SRC"
cp -a "$CONF_SRC" "$CONF_AVAIL"
ln -sfn "$CONF_AVAIL" "$CONF_EN"
# baduk 인증서 경로가 없으면 go.mariago.kr 경로 사용 (IDC 실제 경로)
if [[ ! -f /etc/letsencrypt/live/baduk.mariago.kr/fullchain.pem ]] \
&& [[ -f /etc/letsencrypt/live/go.mariago.kr/fullchain.pem ]]; then
sed -i 's|/etc/letsencrypt/live/baduk.mariago.kr/|/etc/letsencrypt/live/go.mariago.kr/|g' "$CONF_AVAIL"
fi
if [[ ! -f /etc/letsencrypt/ssl-dhparams.pem ]]; then
sed -i '/ssl_dhparam/d' "$CONF_AVAIL" || true
fi
# http2 중복 listen 경고 방지
sed -i 's/listen 443 ssl http2;/listen 443 ssl;/' "$CONF_AVAIL" || true
if ! ls /etc/letsencrypt/live/*/fullchain.pem >/dev/null 2>&1; then
echo "경고: Let's Encrypt 인증서가 없습니다. certbot 발급이 필요합니다." >&2
fi
nginx -t
systemctl reload nginx
echo "nginx 등록: stoku.mariago.kr → 127.0.0.1:18081"
echo ""
echo "인증서 (DNS 확인 후):"
echo " sudo certbot --nginx -d stoku.mariago.kr"
echo " # 또는 baduk 인증서에 확장:"
echo " sudo certbot certonly --nginx -d baduk.mariago.kr -d go.mariago.kr -d mariago.kr -d stoku.mariago.kr --expand"
echo ""
curl -sS -o /dev/null -w "local18081=%{http_code}\n" http://127.0.0.1:18081/ \
|| echo "local18081=DOWN (집 Mac 터널·Next :3001 확인)"