distribution/packages/sysutils/systemd/scripts/systemd-timesyncd-setup

23 lines
552 B
Text
Raw Normal View History

2022-02-05 14:23:32 +00:00
#!/bin/sh
KERNEL_NTP="${1:-/proc/net/ipconfig/ntp_servers}"
NTP_SERVERS=""
if [ -f /proc/net/ipconfig/ntp_servers ]; then
for srv in $(cat /proc/net/ipconfig/ntp_servers); do
if [ -n "$srv" -a "$srv" != "0.0.0.0" ]; then
if [ -z "$NTP_SERVERS" ]; then
NTP_SERVERS="$srv"
else
NTP_SERVERS="${NTP_SERVERS} $srv"
fi
fi
done
if [ -n "$NTP_SERVERS" ]; then
mkdir -p /run/systemd/timesyncd.conf.d/
cat << EOF > /run/systemd/timesyncd.conf.d/kernel-ntp-servers.conf
[Time]
NTP=$NTP_SERVERS
EOF
fi
fi