예제 소스
바둑 on-policy 학습: 대국 로그를 KataGo 라벨로 바꾸기 · 파일 169개
idc_install_mariago_landing.sh
#!/usr/bin/env bash
# IDC에서 실행: mariago.kr → 소개 페이지, HTTP nginx 샘플 제거
#
# scp -r deploy/mariago-landing ethtrade:~/mariago-landing
# scp scripts/idc_install_mariago_landing.sh ethtrade:~/
# ssh ethtrade 'chmod +x ~/idc_install_mariago_landing.sh && sudo ~/idc_install_mariago_landing.sh'
#
set -euo pipefail
# sudo 시 $HOME=/root 이므로, 인자 없으면 실제 로그인 사용자 홈을 씀
# (find_src_dir 가 홈·mariago-landing 등 후보 경로를 자동 탐색)
:
WEB_ROOT=/var/www/mariago
CONF_DST=/etc/nginx/sites-enabled/mariago.kr.conf
find_src_dir() {
local candidates=()
if [[ -n "${1:-}" ]]; then
candidates+=("$1")
fi
if [[ -n "${SUDO_USER:-}" ]]; then
candidates+=("~/project" "/home/$SUDO_USER")
fi
candidates+=("$HOME/mariago-landing" "$HOME")
local dir
for dir in "${candidates[@]}"; do
[[ -f "$dir/index.html" && -f "$dir/mariago.kr.conf" ]] || continue
printf '%s\n' "$dir"
return 0
done
return 1
}
if [[ "$(id -u)" -ne 0 ]]; then
echo "sudo 로 실행해 주세요." >&2
exit 1
fi
if ! SRC="$(find_src_dir "${1:-}")"; then
echo "소스 없음: index.html + mariago.kr.conf" >&2
echo " 예) scp -r deploy/mariago-landing ethtrade:~/mariago-landing" >&2
echo " 또는 홈에 index.html, mariago.kr.conf 가 있어야 합니다." >&2
exit 1
fi
echo "소스: $SRC"
mkdir -p "$WEB_ROOT"
find "$WEB_ROOT" -maxdepth 1 -type f \
\( -name '*.html' -o -name '*.css' -o -name '*.xml' -o -name '*.txt' \) \
-delete
cp -a "$SRC"/*.html "$SRC"/*.css "$SRC"/*.xml "$SRC"/*.txt "$WEB_ROOT/"
if [[ -f "$SRC/mariago.kr.conf" ]]; then
cp -a "$SRC/mariago.kr.conf" "$CONF_DST"
else
echo "mariago.kr.conf 없음" >&2
exit 1
fi
# default nginx 샘플이 default_server 로 mariago.kr HTTP를 가로채지 않게
if [[ -f /etc/nginx/sites-enabled/default ]]; then
sed -i 's/listen 80 default_server;/listen 80;/' /etc/nginx/sites-enabled/default
sed -i 's/listen \[::\]:80 default_server;/listen [::]:80;/' /etc/nginx/sites-enabled/default
fi
nginx -t
systemctl reload nginx
echo ""
echo "완료:"
echo " http://mariago.kr → https://mariago.kr (소개 페이지)"
echo " https://baduk.mariago.kr/play → 대국장"
curl -sI http://mariago.kr/ | head -3 || true
curl -sI https://mariago.kr/ | head -5 || true