#!/usr/bin/env bash # orke 리눅스 서버 설치 — 한 줄로: curl -fsSL https://orke.bomtobe.com/install.sh | bash # 특정 판: curl -fsSL https://orke.bomtobe.com/install.sh | bash -s -- --version 3.4.6 # # GitHub 릴리스(bomtobe-hgkim/orke-linux)에서 리눅스 패키지(orke-<판>-linux-x64.tar.gz)를 찾아 받고, 같은 릴리스의 SHA-256 파일로 # 확인한 뒤 임시 폴더에 풀어 패키지 안의 install.sh 를 돌린다. 설치 자리(~/.local/share/orke, 명령 ~/.local/bin/orke), 필요한 패키지 검사, # 돌고 있는 서비스의 멈춤·다시 시작은 그 install.sh 가 정한다 — 여기서는 받기·확인·풀기만 한다. 임시 폴더는 끝날 때 지운다. # 안내(영어): https://github.com/bomtobe-hgkim/orke-linux#readme # # 전체를 main 함수 하나에 담고 맨 끝에서 부른다 — curl | bash 는 받는 대로 실행하므로, 내려받기가 중간에 끊겨도 반쪽 스크립트가 돌지 않는다. set -euo pipefail REPO="bomtobe-hgkim/orke-linux" GUIDE="https://github.com/${REPO}#readme" # 받은 패키지와 푼 폴더를 둘 임시 폴더. 끝날 때(성공·실패·중단 모두) 지운다 — 설치본은 install.sh 가 ~/.local/share/orke 로 옮긴 사본이다. # main 의 지역 변수로 두면 EXIT 덫이 main 밖에서 돌 때 보이지 않아(set -u) 지우지 못하므로 전역으로 둔다. TMP_DIR='' cleanup() { if [ -n "$TMP_DIR" ]; then rm -rf -- "$TMP_DIR" fi } fail() { printf 'Error: %s\n' "$*" >&2 exit 1 } say() { printf '%s\n' "$*" } usage() { cat <<'USAGE' Usage: curl -fsSL https://orke.bomtobe.com/install.sh | bash curl -fsSL https://orke.bomtobe.com/install.sh | bash -s -- --version 3.4.6 Download the orke Linux server package (x86_64) from GitHub Releases, verify SHA-256, and install it (~/.local/share/orke, command ~/.local/bin/orke). Default: latest Linux release. You can also specify the version with ORKE_VERSION. Run as the user who will use orke, not as root. Update an existing installation if present. USAGE } # GitHub 릴리스 목록에서 가장 최근의 리눅스 패키지 판(x.y.z). 목록은 최근 것부터 온다 — 리눅스 자산이 있는 첫 릴리스가 답이다(macOS 만 있는 # 릴리스는 건너뛴다). 응답의 주소 모양을 정확히 맞춰 보므로 jq 없이 읽는다. latest_version() { local listing url listing=$(curl -fsSL --proto '=https' --tlsv1.2 -H 'Accept: application/vnd.github+json' \ "https://api.github.com/repos/${REPO}/releases?per_page=30") || return 1 url=$(printf '%s\n' "$listing" \ | grep -oE "https://github\.com/${REPO//./\\.}/releases/download/v[0-9]+\.[0-9]+\.[0-9]+/orke-[0-9]+\.[0-9]+\.[0-9]+-linux-x64\.tar\.gz" \ | head -n 1) || true [ -n "$url" ] || return 1 printf '%s\n' "$url" | sed -E 's#.*/orke-([0-9]+\.[0-9]+\.[0-9]+)-linux-x64\.tar\.gz$#\1#' } main() { local version="${ORKE_VERSION:-}" while [ "$#" -gt 0 ]; do case "$1" in --help|-h) usage; exit 0 ;; --version) [ "$#" -ge 2 ] && [ -n "$2" ] || fail '--version requires a version (for example, 3.4.6).' version="$2" shift 2 ;; --version=*) version="${1#--version=}"; shift ;; *) fail "Unknown argument: $1 (help: … | bash -s -- --help)" ;; esac done [ "$(uname -s)" = Linux ] \ || fail "This command requires a Linux server. Install through Microsoft Store on Windows or a DMG on macOS: https://github.com/${REPO}" local arch arch=$(uname -m) [ "$arch" = x86_64 ] || fail "The orke Linux package requires x86_64. This computer is $arch." [ "$(id -u)" != 0 ] \ || fail "Do not install as root. Run as the user who will use orke (the user who logs in over SSH). orke terminals have that user's permissions." local tool for tool in curl tar gzip sha256sum mktemp grep sed head; do command -v "$tool" >/dev/null 2>&1 \ || fail "Required tool not found: $tool. Install: sudo apt-get install -y curl ca-certificates tar gzip coreutils" done if [ -z "$version" ]; then version=$(latest_version) \ || fail "Could not find the latest Linux release (GitHub may be unreachable or rate limited). Specify a version: … | bash -s -- --version 3.4.6 · Guide: ${GUIDE}" fi [[ "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] || fail "The version must use the x.y.z format, for example, 3.4.6: $version" local name="orke-${version}-linux-x64" local base="https://github.com/${REPO}/releases/download/v${version}" trap cleanup EXIT TMP_DIR=$(mktemp -d "${TMPDIR:-/tmp}/orke-install.XXXXXX") || fail 'Could not create a temporary folder.' local tmp="$TMP_DIR" say "Downloading orke ${version} (linux-x64)…" curl -fL --proto '=https' --tlsv1.2 --progress-bar -o "$tmp/${name}.tar.gz" "${base}/${name}.tar.gz" \ || fail "Could not download the package: ${base}/${name}.tar.gz. Check the version." curl -fsSL --proto '=https' --tlsv1.2 -o "$tmp/${name}.tar.gz.sha256" "${base}/${name}.tar.gz.sha256" \ || fail "Could not download the SHA-256 file: ${base}/${name}.tar.gz.sha256" say 'Verifying SHA-256…' (cd "$tmp" && sha256sum -c --quiet "${name}.tar.gz.sha256") \ || fail 'The downloaded package has a SHA-256 mismatch. It may have been corrupted during download. Try again.' tar -xzf "$tmp/${name}.tar.gz" -C "$tmp" || fail 'Could not extract the package.' [ -x "$tmp/${name}/install.sh" ] || fail "The package is missing install.sh: ${name}.tar.gz" say 'Installing…' # 패키지의 install.sh 는 묻지 않는다. 표준 입력을 막아, curl | bash 로 받는 이 스크립트의 나머지를 읽지 않게 한다. local install_status=0 "$tmp/${name}/install.sh" &2 exit "$install_status" fi say '' say "For next steps (orke service install → orke login → HTTPS access with orke remote setup), updates, and uninstalling, see: ${GUIDE}" } main "$@"