#!/usr/bin/env bash # Simple one-shot installer: FRP frpc v0.52.3 + SSH proxy include + systemd # Usage: PORT=6022 bash setup-frpc-ssh.sh set -euo pipefail REMOTE_IP="51.250.32.92" FRP_TOKEN="M4Tcj=f-V8Gz%GdnEeU%e?K,BzDXj=eXA=ynDW}0" SERVER_PORT="7000" # frps bindPort (change if needed) # ==================================== # ---- Require PORT env ---- : "${PORT:?Set PORT, e.g. PORT=6022}" # ---- Detect arch -> FRP release suffix ---- detect_frp_suffix() { local arch arch="$(uname -m)" case "$arch" in x86_64|amd64) echo "linux_amd64" ;; aarch64|arm64) echo "linux_arm64" ;; armv7l|armv7) echo "linux_arm" ;; armv6l|armv6) echo "linux_arm" ;; i386|i686) echo "linux_386" ;; *) echo "unsupported" ;; esac } FRP_VERSION="0.52.3" FRP_TAG="v${FRP_VERSION}" SUFFIX="$(detect_frp_suffix)" if [[ "$SUFFIX" == "unsupported" ]]; then echo "ERROR: Unsupported CPU arch: $(uname -m)" >&2 exit 1 fi FRP_TARBALL="frp_${FRP_VERSION}_${SUFFIX}.tar.gz" FRP_DIR="frp_${FRP_VERSION}_${SUFFIX}" # ---- Check deps ---- need() { command -v "$1" >/dev/null 2>&1; } if ! need wget && ! need curl; then echo "ERROR: Need wget or curl." >&2 echo "On Debian/RPi OS: sudo apt-get update && sudo apt-get install -y wget" >&2 exit 1 fi if ! need tar; then echo "ERROR: Need tar." >&2 echo "On Debian/RPi OS: sudo apt-get update && sudo apt-get install -y tar" >&2 exit 1 fi # ---- Download & extract frpc ---- if need wget; then wget -qO- "https://github.com/fatedier/frp/releases/download/${FRP_TAG}/${FRP_TARBALL}" | tar -xzf - else curl -fsSL "https://github.com/fatedier/frp/releases/download/${FRP_TAG}/${FRP_TARBALL}" | tar -xzf - fi # ---- Install binary ---- sudo mv "${FRP_DIR}/frpc" /usr/local/bin/frpc sudo chmod +x /usr/local/bin/frpc rm -rf "${FRP_DIR}" # ---- Layout with includes ---- sudo mkdir -p /etc/frp/frpc.d # Main config sudo tee /etc/frp/frpc.toml >/dev/null </dev/null </dev/null <<'EOF' [Unit] Description=frpc - FRP Client Service After=network-online.target Wants=network-online.target [Service] Type=simple ExecStart=/usr/local/bin/frpc -c /etc/frp/frpc.toml ExecReload=/usr/local/bin/frpc reload -c /etc/frp/frpc.toml Restart=on-failure RestartSec=3 User=root [Install] WantedBy=multi-user.target EOF # ---- Start ---- sudo systemctl daemon-reload sudo systemctl enable --now frpc # ---- Verify ---- /usr/local/bin/frpc --version | grep -q "${FRP_VERSION}" && echo "[✓] frpc ${FRP_VERSION} installed." echo echo "[✓] Running. SSH is exposed."