feat(脚本): 增加tls更新

pull/534/merge
mack-a 2020-07-03 18:01:32 +08:00
parent 80082ebf48
commit 4cd03ef0b4
2 changed files with 42 additions and 0 deletions

View File

@ -253,6 +253,25 @@ installTLS(){
echoContent green " Nginx启动成功TLS配置成功--->\n"
installV2Ray $1 ${customPath}
}
# 重新安装&更新tls证书
reloadInstallTLS(){
touch /etc/nginx/v2ray-agent-https/reloadInstallTLS.sh
echo "#!/usr/bin/env bash" >> /etc/nginx/v2ray-agent-https/reloadInstallTLS.sh
echo "domain=$1" >> /etc/nginx/v2ray-agent-https/reloadInstallTLS.sh
echo "modifyTime=`stat test1.am1z.xyz.key|sed -n '6,6p'|awk '{print $2" "$3" "$4" "$5}'`" >> /etc/nginx/v2ray-agent-https/reloadInstallTLS.sh
echo "modifyTime=`date +%s -d "${modifyTime}"`" >> /etc/nginx/v2ray-agent-https/reloadInstallTLS.sh
echo "currentTime=`date +%s`" >> /etc/nginx/v2ray-agent-https/reloadInstallTLS.sh
echo "stampDiff=`expr ${currentTime} - ${modifyTime}`" >> /etc/nginx/v2ray-agent-https/reloadInstallTLS.sh
echo "minutes=`expr ${stampDiff} / 60`" >> /etc/nginx/v2ray-agent-https/reloadInstallTLS.sh
echo "if [[ ! -z ${modifyTime} ]] && [[ ! -z ${currentTime} ]] && [[ ! -z ${stampDiff} ]] && [[ ! -z ${minutes} ]] && [[ ${minutes} -lt '120' ]]" >> /etc/nginx/v2ray-agent-https/reloadInstallTLS.sh
echo "then" >> /etc/nginx/v2ray-agent-https/reloadInstallTLS.sh
echo "nginx -s stop" >> /etc/nginx/v2ray-agent-https/reloadInstallTLS.sh
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 >/dev/null" >> /etc/nginx/v2ray-agent-https/reloadInstallTLS.sh
echo "fi" >> /etc/nginx/v2ray-agent-https/reloadInstallTLS.sh
}
# V2Ray
installV2Ray(){
if [[ -z `find /tmp -name "v2ray*"` ]]

23
test.sh Executable file
View File

@ -0,0 +1,23 @@
#!/usr/bin/env bash
touch /etc/nginx/v2ray-agent-https/reloadInstallTLS.sh
echo '' > /etc/nginx/v2ray-agent-https/reloadInstallTLS.sh
echo '#!/usr/bin/env bash' >> /etc/nginx/v2ray-agent-https/reloadInstallTLS.sh
echo 'domain=$1' >> /etc/nginx/v2ray-agent-https/reloadInstallTLS.sh
echo 'if [[ ! -z `find ~/.acme.sh/ -name ${domain}.key` ]]' >> /etc/nginx/v2ray-agent-https/reloadInstallTLS.sh
echo 'then' >> /etc/nginx/v2ray-agent-https/reloadInstallTLS.sh
echo ' key=`find ~/.acme.sh/ -name ${domain}.key|head -1`' >> /etc/nginx/v2ray-agent-https/reloadInstallTLS.sh
echo ' echo ${key}' >> /etc/nginx/v2ray-agent-https/reloadInstallTLS.sh
echo ' modifyTime=`stat ${key}|sed -n '\'6,6p\''|awk '{print \$2\" \"\$3\" \"\$4\" \"\$5}'`' >> /etc/nginx/v2ray-agent-https/reloadInstallTLS.sh
echo ' modifyTime=`date +%s -d "${modifyTime}"`' >> /etc/nginx/v2ray-agent-https/reloadInstallTLS.sh
echo ' currentTime=`date +%s`' >> /etc/nginx/v2ray-agent-https/reloadInstallTLS.sh
echo ' stampDiff=`expr ${currentTime} - ${modifyTime}`' >> /etc/nginx/v2ray-agent-https/reloadInstallTLS.sh
echo ' minutes=`expr ${stampDiff} / 60`' >> /etc/nginx/v2ray-agent-https/reloadInstallTLS.sh
echo ' echo ${minutes}' >> /etc/nginx/v2ray-agent-https/reloadInstallTLS.sh
echo ' if [[ ! -z ${modifyTime} ]] && [[ ! -z ${currentTime} ]] && [[ ! -z ${stampDiff} ]] && [[ ! -z ${minutes} ]] && [[ ${minutes} -lt '\'200000\'' ]]' >> /etc/nginx/v2ray-agent-https/reloadInstallTLS.sh
echo ' then' >> /etc/nginx/v2ray-agent-https/reloadInstallTLS.sh
echo ' echo "符合条件"' >> /etc/nginx/v2ray-agent-https/reloadInstallTLS.sh
#echo ' nginx -s stop' >> /etc/nginx/v2ray-agent-https/reloadInstallTLS.sh
#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' >> /etc/nginx/v2ray-agent-https/reloadInstallTLS.sh
echo ' fi' >> /etc/nginx/v2ray-agent-https/reloadInstallTLS.sh
echo 'fi' >> /etc/nginx/v2ray-agent-https/reloadInstallTLS.sh
echo "exit 0" >> /etc/nginx/v2ray-agent-https/reloadInstallTLS.sh