From 7b503f884ef65ac44b3cf9f009391f45621880fa Mon Sep 17 00:00:00 2001 From: Richard Ipsum Date: Mon, 13 Apr 2015 19:25:09 +0000 Subject: Add ntp configure extension Change-Id: If7926bc7ed11d966feca2aa9ef767dc29996729e --- ntpd.configure | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 ntpd.configure diff --git a/ntpd.configure b/ntpd.configure new file mode 100644 index 00000000..fd39d9e9 --- /dev/null +++ b/ntpd.configure @@ -0,0 +1,54 @@ +#!/bin/bash +# +# Copyright © 2015 Codethink Limited +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program. If not, see . + + +set -e + +ROOT="$1" + +# NTP conflicts with systemd-timesyncd, +# so if we want to use NTP then we need to disable systemd-timesyncd +rm "$ROOT/etc/systemd/system/sysinit.target.wants/systemd-timesyncd.service" + +# On at least x86 64 the default rlimit +# ntp sets (32kB) isn't enough, so increase it +cat >> "$ROOT/etc/ntp.conf" << EOF + +# The default rlimit isn't enough in some cases +# so we set a higher limit here +rlimit memlock 256 +EOF + +NTPD_PIDFILE=/run/ntpd.pid +cat > "$ROOT/usr/lib/systemd/system/ntpd.service" << EOF +[Unit] +Description=Network Time Service +After=network.target nss-lookup.target +Conflicts=systemd-timesyncd.service + +[Service] +Type=forking +PIDFile=$NTPD_PIDFILE +ExecStart=/usr/bin/ntpd -u ntp:ntp -p $NTPD_PIDFILE +PrivateTmp=True +Restart=on-failure + +[Install] +WantedBy=multi-user.target +EOF + +ln -s "/usr/lib/systemd/system/ntpd.service" \ + "$ROOT/usr/lib/systemd/system/multi-user.target.wants/ntpd.service" -- cgit v1.2.1