From 6b425a2b2f35fb90b00583fbf503f30816d2ebb7 Mon Sep 17 00:00:00 2001 From: Shulhan Date: Fri, 1 Jul 2022 00:07:23 +0700 Subject: all: use drop-ins replacement to overwrite NTP configuration Per manual page timesyncd.conf(5) [1]: Initially, the main configuration file in /etc/systemd/ contains commented out entries showing the defaults as a guide to the administrator. ... Using drop-ins for local configuration is recommended over modifications to the main configuration file. The reason why the filename is 00- describe below It is recommended to prefix all filenames in those subdirectories with a two-digit number and a dash, to simplify the ordering of the files. Another reason is to prevent the system being littered with /etc/systemd/timesyncd.conf.pacnew files when systemd updated. [1] https://man.archlinux.org/man/timesyncd.conf.5 --- build-arch-gce | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'build-arch-gce') diff --git a/build-arch-gce b/build-arch-gce index eeefa31..e1caf27 100755 --- a/build-arch-gce +++ b/build-arch-gce @@ -97,15 +97,17 @@ print_fstab() { } echo '- Running additional setup in chroot.' + +echo '-- Configuring NTP.' +mkdir -p $mount_dir/etc/systemd/timesyncd.conf.d/ +cp ./sys/etc/systemd/timesyncd.conf.d/00-google.conf $mount_dir/etc/systemd/timesyncd.conf.d/ + arch-chroot -- "$mount_dir" /bin/bash -s <<-'EOS' set -eEuo pipefail trap 'echo "Error: \`$BASH_COMMAND\` exited with status $?"' ERR echo '-- Configuring time.' ln -sf /usr/share/zoneinfo/UTC /etc/localtime - gawk -i assert -i inplace ' - /^#NTP=/ { $0 = "NTP=metadata.google.internal"; ++f } - { print } END { assert(f == 1, "f == 1") }' /etc/systemd/timesyncd.conf systemctl --quiet enable systemd-timesyncd.service echo '-- Configuring locale.' -- cgit v1.3