1
0
This repository has been archived on 2024-11-10. You can view files and clone it, but cannot push or open issues or pull requests.
Lakka-rk322x/packages/sysutils/systemd/scripts/systemd-timesyncd-setup
Matthias Reichl 750dd4add2 systemd: enable systemd-timesyncd when using kernel ip configuration
connman's NTP client can't be used if it's not managing the network
interface so use systemd's timesyncd as we already build it.

timesyncd is automatically configured to use the NTP servers provided
by kernel ip config, if they are missing the default fallback NTP
servers (currently the ones from Google) are used.

Users can also provide timesyncd configuration files via
/storage/.config/timesyncd.conf.d/ eg to change the (fallback) servers.

Signed-off-by: Matthias Reichl <hias@horus.com>
2019-11-15 18:54:04 +01:00

23 lines
552 B
Bash
Executable File

#!/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