#!/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} password=${5} test_or_not=${6} SSHCONF="/etc/ssh/sshd_config" # sshd配置文件位置 # 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-get update apt-get install -y sudo curl vim git for pkg in docker.io docker-doc docker-compose podman-docker containerd runc; do sudo apt-get remove $pkg; done curl -fsSL https://get.docker.com | bash echo "step 1: install has finished" # step 2: localize useradd -md /home/${nml_user_home} -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} # set password echo "${nml_user_name}:${password}" | chpasswd # 修改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}" cat > /etc/ssh/sshd_config.d/custom_sshd.conf << EOF Port ${new_port} PermitRootLogin yes EOF timedatectl set-timezone Asia/Shanghai echo `date` echo "step 2: localize has finished" # step 3: monitor if [[ ${nml_user_name} == 'SkF%16_6' ]]; then ssrust_user_name="1000" else ssrust_user_name=${nml_user_name} fi bash <(wget --no-check-certificate -qO- 'https://git.ahfei.blog/ahfei/Rust_ServerStatus/raw/branch/main/one-touch.sh') "/home/${nml_user_home}/myserve/serverstatus" "A23456.." "ahfei-${ss_user_name}" "http://serverstatus.ahfei.blog:8080/report" ${ssrust_user_name} chown -R ${nml_user_name}:${nml_user_name} /home/${nml_user_home}/myserve 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) docker run -d -e MODE=standalone -p 80:80 -it --name speedtest adolfintel/speedtest:latest bash <(wget -qO- https://raw.githubusercontent.com/i-abc/GB5/main/gb5-test.sh) echo "`ip a | grep brd | grep inet | head -n 1 | awk '{print$2}' | sed 's/\/.*//g'`:80" echo "step 4: test has finished"