From 0ca8aa53a0497cb7eb69dec2a594481c216f4574 Mon Sep 17 00:00:00 2001 From: Brian Zalewski <59970525+ProfessorManhattan@users.noreply.github.com> Date: Mon, 25 Dec 2023 02:57:07 +0000 Subject: [PATCH] Updated NTP to list of servers --- .../universal/run_before_05-system.sh.tmpl | 15 ++++++++++++++- home/dot_local/etc/ntp.conf | 15 +++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 home/dot_local/etc/ntp.conf diff --git a/home/.chezmoiscripts/universal/run_before_05-system.sh.tmpl b/home/.chezmoiscripts/universal/run_before_05-system.sh.tmpl index ce9f32f1..1e7a46c1 100644 --- a/home/.chezmoiscripts/universal/run_before_05-system.sh.tmpl +++ b/home/.chezmoiscripts/universal/run_before_05-system.sh.tmpl @@ -565,10 +565,23 @@ setHostname() { } # @description Sets the NTP server using `m` on macOS +# +# `2>/dev/null 1>&2` was added after `sudo systemsetup -setusingnetworktime` calls because the command was outputting the following +# useless error: +# +# ```shell +# ### Error:-99 File:/AppleInternal/Library/BuildRoots/0032d1ee-80fd-11ee-8227-6aecfccc70fe/Library/Caches/com.apple.xbs/Sources/Admin/InternetServices.m Line:379 +# ``` setNtpServer() { if command -v m > /dev/null; then ### macOS - m ntp set {{ .user.ntpServer }} + logg info 'Copying ~/.local/etc/ntp.conf to /etc/ntp.conf' + sudo cp -f "${XDG_DATA_HOME:-$HOME/.local/share}/chezmoi/home/dot_local/etc/ntp.conf" /etc/ntp.conf + logg info 'Copying ~/.local/etc/ntp.conf to /private/etc/ntp.conf' + sudo cp -f "${XDG_DATA_HOME:-$HOME/.local/share}/chezmoi/home/dot_local/etc/ntp.conf" /private/etc/ntp.conf + logg info 'Turning off setusingnetworktime for 2 seconds' && sudo systemsetup -setusingnetworktime off 2>/dev/null 1>&2 + sleep 2 + logg info 'Re-enabling setusingnetworktime' && sudo systemsetup -setusingnetworktime on 2>/dev/null 1>&2 else logg warn 'Skipped setting the NTP server' fi diff --git a/home/dot_local/etc/ntp.conf b/home/dot_local/etc/ntp.conf new file mode 100644 index 00000000..ed0d844f --- /dev/null +++ b/home/dot_local/etc/ntp.conf @@ -0,0 +1,15 @@ +server 0.pool.ntp.org +server 1.pool.ntp.org +server 2.pool.ntp.org +server ntp2.lrz.de +server ntp1.lrz.de +server ntp3.lrz.de +server ptbtime1.ptb.de +server ptbtime2.ptb.de +server ptbtime3.ptb.de +server ntp1.in.tum.de +server ntp2.in.tum.de +server time.euro.apple.com +server time.apple.com +server time.asia.apple.com +server time.windows.com \ No newline at end of file