From bb729d730d493fabe00e47defc6dbfda07a68930 Mon Sep 17 00:00:00 2001 From: AhFei Date: Mon, 16 Jan 2023 02:22:47 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E7=81=B5=E6=B4=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. 改善获取ip方法 2. 自动修改ssh端口和禁止root登陆 3. 可以选择不测试 --- initial.sh | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/initial.sh b/initial.sh index af3dff7..d517251 100644 --- a/initial.sh +++ b/initial.sh @@ -8,8 +8,12 @@ export PATH nml_user_name=${1} nml_user_home=${2} 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') @@ -34,6 +38,11 @@ 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` @@ -53,6 +62,12 @@ chmod 600 /var/spool/cron/crontabs/${nml_user_name} echo "step 3: monitor has finished" +# 判断是否进行测试 +if [[ -z ${test_or_not} ]]; then + exit 1 +fi + + # step 4: test cpu net etc wget https://cdn.geekbench.com/Geekbench-5.4.5-Linux.tar.gz && \ tar -xzvf Geekbench-*.tar.gz && rm Geekbench-*.tar.gz && \ @@ -61,6 +76,6 @@ echo "now geekbench5!" ./geekbench5 > result_geekbench5.txt 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" \ No newline at end of file