#!/bin/bash # This script automatically downloads and installs the appropriate Netrinos client # for the current system architecture. It should be run with superuser privileges. # # Usage: # sudo ./install-client.sh [version] [cli] # # or directly from the shell with: # # curl -fsSL https://download.netrinos.com/linux/install-client.sh | sudo bash -s [version] [cli] # # Parameters: # version - latest (default), daily, beta, or specific version number # cli - optional flag to install CLI-only version (no GUI) # # Supports Debian/Ubuntu (.deb), CentOS/RHEL/Fedora (.rpm), and other Linux # distributions (.tgz fallback). # # Examples: # bash -s latest # Install latest UI version # bash -s daily cli # Install daily CLI-only version # bash -s cli # Install latest CLI-only version # Detect the system architecture detected_arch=$(uname -m) # Parse arguments - look for 'cli' flag anywhere in args or as suffix cli_mode=false version="latest" for arg in "$@"; do arg_lower=${arg,,} if [ "$arg_lower" = "cli" ]; then cli_mode=true elif [[ "$arg_lower" == *-cli ]]; then # Handle combined format like "daily-cli" cli_mode=true version="${arg_lower%-cli}" else version="$arg_lower" fi done # Define the base URL base_url="https://download.netrinos.com/linux" # If version = latest, set folder = latest case "$version" in beta) base_url="$base_url/beta" ;; daily) base_url="$base_url/daily" ;; latest) # latest is in main folder ;; *) base_url="$base_url/archive" ;; esac # Detect package manager if command -v dpkg &>/dev/null && command -v apt-get &>/dev/null; then pkg_type="deb" elif command -v rpm &>/dev/null && command -v dnf &>/dev/null; then pkg_type="rpm" elif command -v rpm &>/dev/null && command -v yum &>/dev/null; then pkg_type="rpm" else pkg_type="tgz" fi # Choose the appropriate architecture name (Go/Debian convention) case "$detected_arch" in x86_64) arch="amd64" ;; arm) arch="arm" ;; aarch64) arch="arm64" ;; armhf|armv6l|armv7l) arch="armhf" ;; *) echo "Unsupported architecture: $detected_arch" exit 1 ;; esac # Define the filename based on cli_mode and package type case "$pkg_type" in deb) if [ "$cli_mode" = true ]; then filename="netrinos-cli-linux_${version}_${arch}.deb" echo "Installing CLI-only version (deb)..." else filename="netrinos-client-linux_${version}_${arch}.deb" echo "Installing client (deb)..." fi ;; rpm) if [ "$cli_mode" = true ]; then filename="netrinos-cli-linux_${version}_${arch}.rpm" echo "Installing CLI-only version (rpm)..." else filename="netrinos-client-linux_${version}_${arch}.rpm" echo "Installing client (rpm)..." fi ;; tgz) if [ "$cli_mode" = true ]; then echo "CLI-only .tgz packages are not available." exit 1 else filename="netrinos-client-linux_${version}_${arch}.tgz" echo "Installing client (tgz)..." fi ;; esac # Define the URL url="$base_url/$filename" echo "Using: $url" # Define the temporary file (with correct extension for dnf/rpm) case "$pkg_type" in deb) tmpfile=$(mktemp --suffix=.deb) ;; rpm) tmpfile=$(mktemp --suffix=.rpm) ;; *) tmpfile=$(mktemp --suffix=.tgz) ;; esac # Download the package wget -O "$tmpfile" "$url" # Install based on package type case "$pkg_type" in deb) sudo dpkg -i "$tmpfile" sudo apt-get install -f -y ;; rpm) # Use reinstall to handle upgrades/downgrades, fall back to install for fresh installs sudo dnf reinstall -y "$tmpfile" 2>/dev/null \ || sudo dnf install -y "$tmpfile" 2>/dev/null \ || sudo yum reinstall -y "$tmpfile" 2>/dev/null \ || sudo yum install -y "$tmpfile" ;; tgz) echo "Extracting to /usr/local/bin..." sudo tar -xzf "$tmpfile" -C /usr/local/bin ;; esac # Save the upgrade channel preference (include cli suffix if applicable) NETRINOS_BIN=$(command -v netrinos 2>/dev/null) if [ -n "$NETRINOS_BIN" ] && [ -x "$NETRINOS_BIN" ]; then if [ "$cli_mode" = true ]; then channel="${version}-cli" else channel="$version" fi echo "Setting upgrade channel to: $channel" "$NETRINOS_BIN" upgrade channel "$channel" >/dev/null 2>&1 || true fi # Tell the user how to start the GUI. XDG autostart handles future logins. # Launching a GUI from a root install script is unreliable (DISPLAY, DBUS, # XAUTHORITY vary by distro/session). Chrome, VS Code, etc. don't try. if [ "$cli_mode" = false ] && [ -x /usr/local/bin/netrinos-ui ]; then echo "Run 'netrinos-ui' to start the GUI, or launch Netrinos from the Applications menu." fi