2023-01-12 23:55:52 +08:00
|
|
|
#!/bin/bash
|
|
|
|
# initial the system
|
|
|
|
|
|
|
|
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
|
|
|
|
export PATH
|
|
|
|
|
2023-01-13 00:42:53 +08:00
|
|
|
# step 0: prepare
|
2023-01-14 01:04:04 +08:00
|
|
|
nml_user_name=${1}
|
|
|
|
nml_user_home=${2}
|
|
|
|
ss_user_name=${3}
|
2023-01-16 02:22:47 +08:00
|
|
|
new_port=${4}
|
2023-10-18 23:25:25 +08:00
|
|
|
password=${5}
|
|
|
|
test_or_not=${6}
|
2023-01-13 00:42:53 +08:00
|
|
|
|
2023-01-16 02:22:47 +08:00
|
|
|
SSHCONF="/etc/ssh/sshd_config" # sshd配置文件位置
|
|
|
|
|
2023-01-13 00:42:53 +08:00
|
|
|
|
2023-01-12 23:55:52 +08:00
|
|
|
# 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 #执行
|
|
|
|
|
2023-10-18 23:25:25 +08:00
|
|
|
apt-get update
|
|
|
|
apt-get install -y sudo curl vim git
|
2023-08-15 00:00:20 +08:00
|
|
|
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
|
2023-01-12 23:55:52 +08:00
|
|
|
echo "step 1: install has finished"
|
|
|
|
|
|
|
|
|
|
|
|
# step 2: localize
|
2023-10-18 23:25:25 +08:00
|
|
|
useradd -md /home/${nml_user_home} -s /bin/bash ${nml_user_name}
|
2023-01-14 01:04:04 +08:00
|
|
|
usermod -aG sudo ${nml_user_name} # 有些发行版 RN 的就没有sudo adm
|
|
|
|
usermod -aG adm ${nml_user_name}
|
|
|
|
usermod -aG docker ${nml_user_name}
|
2023-10-18 23:25:25 +08:00
|
|
|
# set password
|
2023-10-24 17:28:42 +08:00
|
|
|
echo "${nml_user_name}:${password}" | chpasswd
|
2023-01-12 23:55:52 +08:00
|
|
|
|
2023-01-16 02:22:47 +08:00
|
|
|
# 修改ssh端口和禁止root登陆
|
2023-11-21 00:30:21 +08:00
|
|
|
# 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
|
2023-01-16 02:22:47 +08:00
|
|
|
|
2023-01-12 23:55:52 +08:00
|
|
|
timedatectl set-timezone Asia/Shanghai
|
|
|
|
echo `date`
|
|
|
|
|
|
|
|
echo "step 2: localize has finished"
|
|
|
|
|
|
|
|
|
|
|
|
# step 3: monitor
|
2023-08-18 01:21:50 +08:00
|
|
|
if [[ ${nml_user_name} == 'SkF%16_6' ]]; then
|
|
|
|
ssrust_user_name="1000"
|
|
|
|
else
|
|
|
|
ssrust_user_name=${nml_user_name}
|
|
|
|
fi
|
2023-12-15 21:45:11 +08:00
|
|
|
curl -sL https://git.ahfei.blog/ahfei/Rust_ServerStatus/raw/branch/main/one-touch.sh | sudo bash -s "http://serverstatus.ahfei.blog:8080/report" "/home/${nml_user_home}/myserve/serverstatus" ${ssrust_user_name} "ahfei-${ss_user_name}" "A23456.."
|
2023-07-16 23:24:05 +08:00
|
|
|
chown -R ${nml_user_name}:${nml_user_name} /home/${nml_user_home}/myserve
|
2023-01-12 23:55:52 +08:00
|
|
|
|
|
|
|
echo "step 3: monitor has finished"
|
|
|
|
|
|
|
|
|
2023-01-16 02:22:47 +08:00
|
|
|
# 判断是否进行测试
|
|
|
|
if [[ -z ${test_or_not} ]]; then
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
2023-01-12 23:55:52 +08:00
|
|
|
# step 4: test cpu net etc
|
2023-06-26 21:16:14 +08:00
|
|
|
echo 1 | bash <(wget -qO- --no-check-certificate https://github.com/spiritLHLS/ecs/raw/main/ecs.sh)
|
|
|
|
|
2023-08-08 14:55:45 +08:00
|
|
|
|
2023-10-05 18:20:08 +08:00
|
|
|
docker run -d -e MODE=standalone -p 80:80 -it --name speedtest adolfintel/speedtest:latest
|
2023-08-08 14:55:45 +08:00
|
|
|
|
|
|
|
bash <(wget -qO- https://raw.githubusercontent.com/i-abc/GB5/main/gb5-test.sh)
|
|
|
|
|
2023-10-11 18:49:01 +08:00
|
|
|
echo "`ip a | grep brd | grep inet | head -n 1 | awk '{print$2}' | sed 's/\/.*//g'`:80"
|
2023-01-12 23:55:52 +08:00
|
|
|
|
2023-01-13 00:56:34 +08:00
|
|
|
echo "step 4: test has finished"
|