From c8ae7b5224042f41960d1017c064b4341d0aaf2b Mon Sep 17 00:00:00 2001 From: mack-a Date: Wed, 22 Sep 2021 11:43:55 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E8=84=9A=E6=9C=AC):=20=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E8=AF=81=E4=B9=A6=E8=BF=87=E6=9C=9F=E6=98=AF=E9=87=8D=E6=96=B0?= =?UTF-8?q?=E5=AE=89=E8=A3=85=E5=AF=BC=E8=87=B4=E4=B8=80=E7=9B=B4=E4=B8=8D?= =?UTF-8?q?=E5=81=9C=E9=87=8D=E5=A4=8D=E6=89=A7=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- install.sh | 51 +++++++++++++++++++++++---------------------------- 1 file changed, 23 insertions(+), 28 deletions(-) diff --git a/install.sh b/install.sh index 4f56a272..f3078b7c 100644 --- a/install.sh +++ b/install.sh @@ -953,17 +953,11 @@ installTLS() { local tlsDomain=${domain} # 安装tls if [[ -f "/etc/v2ray-agent/tls/${tlsDomain}.crt" && -f "/etc/v2ray-agent/tls/${tlsDomain}.key" && -n $(cat "/etc/v2ray-agent/tls/${tlsDomain}.crt") ]] || [[ -d "$HOME/.acme.sh/${tlsDomain}_ecc" && -f "$HOME/.acme.sh/${tlsDomain}_ecc/${tlsDomain}.key" && -f "$HOME/.acme.sh/${tlsDomain}_ecc/${tlsDomain}.cer" ]]; then - # 存在证书 echoContent green " ---> 检测到证书" - checkTLStatus "${tlsDomain}" - if [[ "${tlsStatus}" == "已过期" ]]; then - rm -rf "$HOME/.acme.sh/${tlsDomain}_ecc/*" - rm -rf "/etc/v2ray-agent/tls/${tlsDomain}*" - installTLS "$1" - else - echoContent green " ---> 证书有效" - # - if [[ -z $(find /etc/v2ray-agent/tls/ -name "${tlsDomain}.crt") ]] || [[ -z $(find /etc/v2ray-agent/tls/ -name "${tlsDomain}.key") ]] || [[ -z $(cat "/etc/v2ray-agent/tls/${tlsDomain}.crt") ]]; then + # checkTLStatus + renewalTLS + + if [[ -z $(find /etc/v2ray-agent/tls/ -name "${tlsDomain}.crt") ]] || [[ -z $(find /etc/v2ray-agent/tls/ -name "${tlsDomain}.key") ]] || [[ -z $(cat "/etc/v2ray-agent/tls/${tlsDomain}.crt") ]]; then sudo "$HOME/.acme.sh/acme.sh" --installcert -d "${tlsDomain}" --fullchainpath "/etc/v2ray-agent/tls/${tlsDomain}.crt" --keypath "/etc/v2ray-agent/tls/${tlsDomain}.key" --ecc >/dev/null else echoContent yellow " ---> 如未过期请选择[n]\n" @@ -972,8 +966,8 @@ installTLS() { rm -rf /etc/v2ray-agent/tls/* installTLS "$1" fi - fi fi + elif [[ -d "$HOME/.acme.sh" ]] && [[ ! -f "$HOME/.acme.sh/${tlsDomain}_ecc/${tlsDomain}.cer" || ! -f "$HOME/.acme.sh/${tlsDomain}_ecc/${tlsDomain}.key" ]]; then echoContent green " ---> 安装TLS证书" if echo "${localIP}" | grep -q ":"; then @@ -1107,7 +1101,9 @@ installCronTLS() { # 更新证书 renewalTLS() { - echoContent skyBlue "\n进度 1/1 : 更新证书" + if [[ -n $1 ]]; then + echoContent skyBlue "\n进度 $1/1 : 更新证书" + fi if [[ -d "$HOME/.acme.sh/${currentHost}_ecc" ]] && [[ -f "$HOME/.acme.sh/${currentHost}_ecc/${currentHost}.key" ]] && [[ -f "$HOME/.acme.sh/${currentHost}_ecc/${currentHost}.cer" ]]; then modifyTime=$(stat "$HOME/.acme.sh/${currentHost}_ecc/${currentHost}.cer" | sed -n '7,6p' | awk '{print $2" "$3" "$4" "$5}') @@ -1145,24 +1141,23 @@ renewalTLS() { # 查看TLS证书的状态 checkTLStatus() { - if [[ -n "$1" ]]; then - if [[ -d "$HOME/.acme.sh/$1_ecc" ]] && [[ -f "$HOME/.acme.sh/$1_ecc/$1.key" ]] && [[ -f "$HOME/.acme.sh/$1_ecc/$1.cer" ]]; then - modifyTime=$(stat "$HOME/.acme.sh/$1_ecc/$1.key" | sed -n '7,6p' | awk '{print $2" "$3" "$4" "$5}') + if [[ -d "$HOME/.acme.sh/${currentHost}_ecc" ]] && [[ -f "$HOME/.acme.sh/${currentHost}_ecc/${currentHost}.key" ]] && [[ -f "$HOME/.acme.sh/${currentHost}_ecc/${currentHost}.cer" ]]; then + modifyTime=$(stat "$HOME/.acme.sh/${currentHost}_ecc/${currentHost}.cer" | sed -n '7,6p' | awk '{print $2" "$3" "$4" "$5}') - modifyTime=$(date +%s -d "${modifyTime}") - currentTime=$(date +%s) - ((stampDiff = currentTime - modifyTime)) - ((days = stampDiff / 86400)) - ((remainingDays = 90 - days)) + modifyTime=$(date +%s -d "${modifyTime}") + currentTime=$(date +%s) + ((stampDiff = currentTime - modifyTime)) + ((days = stampDiff / 86400)) + ((remainingDays = 90 - days)) - tlsStatus=${remainingDays} - if [[ ${remainingDays} -le 0 ]]; then - tlsStatus="已过期" - fi - echoContent skyBlue " ---> 证书生成日期:$(date -d "@${modifyTime}" +"%F %H:%M:%S")" - echoContent skyBlue " ---> 证书生成天数:${days}" - echoContent skyBlue " ---> 证书剩余天数:${tlsStatus}" + tlsStatus=${remainingDays} + if [[ ${remainingDays} -le 0 ]]; then + tlsStatus="已过期" fi + + echoContent skyBlue " ---> 证书生成日期:$(date -d "@${modifyTime}" +"%F %H:%M:%S")" + echoContent skyBlue " ---> 证书生成天数:${days}" + echoContent skyBlue " ---> 证书剩余天数:${tlsStatus}" fi } @@ -4273,7 +4268,7 @@ menu() { cd "$HOME" || exit echoContent red "\n==============================================================" echoContent green "作者:mack-a" - echoContent green "当前版本:v2.5.35" + echoContent green "当前版本:v2.5.36" echoContent green "Github:https://github.com/mack-a/v2ray-agent" echoContent green "描述:八合一共存脚本\c" showInstallStatus