#!/bin/sh # Self-contained, per-user bootstrap. No sudo, package managers, or system Python/Tor. set -eu umask 077 rdzv_main() { VERSION='0.2.25' RELEASE_ORIGIN='https://join.rdzv.sh' MODE='join' case "${1-}" in host|join|install) MODE=$1; shift ;; esac case "$MODE" in host|join|install) ;; *) printf '%s\n' 'Invalid mode' >&2; return 1 ;; esac SYSTEM=$(uname -s) case "$SYSTEM" in Linux|Darwin) ;; *) printf '%s\n' 'Supported systems: Linux and macOS. No system changes were made.' >&2; return 1 ;; esac case "$(uname -m)" in x86_64) PLATFORM=x86_64 ;; aarch64|arm64) # A 64-bit ARM kernel can run a 32-bit hard-float userland. if [ "$SYSTEM" = Linux ] && [ "$(getconf LONG_BIT 2>/dev/null || true)" = 32 ]; then PLATFORM=armv7l; else PLATFORM=aarch64; fi ;; armv7l|armv8l) PLATFORM=armv7l ;; *) printf '%s\n' 'This portable release supports Linux x86_64, aarch64, and armv7l. No system changes were made.' >&2; return 1 ;; esac if [ "$SYSTEM" = Darwin ]; then case "$PLATFORM" in aarch64) PLATFORM=macos-$PLATFORM ;; *) printf '%s\n' 'This macOS preview requires an Apple Silicon Mac and a native ARM64 terminal (not Rosetta).' >&2; return 1 ;; esac fi case "$PLATFORM" in x86_64) RELEASE_SHA256='6c40bd93a321c94ebb288734d6c46f203245f70aabcb4c58ebce472435c2f0fc' RELEASE_PARTS='rendezvous-0.2.25-linux-x86_64.tar.gz.part00 rendezvous-0.2.25-linux-x86_64.tar.gz.part01 rendezvous-0.2.25-linux-x86_64.tar.gz.part02' ;; aarch64) RELEASE_SHA256='57850ed0e0d79965ec72dd031d34cb1a8c6162dd0b1d2f6d1944949840374f71' RELEASE_PARTS='rendezvous-0.2.25-linux-aarch64.tar.gz.part00 rendezvous-0.2.25-linux-aarch64.tar.gz.part01 rendezvous-0.2.25-linux-aarch64.tar.gz.part02' ;; armv7l) RELEASE_SHA256='31441252ee015378c7b2d287515e345e3a9930a771c0c200e217a708be303690' RELEASE_PARTS='rendezvous-0.2.25-linux-armv7l.tar.gz.part00 rendezvous-0.2.25-linux-armv7l.tar.gz.part01 rendezvous-0.2.25-linux-armv7l.tar.gz.part02' ;; macos-aarch64) RELEASE_SHA256='32146b5827e07fa4e0507a9d7518048daa3c966bb4d0d1f0674aa10838f5a06c' RELEASE_PARTS='rendezvous-0.2.25-macos-aarch64.tar.gz.part00 rendezvous-0.2.25-macos-aarch64.tar.gz.part01 rendezvous-0.2.25-macos-aarch64.tar.gz.part02' ;; *) printf '%s\n' 'No release is available for this platform.' >&2; return 1 ;; esac if [ "$SYSTEM" = Linux ]; then GLIBC=$(getconf GNU_LIBC_VERSION 2>/dev/null || true) case "$GLIBC" in 'glibc '*) GLIBC=${GLIBC#glibc } ;; *) printf '%s\n' 'This release needs glibc 2.34+ (not Alpine/musl).' >&2; return 1 ;; esac MAJOR=${GLIBC%%.*}; MINOR=${GLIBC#*.}; MINOR=${MINOR%%.*} case "$MAJOR:$MINOR" in *[!0-9:]*|:|*:) printf '%s\n' 'Could not determine glibc version.' >&2; return 1 ;; esac if [ "$MAJOR" -lt 2 ] || { [ "$MAJOR" -eq 2 ] && [ "$MINOR" -lt 34 ]; }; then printf '%s\n' 'This release requires glibc 2.34+ (Ubuntu 22.04+, Debian 12+, Amazon Linux 2023).' >&2 return 1 fi fi for tool in curl tar mktemp; do command -v "$tool" >/dev/null 2>&1 || { printf 'Required base utility missing: %s\n' "$tool" >&2; return 1; } done if command -v sha256sum >/dev/null 2>&1; then CHECKSUM=sha256sum elif command -v shasum >/dev/null 2>&1; then CHECKSUM=shasum else printf '%s\n' 'Required SHA-256 utility missing (sha256sum or shasum).' >&2; return 1 fi : "${HOME:?HOME must be set}" ROOT="$HOME/.local/share/rendezvous" BIN="$HOME/.local/bin" if [ -L "$ROOT" ]; then printf '%s\n' 'Refusing symlinked installation root.' >&2; return 1; fi mkdir -p "$ROOT" "$BIN" chmod 700 "$ROOT" WORK=$(mktemp -d "$ROOT/.install.XXXXXXXX") PENDING_ENV='' trap 'rm -rf -- "$WORK"; if [ -n "$PENDING_ENV" ]; then rm -rf -- "$PENDING_ENV"; fi' EXIT trap 'exit 130' INT trap 'exit 143' TERM HUP TARGET="$ROOT/$VERSION-$PLATFORM" if [ ! -f "$TARGET/.complete" ] || [ "$(cat "$TARGET/.complete" 2>/dev/null)" != "$RELEASE_SHA256" ]; then if [ -t 2 ] && [ "${NO_COLOR+x}" != x ] && [ "${TERM-}" != dumb ]; then printf '\033[90mDownloading Rendezvous %s…\033[0m\n' "$VERSION" >&2 else printf 'Downloading Rendezvous %s…\n' "$VERSION" >&2 fi : > "$WORK/release.tar.gz" for part in $RELEASE_PARTS; do curl --proto '=https' --tlsv1.2 -fsSL --retry 3 --connect-timeout 20 --max-time 300 \ "$RELEASE_ORIGIN/releases/$VERSION/$part" -o "$WORK/part" cat "$WORK/part" >> "$WORK/release.tar.gz" done printf '%s %s\n' "$RELEASE_SHA256" "$WORK/release.tar.gz" > "$WORK/checksum" if [ "$CHECKSUM" = shasum ]; then shasum -a 256 -c "$WORK/checksum" >/dev/null || { printf '%s\n' 'Release checksum mismatch; nothing installed.' >&2; return 1; } elif ! sha256sum -c "$WORK/checksum" >/dev/null; then printf '%s\n' 'Release checksum mismatch; nothing installed.' >&2 return 1 fi tar -tzf "$WORK/release.tar.gz" > "$WORK/members" while IFS= read -r member; do case "/$member/" in *'/../'*|*'/./'*) printf '%s\n' 'Unsafe release path.' >&2; return 1 ;; esac case "$member" in app|app/*|bin|bin/*|python|python/*|tor|tor/*|licenses|licenses/*|BUILD.json) ;; *) printf '%s\n' 'Unexpected release contents.' >&2; return 1 ;; esac done < "$WORK/members" ENV_DIR=$(mktemp -d "$ROOT/runtime-$VERSION.XXXXXXXX") PENDING_ENV=$ENV_DIR # Only the exact hash-pinned publisher archive is extracted, never unverified input. tar -xzf "$WORK/release.tar.gz" --no-same-owner --no-same-permissions -C "$ENV_DIR" "$ENV_DIR/bin/rdzv" --version >/dev/null "$ENV_DIR/bin/tor" --version >/dev/null mkdir -p "$TARGET" printf '%s\n' "$ENV_DIR" > "$WORK/environment" mv "$WORK/environment" "$TARGET/environment" printf '%s\n' "$RELEASE_SHA256" > "$WORK/complete" mv "$WORK/complete" "$TARGET/.complete" PENDING_ENV='' fi ENV_DIR=$(cat "$TARGET/environment") case "$ENV_DIR" in "$ROOT"/runtime-*) ;; *) printf '%s\n' 'Invalid local runtime path.' >&2; return 1 ;; esac cat > "$WORK/rdzv" </dev/null || printf '%s\n' 'Old runtime cleanup deferred; the new installation is ready.' >&2 rm -rf -- "$WORK" trap - EXIT INT TERM HUP [ "$MODE" != install ] || return 0 if [ "$MODE" = join ]; then HAS_INVITATION=0; HAS_COMMAND=0; SKIP_VALUE=0; HELP=0; AGENT=0 for arg in "$@"; do if [ "$SKIP_VALUE" = 1 ]; then SKIP_VALUE=0; continue; fi case "$arg" in --invitation|--invitation-file) HAS_INVITATION=1; SKIP_VALUE=1 ;; --invitation=*|--invitation-file=*) HAS_INVITATION=1 ;; --command) HAS_COMMAND=1; SKIP_VALUE=1 ;; --command=*) HAS_COMMAND=1 ;; --session-timeout) SKIP_VALUE=1 ;; -a|--agent) AGENT=1 ;; --help|-h) HELP=1 ;; esac done if [ "$HELP" = 1 ]; then exec "$BIN/rdzv" "$MODE" "$@"; fi # The curl pipeline occupies stdin even when an invitation is supplied. # A prompted invitation or interactive shell needs the controlling terminal. if [ "$HAS_INVITATION" = 0 ] || { [ "$HAS_COMMAND" = 0 ] && [ "$AGENT" = 0 ]; }; then if ( : /dev/null; then exec "$BIN/rdzv" "$MODE" "$@" &2 return 1 fi # Never forward the piped installer text into a remote command. exec "$BIN/rdzv" "$MODE" "$@"