feat(脚本): 增加邮箱无法通过SSL厂商验证检测、兼容buypass 180天有效期检查

pull/534/merge
mack-a 2022-09-21 17:52:28 +08:00
parent a2155a8fc8
commit 7b5b9e48f0
1 changed files with 36 additions and 7 deletions

View File

@ -199,6 +199,9 @@ initVar() {
# ssl邮箱 # ssl邮箱
sslEmail= sslEmail=
# 检查天数
sslRenewalDays=90
} }
# 检测安装方式 # 检测安装方式
@ -1020,6 +1023,15 @@ checkIP() {
} }
# 自定义email # 自定义email
customSSLEmail() { customSSLEmail() {
if echo "$1" | grep -q "validate email"; then
read -r -p "是否重新输入邮箱地址[y/n]:" sslEmailStatus
if [[ "${sslEmailStatus}" == "y" ]]; then
sed '/ACCOUNT_EMAIL/d' /root/.acme.sh/account.conf >/root/.acme.sh/account.conf_tmp && mv /root/.acme.sh/account.conf_tmp /root/.acme.sh/account.conf
else
exit 0
fi
fi
if [[ -d "/root/.acme.sh" && -f "/root/.acme.sh/account.conf" ]]; then if [[ -d "/root/.acme.sh" && -f "/root/.acme.sh/account.conf" ]]; then
if ! grep -q "ACCOUNT_EMAIL" <"/root/.acme.sh/account.conf" && ! echo "${sslType}" | grep -q "letsencrypt"; then if ! grep -q "ACCOUNT_EMAIL" <"/root/.acme.sh/account.conf" && ! echo "${sslType}" | grep -q "letsencrypt"; then
read -r -p "请输入邮箱地址:" sslEmail read -r -p "请输入邮箱地址:" sslEmail
@ -1031,7 +1043,6 @@ customSSLEmail() {
customSSLEmail customSSLEmail
fi fi
fi fi
echo
fi fi
} }
@ -1058,6 +1069,8 @@ switchSSLType() {
sslType="letsencrypt" sslType="letsencrypt"
;; ;;
esac esac
touch /etc/v2ray-agent/tls
echo "${sslType}" >/etc/v2ray-agent/tls/ssl_type
fi fi
} }
# 安装TLS # 安装TLS
@ -1088,9 +1101,9 @@ installTLS() {
customSSLEmail customSSLEmail
if echo "${localIP}" | grep -q ":"; then if echo "${localIP}" | grep -q ":"; then
sudo "$HOME/.acme.sh/acme.sh" --issue -d "${tlsDomain}" --standalone -k ec-256 --server "${sslType}" --listen-v6 | tee -a /etc/v2ray-agent/tls/acme.log >/dev/null sudo "$HOME/.acme.sh/acme.sh" --issue -d "${tlsDomain}" --standalone -k ec-256 --server "${sslType}" --listen-v6 2>&1 | tee -a /etc/v2ray-agent/tls/acme.log >/dev/null
else else
sudo "$HOME/.acme.sh/acme.sh" --issue -d "${tlsDomain}" --standalone -k ec-256 --server "${sslType}" | tee -a /etc/v2ray-agent/tls/acme.log >/dev/null sudo "$HOME/.acme.sh/acme.sh" --issue -d "${tlsDomain}" --standalone -k ec-256 --server "${sslType}" 2>&1 | tee -a /etc/v2ray-agent/tls/acme.log >/dev/null
fi fi
if [[ -d "$HOME/.acme.sh/${tlsDomain}_ecc" && -f "$HOME/.acme.sh/${tlsDomain}_ecc/${tlsDomain}.key" && -f "$HOME/.acme.sh/${tlsDomain}_ecc/${tlsDomain}.cer" ]]; then if [[ -d "$HOME/.acme.sh/${tlsDomain}_ecc" && -f "$HOME/.acme.sh/${tlsDomain}_ecc/${tlsDomain}.key" && -f "$HOME/.acme.sh/${tlsDomain}_ecc/${tlsDomain}.cer" ]]; then
@ -1102,11 +1115,21 @@ installTLS() {
echoContent red " ---> TLS安装失败请检查acme日志" echoContent red " ---> TLS安装失败请检查acme日志"
exit 0 exit 0
fi fi
installTLSCount=1
echo
echoContent red " ---> TLS安装失败正在检查80、443端口是否开放" echoContent red " ---> TLS安装失败正在检查80、443端口是否开放"
allowPort 80 allowPort 80
allowPort 443 allowPort 443
echoContent yellow " ---> 重新尝试安装TLS证书" echoContent yellow " ---> 重新尝试安装TLS证书"
installTLSCount=1
if tail -n 10 /etc/v2ray-agent/tls/acme.log | grep -q "Could not validate email address as valid"; then
echoContent red " ---> 邮箱无法通过SSL厂商验证请重新输入"
echo
customSSLEmail "validate email"
installTLS "$1"
fi
installTLS "$1" installTLS "$1"
fi fi
echoContent green " ---> TLS生成成功" echoContent green " ---> TLS生成成功"
@ -1261,6 +1284,12 @@ renewalTLS() {
domain=${tlsDomain} domain=${tlsDomain}
fi fi
if [[ -f "/etc/v2ray-agent/tls/ssl_type" ]]; then
if grep -q "buypass" <"/etc/v2ray-agent/tls/ssl_type"; then
sslRenewalDays=180
fi
fi
if [[ -d "$HOME/.acme.sh/${domain}_ecc" ]] && [[ -f "$HOME/.acme.sh/${domain}_ecc/${domain}.key" ]] && [[ -f "$HOME/.acme.sh/${domain}_ecc/${domain}.cer" ]]; then if [[ -d "$HOME/.acme.sh/${domain}_ecc" ]] && [[ -f "$HOME/.acme.sh/${domain}_ecc/${domain}.key" ]] && [[ -f "$HOME/.acme.sh/${domain}_ecc/${domain}.cer" ]]; then
modifyTime=$(stat "$HOME/.acme.sh/${domain}_ecc/${domain}.cer" | sed -n '7,6p' | awk '{print $2" "$3" "$4" "$5}') modifyTime=$(stat "$HOME/.acme.sh/${domain}_ecc/${domain}.cer" | sed -n '7,6p' | awk '{print $2" "$3" "$4" "$5}')
@ -1268,7 +1297,7 @@ renewalTLS() {
currentTime=$(date +%s) currentTime=$(date +%s)
((stampDiff = currentTime - modifyTime)) ((stampDiff = currentTime - modifyTime))
((days = stampDiff / 86400)) ((days = stampDiff / 86400))
((remainingDays = 90 - days)) ((remainingDays = sslRenewalDays - days))
tlsStatus=${remainingDays} tlsStatus=${remainingDays}
if [[ ${remainingDays} -le 0 ]]; then if [[ ${remainingDays} -le 0 ]]; then
@ -1305,7 +1334,7 @@ checkTLStatus() {
currentTime=$(date +%s) currentTime=$(date +%s)
((stampDiff = currentTime - modifyTime)) ((stampDiff = currentTime - modifyTime))
((days = stampDiff / 86400)) ((days = stampDiff / 86400))
((remainingDays = 90 - days)) ((remainingDays = sslRenewalDays - days))
tlsStatus=${remainingDays} tlsStatus=${remainingDays}
if [[ ${remainingDays} -le 0 ]]; then if [[ ${remainingDays} -le 0 ]]; then
@ -4784,7 +4813,7 @@ menu() {
cd "$HOME" || exit cd "$HOME" || exit
echoContent red "\n==============================================================" echoContent red "\n=============================================================="
echoContent green "作者:mack-a" echoContent green "作者:mack-a"
echoContent green "当前版本:v2.5.77" echoContent green "当前版本:v2.5.78"
echoContent green "Github:https://github.com/mack-a/v2ray-agent" echoContent green "Github:https://github.com/mack-a/v2ray-agent"
echoContent green "描述:八合一共存脚本\c" echoContent green "描述:八合一共存脚本\c"
showInstallStatus showInstallStatus