feat(脚本): 增加定时任务

pull/534/merge
mack-a 2020-07-07 18:05:18 +08:00
parent 4cd03ef0b4
commit 1c35bb52d3
1 changed files with 19 additions and 2 deletions

View File

@ -251,16 +251,24 @@ installTLS(){
exit 0
fi
echoContent green " Nginx启动成功TLS配置成功--->\n"
# 增加定时任务定时维护证书
# reInstallTLS $1
installV2Ray $1 ${customPath}
}
# 重新安装&更新tls证书
reloadInstallTLS(){
reInstallTLS(){
echoContent yellow "添加定时维护证书"
touch /etc/nginx/v2ray-agent-https/reloadInstallTLS.sh
touch /etc/nginx/v2ray-agent-https/backup_crontab.cron
# 定时任务
echo "40 0 * * * bash /etc/nginx/v2ray-agent-https/reloadInstallTLS.sh" > /etc/nginx/v2ray-agent-https/backup_crontab.cron
# 备份
crontab -l > /etc/nginx/v2ray-agent-https/backup_crontab.cron
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=`stat $1.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
@ -269,7 +277,16 @@ reloadInstallTLS(){
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 "nginx" >> /etc/nginx/v2ray-agent-https/reloadInstallTLS.sh
echo "fi" >> /etc/nginx/v2ray-agent-https/reloadInstallTLS.sh
crontab /etc/nginx/v2ray-agent-https/backup_crontab.cron
crontabResult=`crontab -l`
if [[ -z `crontab -l|grep -v grep|grep 'reloadInstallTLS'` ]]
then
echoContent green "添加定时维护证书"
else
echoContent red "添加定时维护证书失败"
fi
}
# V2Ray