feat(脚本): 安装脚本优化EOF、测速脚本修改无法判断0的bug

pull/534/merge
mack-a 2020-08-04 16:56:55 +08:00
parent 77d56d4b83
commit 1c64176838
2 changed files with 49 additions and 45 deletions

View File

@ -99,7 +99,7 @@ init(){
echoContent green "请输入单个ip的测试次数【默认为5次】" echoContent green "请输入单个ip的测试次数【默认为5次】"
echoContent red "=============================================" echoContent red "============================================="
read testNum read testNum
if [[ "$testNum" =~ ^[1-9]+$ ]] if [[ "$testNum" =~ ^[0-9]+$ ]]
then then
num=${testNum} num=${testNum}
else else

View File

@ -333,32 +333,33 @@ reInstallTLS(){
# 备份 # 备份
domain=$1 domain=$1
echo "#!/usr/bin/env bash" >> /etc/nginx/v2ray-agent-https/reloadInstallTLS.sh cat << EOF > /etc/nginx/v2ray-agent-https/reloadInstallTLS.sh
echo "domain=${domain}" >> /etc/nginx/v2ray-agent-https/reloadInstallTLS.sh domain=$1
echo "eccPath=\`find ~/.acme.sh -name \"\${domain}_ecc\"|head -1\`" >> /etc/nginx/v2ray-agent-https/reloadInstallTLS.sh eccPath=\`find ~/.acme.sh -name "\${domain}_ecc"|head -1\`
echo "mkdir -p /etc/v2ray-agent/tls" >> /etc/nginx/v2ray-agent-https/reloadInstallTLS.sh mkdir -p /etc/v2ray-agent/tls
echo "touch /etc/v2ray-agent/tls/tls.log" >> /etc/nginx/v2ray-agent-https/reloadInstallTLS.sh touch /etc/v2ray-agent/tls/tls.log
echo "touch /etc/v2ray-agent/tls/acme.log" >> /etc/nginx/v2ray-agent-https/reloadInstallTLS.sh touch /etc/v2ray-agent/tls/acme.log
echo "if [[ ! -z \${eccPath} ]]" >> /etc/nginx/v2ray-agent-https/reloadInstallTLS.sh if [[ ! -z \${eccPath} ]]
echo "then" >> /etc/nginx/v2ray-agent-https/reloadInstallTLS.sh then
echo "modifyTime=\`stat \${eccPath}/\${domain}.key|sed -n '6,6p'|awk '{print \$2\" \"\$3\" \"\$4\" \"\$5}'\`" >> /etc/nginx/v2ray-agent-https/reloadInstallTLS.sh modifyTime=\`stat \${eccPath}/\${domain}.key|sed -n '6,6p'|awk '{print \$2" "\$3" "\$4" "\$5}'\`
echo "modifyTime=\`date +%s -d \"\${modifyTime}\"\`" >> /etc/nginx/v2ray-agent-https/reloadInstallTLS.sh modifyTime=\`date +%s -d "\${modifyTime}"\`
echo "currentTime=\`date +%s\`" >> /etc/nginx/v2ray-agent-https/reloadInstallTLS.sh currentTime=\`date +%s\`
echo "stampDiff=\`expr \${currentTime} - \${modifyTime}\`" >> /etc/nginx/v2ray-agent-https/reloadInstallTLS.sh stampDiff=\`expr \${currentTime} - \${modifyTime}\`
echo "minutes=\`expr \${stampDiff} / 60\`" >> /etc/nginx/v2ray-agent-https/reloadInstallTLS.sh minutes=\`expr \${stampDiff} / 60\`
echo "status=\"正常\"" >> /etc/nginx/v2ray-agent-https/reloadInstallTLS.sh status="正常"
echo "reloadTime=\"暂无\"" >> /etc/nginx/v2ray-agent-https/reloadInstallTLS.sh reloadTime="暂无"
echo "if [[ ! -z \${modifyTime} ]] && [[ ! -z \${currentTime} ]] && [[ ! -z \${stampDiff} ]] && [[ ! -z \${minutes} ]] && [[ \${minutes} -lt '120' ]]" >> /etc/nginx/v2ray-agent-https/reloadInstallTLS.sh if [[ ! -z \${modifyTime} ]] && [[ ! -z \${currentTime} ]] && [[ ! -z \${stampDiff} ]] && [[ ! -z \${minutes} ]] && [[ \${minutes} -lt '120' ]]
echo "then" >> /etc/nginx/v2ray-agent-https/reloadInstallTLS.sh then
echo "nginx -s stop" >> /etc/nginx/v2ray-agent-https/reloadInstallTLS.sh nginx -s stop
echo "~/.acme.sh/acme.sh --installcert -d \${domain} --fullchainpath /etc/nginx/v2ray-agent-https/\${domain}.crt --keypath /etc/nginx/v2ray-agent-https/\${domain}.key --ecc >> /tmp/tls/acme.log" >> /etc/nginx/v2ray-agent-https/reloadInstallTLS.sh ~/.acme.sh/acme.sh --installcert -d \${domain} --fullchainpath /etc/nginx/v2ray-agent-https/\${domain}.crt --keypath /etc/nginx/v2ray-agent-https/\${domain}.key --ecc >> /tmp/tls/acme.log
echo "nginx" >> /etc/nginx/v2ray-agent-https/reloadInstallTLS.sh nginx
echo "reloadTime=\`date -d @\${currentTime} +\"%F %H:%M:%S\"\`" >> /etc/nginx/v2ray-agent-https/reloadInstallTLS.sh reloadTime=\`date -d @\${currentTime} +"%F %H:%M:%S"\`
echo "fi" >> /etc/nginx/v2ray-agent-https/reloadInstallTLS.sh fi
echo "echo \"域名:\${domain}modifyTime:\"\`date -d @\${modifyTime} +\"%F %H:%M:%S\"\`,\"检查时间:\"\`date -d @\${currentTime} +\"%F %H:%M:%S\"\`,"上次生成证书的时:"\`expr \${minutes} / 1440\`\"天前\",\"证书状态:\"\${status},\"重新生成日期:\"\${reloadTime} >> /tmp/tls/tls.log" >> /etc/nginx/v2ray-agent-https/reloadInstallTLS.sh echo "域名:\${domain}modifyTime:"\`date -d @\${modifyTime} +"%F %H:%M:%S"\`,"检查时间:"\`date -d @\${currentTime} +"%F %H:%M:%S"\`,上次生成证书的时:\`expr \${minutes} / 1440\`"天前","证书状态:"\${status},"重新生成日期:"\${reloadTime} >> /etc/v2ray-agent/tls/tls.log
echo "else" >> /etc/nginx/v2ray-agent-https/reloadInstallTLS.sh else
echo "echo '无法找到证书路径' >> /etc/v2ray-agent/tls/tls.log" >> /etc/nginx/v2ray-agent-https/reloadInstallTLS.sh echo '无法找到证书路径' >> /etc/v2ray-agent/tls/tls.log
echo "fi" >> /etc/nginx/v2ray-agent-https/reloadInstallTLS.sh fi
EOF
if [[ ! -z `crontab -l|grep -v grep|grep 'reloadInstallTLS'` ]] if [[ ! -z `crontab -l|grep -v grep|grep 'reloadInstallTLS'` ]]
then then
@ -451,24 +452,27 @@ installV2RayService(){
rm -rf /etc/systemd/system/v2ray.service rm -rf /etc/systemd/system/v2ray.service
touch /etc/systemd/system/v2ray.service touch /etc/systemd/system/v2ray.service
echo '[Unit]' >> /etc/systemd/system/v2ray.service cat << EOF > /etc/systemd/system/v2ray.service
echo 'Description=V2Ray - A unified platform for anti-censorship' >> /etc/systemd/system/v2ray.service [Unit]
echo 'Documentation=https://v2ray.com https://guide.v2fly.org' >> /etc/systemd/system/v2ray.service Description=V2Ray - A unified platform for anti-censorship
echo 'After=network.target nss-lookup.target' >> /etc/systemd/system/v2ray.service Documentation=https://v2ray.com https://guide.v2fly.org
echo 'Wants=network-online.target' >> /etc/systemd/system/v2ray.service After=network.target nss-lookup.target
echo '' >> /etc/systemd/system/v2ray.service Wants=network-online.target
echo '[Service]' >> /etc/systemd/system/v2ray.service
echo 'Type=simple' >> /etc/systemd/system/v2ray.service [Service]
echo 'User=root' >> /etc/systemd/system/v2ray.service Type=simple
echo 'CapabilityBoundingSet=CAP_NET_BIND_SERVICE CAP_NET_RAW' >> /etc/systemd/system/v2ray.service User=root
echo 'NoNewPrivileges=yes' >> /etc/systemd/system/v2ray.service CapabilityBoundingSet=CAP_NET_BIND_SERVICE CAP_NET_RAW
echo 'ExecStart=/usr/bin/v2ray/v2ray -config /etc/v2ray/config.json' >> /etc/systemd/system/v2ray.service NoNewPrivileges=yes
echo 'Restart=on-failure' >> /etc/systemd/system/v2ray.service ExecStart=/usr/bin/v2ray/v2ray -config /etc/v2ray/config.json
echo 'RestartPreventExitStatus=23' >> /etc/systemd/system/v2ray.service Restart=on-failure
echo '' >> /etc/systemd/system/v2ray.service RestartPreventExitStatus=23
echo '' >> /etc/systemd/system/v2ray.service
echo '[Install]' >> /etc/systemd/system/v2ray.service
echo 'WantedBy=multi-user.target' >> /etc/systemd/system/v2ray.service [Install]
WantedBy=multi-user.target
EOF
progressTools "green" " 配置V2Ray开机自启成功--->" progressTools "green" " 配置V2Ray开机自启成功--->"
} }