#!/bin/bash # One-line bootstrap for OneLine VPN. # curl -fsSL https://onelinevpn.com/install | sudo bash set -euo pipefail set +x ONELINE_BASE_URL="${ONELINE_BASE_URL:-https://onelinevpn.com}" ONELINE_BASE_URL="${ONELINE_BASE_URL%/}" say() { printf '%s\n' "$*" >&2; } die() { say "$1" exit 1 } have_tty() { (exec 3>/dev/tty) >/dev/null 2>&1 } require_root() { if [[ "$(id -u)" -ne 0 ]]; then die "Run it as root: curl -fsSL https://onelinevpn.com/install | sudo bash" fi } require_ubuntu() { if [[ ! -f /etc/os-release ]]; then die "Need Ubuntu 22.04 or 24.04." fi # shellcheck disable=SC1091 . /etc/os-release if [[ "${ID:-}" != "ubuntu" || ( "${VERSION_ID:-}" != "22.04" && "${VERSION_ID:-}" != "24.04" ) ]]; then die "Need Ubuntu 22.04 or 24.04." fi } download_release() { local dest="$1" if ! curl -fsSL --retry 3 --retry-delay 2 -o "${dest}/familyvpn.tar.gz" "${ONELINE_BASE_URL}/familyvpn.tar.gz" < /dev/null; then die "Could not download the installer." fi if ! curl -fsSL --retry 3 --retry-delay 2 -o "${dest}/familyvpn.tar.gz.sha256" "${ONELINE_BASE_URL}/familyvpn.tar.gz.sha256" < /dev/null; then die "Could not download the checksum." fi } verify_release() { local dest="$1" if ! ( cd "$dest" && sha256sum -c --status familyvpn.tar.gz.sha256 ); then die "Checksum did not match. Refusing to install." fi } main() { local stage require_root require_ubuntu stage="$(mktemp -d /tmp/onelinevpn.XXXXXX)" download_release "$stage" verify_release "$stage" tar -xzf "${stage}/familyvpn.tar.gz" -C "$stage" if [[ ! -f "${stage}/family/install.sh" ]]; then die "Archive is missing family/install.sh." fi # The pipe that delivered this script is not a terminal. Give the real # installer the keyboard so token and Telegram ID prompts still work. if [[ ! -t 0 ]] && have_tty; then exec < /dev/tty fi local rc=0 bash "${stage}/family/install.sh" "$@" || rc=$? rm -rf "$stage" exit "$rc" } main "$@"