#!/bin/bash
#
# 加个时间判断
my_time=`date +%s`
let time_diff=$(expr $time_from_aaaa - $my_time)
time_diff=$(awk "BEGIN {print abs($time_diff)}")
if [ $time_diff > 30 ];then #假如时间差大小30秒,就从faq上更新时间
formatted_date_time=$(date -r $time_from_aaaa "+%m%d%H%M%Y.%S")
sudo date "$formatted_date_time"
(
/usr/bin/osascript -e 'display dialog "时间不准,已更新;hosts文件已更新,确保您是nst连网权限,或者在沙箱内执行,请到 https://2.2.2.3:444 上网认证试试!" buttons {"OK"} default button "OK"')
else
(
/usr/bin/osascript -e 'display dialog "hosts文件已更新,确保您是nst连网权限,或者在沙箱内执行,请到 https://1.1.1.3:444 上网认证试试!" buttons {"OK"} default button "OK"')
fi