From a527e20aec42e25b76cca2ab7ae7eba9b0ccd28a Mon Sep 17 00:00:00 2001 From: mack-a <57424792+mack-a@users.noreply.github.com> Date: Sun, 9 Oct 2022 17:27:01 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E8=84=9A=E6=9C=AC):=20=E5=AE=8C=E5=96=84d?= =?UTF-8?q?ns=E7=94=B3=E8=AF=B7=E8=AF=81=E4=B9=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- install.sh | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/install.sh b/install.sh index 2795fcd..33d90fe 100644 --- a/install.sh +++ b/install.sh @@ -209,14 +209,14 @@ initVar() { # dns tls domain dnsTLSDomain= - # - dnsTLSDomainStatus= + # 该域名是否通过dns安装通配符证书 + installDNSACMEStatus= } # 读取tls证书详情 readAcmeTLS() { if [[ -d "$HOME/.acme.sh/*.${dnsTLSDomain}_ecc" && -f "$HOME/.acme.sh/*.${dnsTLSDomain}_ecc/*.${dnsTLSDomain}.key" && -f "$HOME/.acme.sh/*.${dnsTLSDomain}_ecc/*.${dnsTLSDomain}.cer" ]]; then - dnsTLSDomainStatus=true + installDNSACMEStatus=true fi } # 检测安装方式 @@ -1123,6 +1123,7 @@ acmeInstallSSL() { echoContent green " ---> name:_acme-challenge" echoContent green " ---> value:${txtValue}" echoContent yellow " ---> 添加完成后等请等待1-2分钟" + echo read -r -p "是否添加完成[y/n]:" addDNSTXTRecordStatus if [[ "${addDNSTXTRecordStatus}" == "y" ]]; then local txtAnswer= @@ -1143,6 +1144,7 @@ acmeInstallSSL() { else sudo "$HOME/.acme.sh/acme.sh" --issue -d "${tlsDomain}" --standalone -k ec-256 --server "${sslType}" "${installSSLIPv6}" 2>&1 | tee -a /etc/v2ray-agent/tls/acme.log >/dev/null fi + readAcmeTLS } # 安装TLS @@ -1170,12 +1172,15 @@ installTLS() { 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证书" - switchSSLType - customSSLEmail - ## todo 添加证书已安装判断 - acmeInstallSSL + if [[ "${installDNSACMEStatus}" != "true" ]]; then + switchSSLType + customSSLEmail + acmeInstallSSL + else + echoContent green " ---> 检测到已安装通配符证书,自动生成中" + fi - if [[ "${dnsSSLStatus}" == "true" ]]; then + if [[ "${installDNSACMEStatus}" == "true" ]]; then echo if [[ -d "$HOME/.acme.sh/*.${dnsTLSDomain}_ecc" && -f "$HOME/.acme.sh/*.${dnsTLSDomain}_ecc/*.${dnsTLSDomain}.key" && -f "$HOME/.acme.sh/*.${dnsTLSDomain}_ecc/*.${dnsTLSDomain}.cer" ]]; then sudo "$HOME/.acme.sh/acme.sh" --installcert -d "*.${dnsTLSDomain}" --fullchainpath "/etc/v2ray-agent/tls/${tlsDomain}.crt" --keypath "/etc/v2ray-agent/tls/${tlsDomain}.key" --ecc >/dev/null @@ -1377,7 +1382,6 @@ renewalTLS() { modifyTime=$(stat "$HOME/.acme.sh/${domain}_ecc/${domain}.cer" | sed -n '7,6p' | awk '{print $2" "$3" "$4" "$5}') fi - modifyTime=$(date +%s -d "${modifyTime}") currentTime=$(date +%s) ((stampDiff = currentTime - modifyTime))