#!/bin/bash ###################################################### ### bash <(curl -fsSL https://raw.lhy.life/nezha-agent.sh) ###################################################### ## GetArgValue ## ./script key=value g_args=("$@") function GetArgValue() { local key="$1" local defvalue="$2" for arg in "${g_args[@]}" do if [[ "$arg" == "$key="* ]] then echo "${arg#*=}" return fi done echo "$defvalue" } mkdir -p /root/apps/nezha/agent && cd /root/apps/nezha/agent wget -O "nezha-agent_linux_amd64.zip" "https://github.com/nezhahq/agent/releases/latest/download/nezha-agent_linux_amd64.zip" unzip nezha-agent_linux_amd64.zip rm -rf nezha-agent_linux_amd64.zip chmod +x nezha-agent ./nezha-agent -h NZ_CLIENT_SECRET=$(GetArgValue NZ_CLIENT_SECRET "123") NZ_SERVER=$(GetArgValue NZ_SERVER "exp.com:443") NZ_UUID=$(cat /proc/sys/kernel/random/uuid) NZ_UUID=$(GetArgValue NZ_UUID $NZ_UUID) NZ_TLS=$(GetArgValue NZ_TLS "true") cat < config.yaml client_secret: $NZ_CLIENT_SECRET uuid: $NZ_UUID server: $NZ_SERVER tls: $NZ_TLS debug: false disable_auto_update: true disable_command_execute: true disable_force_update: true disable_nat: true disable_send_query: false gpu: false insecure_tls: false ip_report_period: 1800 report_delay: 3 self_update_period: 0 skip_connection_count: false skip_procs_count: false temperature: false use_gitee_to_upgrade: false use_ipv6_country_code: false EOF