#!/bin/bash # initial the system PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin export PATH # step 0: prepare nml_user_name=${1} nml_user_home=${2} ss_user_name=${3} new_port=${4} test_or_not=${5} SSHCONF="/etc/ssh/sshd_config" # sshd配置文件位置 github_project="docker/compose" # 自动获取 docker compose 最新下载地址 tag=$(wget -qO- -t1 -T2 "https://api.github.com/repos/${github_project}/releases/latest" | grep "tag_name" | head -n 1 | awk -F ":" '{print $2}' | sed 's/\"//g;s/,//g;s/ //g') # step 1: install echo "net.core.default_qdisc=fq" >> /etc/sysctl.conf #修改系统变量 echo "net.ipv4.tcp_congestion_control=bbr" >> /etc/sysctl.conf #修改系统变量 sysctl -p #保存生效 sysctl net.ipv4.tcp_available_congestion_control #执行 apt update apt -y install sudo wget curl unzip ufw screen vim git python3-pip curl -fsSL https://get.docker.com | bash -s docker >${PWD}/step1 2>&1 curl -L https://github.com/docker/compose/releases/download/${tag}/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose && chmod +x /usr/local/bin/docker-compose echo "step 1: install has finished" # step 2: localize useradd -d /home/${nml_user_home} -m ${nml_user_name} usermod -s /bin/bash ${nml_user_name} usermod -aG sudo ${nml_user_name} # 有些发行版 RN 的就没有sudo adm usermod -aG adm ${nml_user_name} usermod -aG docker ${nml_user_name} echo `groups ${nml_user_name}` # 修改ssh端口和禁止root登陆 cp ${SSHCONF} ${SSHCONF}.bak sed -i "s/Port 22/Port ${new_port}/g" "${SSHCONF}" sed -i 's/PermitRootLogin yes/PermitRootLogin no/g' "${SSHCONF}" timedatectl set-timezone Asia/Shanghai echo `date` echo "step 2: localize has finished" # step 3: monitor bash <(wget --no-check-certificate -qO- 'https://git.ahfei.blog/ahfei/Rust_ServerStatus/raw/branch/main/one-touch.sh') x86_64 "/home/${nml_user_home}/myserve/serverstatus" "A23456.." "ahfei-${ss_user_name}" "http://serverstatus.ahfei.blog:8080/report" ${nml_user_name} echo "step 3: monitor has finished" # 判断是否进行测试 if [[ -z ${test_or_not} ]]; then exit 1 fi # step 4: test cpu net etc echo 1 | bash <(wget -qO- --no-check-certificate https://github.com/spiritLHLS/ecs/raw/main/ecs.sh) wget https://cdn.geekbench.com/Geekbench-5.4.5-Linux.tar.gz && \ tar -xzvf Geekbench-*.tar.gz && rm Geekbench-*.tar.gz && \ mv Geek*/* ./ && rmdir Geekbench-* && \ echo "now geekbench5!" ./geekbench5 > result_geekbench5.txt docker run -d -e MODE=standalone -p 88:80 -it adolfintel/speedtest echo "`ip a | grep brd | grep inet | head -n 1 | awk '{print$2}' | sed 's/\/.*//g'`:88" >> result_geekbench5.txt echo "step 4: test has finished"