更灵活

1. 改善获取ip方法
2. 自动修改ssh端口和禁止root登陆
3. 可以选择不测试
main
AhFei 2023-01-16 02:22:47 +08:00
parent 546a7ae11a
commit bb729d730d
1 changed files with 17 additions and 2 deletions

View File

@ -8,8 +8,12 @@ export PATH
nml_user_name=${1} nml_user_name=${1}
nml_user_home=${2} nml_user_home=${2}
ss_user_name=${3} ss_user_name=${3}
new_port=${4}
test_or_not=${5}
github_project="docker/compose" 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') 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')
@ -34,6 +38,11 @@ usermod -aG adm ${nml_user_name}
usermod -aG docker ${nml_user_name} usermod -aG docker ${nml_user_name}
echo `groups ${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 timedatectl set-timezone Asia/Shanghai
echo `date` echo `date`
@ -53,6 +62,12 @@ chmod 600 /var/spool/cron/crontabs/${nml_user_name}
echo "step 3: monitor has finished" echo "step 3: monitor has finished"
# 判断是否进行测试
if [[ -z ${test_or_not} ]]; then
exit 1
fi
# step 4: test cpu net etc # step 4: test cpu net etc
wget https://cdn.geekbench.com/Geekbench-5.4.5-Linux.tar.gz && \ wget https://cdn.geekbench.com/Geekbench-5.4.5-Linux.tar.gz && \
tar -xzvf Geekbench-*.tar.gz && rm Geekbench-*.tar.gz && \ tar -xzvf Geekbench-*.tar.gz && rm Geekbench-*.tar.gz && \
@ -61,6 +76,6 @@ echo "now geekbench5!"
./geekbench5 > result_geekbench5.txt ./geekbench5 > result_geekbench5.txt
docker run -d -e MODE=standalone -p 88:80 -it adolfintel/speedtest docker run -d -e MODE=standalone -p 88:80 -it adolfintel/speedtest
echo "`ip a | head -n13 | grep /24 | awk '{print$2}' | sed 's/\/24//g'`:88" >> result_geekbench5.txt 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" echo "step 4: test has finished"