mirror of
https://github.com/spiritLHLS/one-click-installation-script.git
synced 2024-11-16 14:22:18 +08:00
Update modify_time.sh
This commit is contained in:
parent
22265c87a8
commit
d6f4e8f585
|
@ -51,9 +51,9 @@ check_os() {
|
|||
|
||||
main(){
|
||||
# 获取当前时间和网络时间
|
||||
CURRENT_TIME=$(date +%s)
|
||||
CURRENT_TIME=$(date -u +%s)
|
||||
NETWORK_TIME=$(wget -qSO- --max-redirect=0 google.com 2>&1 | grep Date: | cut -d' ' -f5-8)
|
||||
NETWORK_TIME_SECONDS=$(date -d "$NETWORK_TIME" +%s)
|
||||
NETWORK_TIME_SECONDS=$(TZ=":UTC" date -d "$NETWORK_TIME" +%s)
|
||||
|
||||
# 计算时间差
|
||||
DIFF=$(($NETWORK_TIME_SECONDS-$CURRENT_TIME))
|
||||
|
@ -88,14 +88,22 @@ main(){
|
|||
fi
|
||||
}
|
||||
|
||||
|
||||
check_again(){
|
||||
# 获取当前时间和网络时间
|
||||
CURRENT_TIME=$(date +%s)
|
||||
NETWORK_TIME=$(wget -qSO- --max-redirect=0 google.com 2>&1 | grep Date: | cut -d' ' -f5-8)
|
||||
NETWORK_TIME_SECONDS=$(date -d "$NETWORK_TIME" +%s)
|
||||
|
||||
# 获取当前时区
|
||||
CURRENT_TZ=$(date +%Z)
|
||||
# 获取网络时间对应的时区
|
||||
NETWORK_TZ=$(echo "$NETWORK_TIME" | awk '{print $5}')
|
||||
# 计算时区差,单位是秒
|
||||
TZ_DIFF=$((($(date -d "$NETWORK_TZ" +%s)-$(date -d "$CURRENT_TZ" +%s))/3600*3600))
|
||||
|
||||
# 计算时间差
|
||||
DIFF=$(($NETWORK_TIME_SECONDS-$CURRENT_TIME))
|
||||
DIFF=$(($NETWORK_TIME_SECONDS-$CURRENT_TIME-$TZ_DIFF))
|
||||
|
||||
# 判断时间差是否在允许范围内
|
||||
if [ "$DIFF" -lt 300 ] && [ "$DIFF" -gt -300 ]; then
|
||||
|
@ -109,6 +117,7 @@ check_again(){
|
|||
|
||||
|
||||
|
||||
|
||||
head
|
||||
check_os
|
||||
main
|
||||
|
|
Loading…
Reference in New Issue
Block a user