#!/usr/bin/env sh # ntcp installer for Linux and macOS. # # Usage (one-liner via 3kr.org short URL): # curl -fsSL 3kr.org/install | sudo sh # # Direct (raw GitHub): # curl -fsSL https://raw.githubusercontent.com/muslu/nettransfer/main/install.sh | sudo sh # # Override the binary URL via: # NTCP_BIN_URL=https://example.com/ntcp-linux-amd64 sudo sh install.sh set -eu # ANSI colors — store the ESC character literally (not the '\033' string) # so that downstream `%s`/echo prints render them as escape codes. # Disabled when stderr is not a tty (piped to a log, etc.). if [ -t 2 ] && [ -z "${NO_COLOR:-}" ]; then ESC=$(printf '\033') C_RESET="${ESC}[0m"; C_BOLD="${ESC}[1m"; C_DIM="${ESC}[2m" C_RED="${ESC}[31m"; C_GREEN="${ESC}[32m"; C_YELLOW="${ESC}[33m" C_BLUE="${ESC}[34m"; C_CYAN="${ESC}[36m"; C_BCYAN="${ESC}[96m" else C_RESET=''; C_BOLD=''; C_DIM=''; C_RED=''; C_GREEN='' C_YELLOW=''; C_BLUE=''; C_CYAN=''; C_BCYAN='' fi printf '%s\n' "$C_BCYAN" cat <<'EOF' ███╗ ██╗████████╗ ██████╗██████╗ ████╗ ██║╚══██╔══╝██╔════╝██╔══██╗ ██╔██╗ ██║ ██║ ██║ ██████╔╝ ██║╚██╗██║ ██║ ██║ ██╔═══╝ ██║ ╚████║ ██║ ╚██████╗██║ ╚═╝ ╚═══╝ ╚═╝ ╚═════╝╚═╝ EOF printf '%s%s secure resumable file transfer%s\n\n' "$C_RESET" "$C_DIM" "$C_RESET" step() { printf ' %s→%s %s\n' "$C_CYAN" "$C_RESET" "$1"; } okmsg() { printf ' %s✓%s %s\n' "$C_GREEN" "$C_RESET" "$1"; } warn() { printf ' %s!%s %s\n' "$C_YELLOW" "$C_RESET" "$1"; } errfail() { printf ' %s✗%s %s\n' "$C_RED" "$C_RESET" "$1"; exit 1; } if [ "$(id -u)" != "0" ]; then errfail "ntcp installer must run as root (use sudo)." fi OS="$(uname -s | tr '[:upper:]' '[:lower:]')" ARCH="$(uname -m)" case "$ARCH" in x86_64|amd64) ARCH=amd64 ;; aarch64|arm64) ARCH=arm64 ;; *) errfail "unsupported architecture: $ARCH" ;; esac case "$OS" in linux|darwin) ;; *) errfail "this installer supports linux and macOS only; use install.ps1 on Windows" ;; esac step "detected ${C_BOLD}${OS}/${ARCH}${C_RESET}" # GitHub Releases host the per-platform binaries. CI publishes them on every # `v*` tag. The `latest/download/` path always resolves to the most recent. BASE_URL="${NTCP_BASE_URL:-https://github.com/muslu/nettransfer/releases/latest/download}" BIN_URL="${NTCP_BIN_URL:-${BASE_URL}/ntcp-${OS}-${ARCH}}" DEST="/usr/local/bin/ntcp" TMP="$(mktemp -d)" trap 'rm -rf "$TMP"' EXIT step "downloading ${C_DIM}${BIN_URL}${C_RESET}" if command -v curl >/dev/null 2>&1; then curl -#fSL --proto '=https' --tlsv1.2 -o "$TMP/ntcp" "$BIN_URL" elif command -v wget >/dev/null 2>&1; then wget --https-only --show-progress -q -O "$TMP/ntcp" "$BIN_URL" else errfail "need curl or wget to download" fi chmod +x "$TMP/ntcp" mv "$TMP/ntcp" "$DEST" okmsg "installed binary at ${C_BOLD}${DEST}${C_RESET}" step "registering service and generating first token" "$DEST" install printf '\n' printf ' %s┌─ Token modu seçimi%s\n' "$C_CYAN" "$C_RESET" printf ' %s│%s %ssudo ntcp init%s\n' "$C_CYAN" "$C_RESET" "$C_GREEN" "$C_RESET" printf ' %s│%s %s[1]%s Kalıcı — token süresiz geçerli\n' "$C_CYAN" "$C_RESET" "$C_BOLD" "$C_RESET" printf ' %s│%s %s[2]%s Süreli — TTL ile otomatik geçersiz (örn. 1h, 24h, 7d)\n' "$C_CYAN" "$C_RESET" "$C_BOLD" "$C_RESET" printf ' %s│%s\n' "$C_CYAN" "$C_RESET" printf ' %s│%s %snot:%s atlanırsa kurulumdaki token kalıcı olarak saklanır.\n' "$C_CYAN" "$C_RESET" "$C_DIM" "$C_RESET" printf ' %s└─%s\n' "$C_CYAN" "$C_RESET" printf '\n' printf ' %sℹ%s Daha fazla bilgi: %shttps://github.com/muslu/nettransfer%s\n\n' "$C_BLUE" "$C_RESET" "$C_DIM" "$C_RESET"