跳转到内容
主菜单
主菜单
移至侧栏
隐藏
导航
首页
最近更改
随机页面
分类入口
MediaWiki帮助
教程大纲
安装教程
配置教程
使用教程
知识库
出站链接
UbuntuStudioCN
搜索
搜索
中文(中国大陆)
外观
创建账号
登录
个人工具
创建账号
登录
查看“︁Test”︁的源代码
页面
讨论
大陆简体
阅读
查看源代码
查看历史
工具
工具
移至侧栏
隐藏
操作
阅读
查看源代码
查看历史
常规
链入页面
相关更改
特殊页面
页面信息
外观
移至侧栏
隐藏
←
Test
因为以下原因,您没有权限编辑该页面:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
快速安装脚本 == 安装内容 == <pre> #!/bin/bash get_latest_release_tag() { curl -s "https://api.github.com/repos/fatedier/frp/releases/latest" | grep -Po '"tag_name": "\K[^"]*' } # Function to detect architecture detect_arch() { ARCH=$(uname -m) case "$ARCH" in x86_64) echo "amd64" ;; aarch64) echo "arm64" ;; armv7l) echo "arm" ;; *) echo "unsupported" ;; esac } # Main script main() { LATEST_TAG=$(get_latest_release_tag) if [ -z "$LATEST_TAG" ]; then echo "Error: Could not fetch the latest release tag." exit 1 fi echo "Latest FRP release: $LATEST_TAG" DETECTED_ARCH=$(detect_arch) if [ "$DETECTED_ARCH" == "unsupported" ]; then echo "Error: Your architecture ($ARCH) is not directly supported by this script for FRP downloads." echo "Please manually download from https://github.com/fatedier/frp/releases" exit 1 fi echo "Detected architecture: $DETECTED_ARCH" FILENAME="frp_${LATEST_TAG#v}_linux_${DETECTED_ARCH}.tar.gz" DOWNLOAD_URL="https://github.com/fatedier/frp/releases/download/${LATEST_TAG}/${FILENAME}" echo "Attempting to download: $DOWNLOAD_URL" # Use curl to download the file curl -L -o "$FILENAME" "$DOWNLOAD_URL" if [ $? -eq 0 ]; then echo "Download complete: $FILENAME" echo "You can now extract it using: tar -xzf $FILENAME" else echo "Error: Download failed." echo "Please check the URL or your network connection." fi } # Define variables SERVICE_NAME="frps" SERVICE_FILE="/etc/systemd/system/${SERVICE_NAME}.service" FRPS_DIR="$HOME/Workspace/frp" # Recommended directory for frp binaries and config mkdir -p ~/Workspace cd ~/Workspace main mv ${FILENAME%.tar.gz} frp # Check if the frps directory exists, if not, create it if [ ! -d "$FRPS_DIR" ]; then echo "Creating directory: $FRPS_DIR" sudo mkdir -p "$FRPS_DIR" sudo chown $USER:$USER "$FRPS_DIR" # Give ownership to the current user for easy management fi # Get the current working directory of the script SCRIPT_DIR=$(pwd) # Check if frps binary exists in the current directory if [ ! -f "$SCRIPT_DIR/frps" ]; then echo "Error: 'frps' binary not found in the current directory ($SCRIPT_DIR)." echo "Please ensure the frp archive has been extracted and 'frps' is present." exit 1 fi # Check if frps.toml configuration file exists in the current directory if [ ! -f "$SCRIPT_DIR/frps.toml" ]; then echo "Error: 'frps.toml' configuration file not found in the current directory ($SCRIPT_DIR)." echo "Please ensure 'frps.toml' is present." exit 1 fi # Copy frps binary and frps.toml to the designated directory echo "Copying frps binary and frps.toml to $FRPS_DIR..." sudo cp "$SCRIPT_DIR/frps" "$FRPS_DIR/" sudo cp "$SCRIPT_DIR/frps.toml" "$FRPS_DIR/" # Create the systemd service file echo "Creating systemd service file: $SERVICE_FILE" sudo bash -c "cat << EOF > $SERVICE_FILE [Unit] Description = frp server After = network.target syslog.target Wants = network.target [Service] Type = simple User = $USER ExecStart = $FRPS_DIR/frps -c $FRPS_DIR/frps.toml Restart = on-failure RestartSec = 5s [Install] WantedBy = multi-user.target EOF" # Reload systemd daemon, enable and start the service echo "Reloading systemd daemon..." sudo systemctl daemon-reload echo "Enabling $SERVICE_NAME service to start on boot..." sudo systemctl enable "$SERVICE_NAME" echo "Starting $SERVICE_NAME service..." sudo systemctl start "$SERVICE_NAME" echo "Service creation complete. You can check its status with: sudo systemctl status $SERVICE_NAME" echo "Remember to configure your frps.toml file properly." # Define the output file TOML_FILE="frps.toml" # Function to generate a random token generate_token() { # Generate a random string of 32 alphanumeric characters head /dev/urandom | tr -dc A-Za-z0-9_.- | head -c 32 } # Generate the token GENERATED_TOKEN=$(generate_token) # Create the frps.toml content cat << EOF > "$TOML_FILE" # frps.toml - FRP Server Configuration # Basic server settings bindAddr = "0.0.0.0" bindPort =12048 kcpBindPort = 12048 # Authentication settings auth.method = "token" auth.token = "$GENERATED_TOKEN" # Logging settings log.to = "./frps.log" # trace, debug, info, warn, error log.level = "info" log.maxDays = 7 EOF echo "Generated '$TOML_FILE' with a new authentication token." echo "Authentication Token: $GENERATED_TOKEN" echo "Please keep this token secure and use it in your frpc.toml client configuration." </pre>
返回
Test
。