Skip to content

Commit

Permalink
fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Jrohy committed Apr 11, 2020
1 parent 97f526f commit 7b42338
Showing 1 changed file with 26 additions and 18 deletions.
44 changes: 26 additions & 18 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,27 @@ installDependent(){
fi
}

setupCron() {
if [[ `crontab -l 2>/dev/null|grep acme` && -z `crontab -l 2>/dev/null|grep trojan-web` ]]; then
#计算北京时间早上3点时VPS的实际时间
ORIGIN_TIME_ZONE=$(date -R|awk '{printf"%d",$6}')
LOCAL_TIME_ZONE=${ORIGIN_TIME_ZONE%00}
BEIJING_ZONE=8
BEIJING_UPDATE_TIME=3
DIFF_ZONE=$[$BEIJING_ZONE-$LOCAL_TIME_ZONE]
LOCAL_TIME=$[$BEIJING_UPDATE_TIME-$DIFF_ZONE]
if [ $LOCAL_TIME -lt 0 ];then
LOCAL_TIME=$[24+$LOCAL_TIME]
elif [ $LOCAL_TIME -ge 24 ];then
LOCAL_TIME=$[$LOCAL_TIME-24]
fi
crontab -l 2>/dev/null|sed '/acme.sh/d' > crontab.txt
echo "0 ${LOCAL_TIME}"' * * * systemctl stop trojan-web && "/root/.acme.sh"/acme.sh --cron --home "/root/.acme.sh" > /dev/null && systemctl start trojan-web' >> crontab.txt
crontab crontab.txt
rm -f crontab.txt
fi
}

installTrojan(){
local SHOW_TIP=0
if [[ $UPDATE == 1 ]];then
Expand All @@ -137,27 +158,14 @@ installTrojan(){
echo -e "运行命令`colorEcho $BLUE trojan`可进行trojan管理\n"
/usr/local/bin/trojan
else
if [[ `cat /usr/local/etc/trojan/config.json|grep -w "\"db\""` ]];then
sed -i "s/\"db\"/\"database\"/g" /usr/local/etc/trojan/config.json
systemctl restart trojan
fi
colorEcho $GREEN "更新trojan管理程序成功!\n"
fi
setupCron
systemctl restart trojan-web
if [[ -z `crontab -l 2>/dev/null|grep trojan-web` ]]; then
#计算北京时间早上3点时VPS的实际时间
ORIGIN_TIME_ZONE=$(date -R|awk '{printf"%d",$6}')
LOCAL_TIME_ZONE=${ORIGIN_TIME_ZONE%00}
BEIJING_ZONE=8
BEIJING_UPDATE_TIME=3
DIFF_ZONE=$[$BEIJING_ZONE-$LOCAL_TIME_ZONE]
LOCAL_TIME=$[$BEIJING_UPDATE_TIME-$DIFF_ZONE]
if [ $LOCAL_TIME -lt 0 ];then
LOCAL_TIME=$[24+$LOCAL_TIME]
elif [ $LOCAL_TIME -ge 24 ];then
LOCAL_TIME=$[$LOCAL_TIME-24]
fi
crontab -l 2>/dev/null|sed '/acme.sh/d' > crontab.txt
echo "0 ${LOCAL_TIME}"' * * * systemctl stop trojan-web && "/root/.acme.sh"/acme.sh --cron --home "/root/.acme.sh" > /dev/null && systemctl start trojan-web' >> crontab.txt
crontab crontab.txt
rm -f crontab.txt
fi
[[ $SHOW_TIP == 1 ]] && echo "浏览器访问'`colorEcho $BLUE https://域名`'可在线trojan多用户管理"
}

Expand Down

0 comments on commit 7b42338

Please sign in to comment.