From 30f14e212cb62026b17b43cdda24587c570aff72 Mon Sep 17 00:00:00 2001 From: Javier Jardon Date: Fri, 17 Apr 2015 15:49:26 +0100 Subject: ntpd: Set default .service and conf file in the morphology file So we can avoid an specific extension to introduce it in the system Change-Id: I57f446977e3e5fba5fe98be6fdd6a3f150623f14 --- ntpd.configure | 54 --------------------------------------- strata/ntpd/ntpd.morph | 41 +++++++++++++++++++++++++++++ swift/etc/ntp.conf | 4 +++ swift/manifest | 2 +- systems/swift-system-x86_64.morph | 1 - 5 files changed, 46 insertions(+), 56 deletions(-) delete mode 100644 ntpd.configure diff --git a/ntpd.configure b/ntpd.configure deleted file mode 100644 index fd39d9e9..00000000 --- a/ntpd.configure +++ /dev/null @@ -1,54 +0,0 @@ -#!/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" diff --git a/strata/ntpd/ntpd.morph b/strata/ntpd/ntpd.morph index fd561de1..49316c14 100644 --- a/strata/ntpd/ntpd.morph +++ b/strata/ntpd/ntpd.morph @@ -3,6 +3,47 @@ kind: chunk build-system: autotools configure-commands: - ./configure --prefix="$PREFIX" --enable-linuxcaps +post-install-commands: +- | + cat > ntpd.service << EOF + [Unit] + Description=Network Time Service + After=network.target nss-lookup.target + Conflicts=systemd-timesyncd.service + + [Service] + Type=forking + ExecStart=/usr/bin/ntpd -u ntp:ntp + PrivateTmp=True + Restart=on-failure + + [Install] + WantedBy=multi-user.target + EOF +- install -D -m 644 ntpd.service "$DESTDIR"/lib/systemd/system/ntpd.service +- mkdir -p "$DESTDIR"/lib/systemd/system/multi-user.target.wants +- ln -s /lib/systemd/system/ntpd.service "$DESTDIR"/lib/systemd/system/multi-user.target.wants/ntpd.service +- | + cat > ntp.conf << EOF + # We use iburst here to reduce the potential initial delay to set the clock + server 0.pool.ntp.org iburst + server 1.pool.ntp.org iburst + server 2.pool.ntp.org iburst + server 3.pool.ntp.org iburst + + # kod - notify client when packets are denied service, + # rather than just dropping the packets + # + # nomodify - deny queries which attempt to modify the state of the server + # + # notrap - decline to provide mode 6 control message trap service to + # matching hosts + # + # see ntp.conf(5) for more details + restrict -4 default kod notrap nomodify + restrict -6 default kod notrap nomodify + EOF +- install -D -m 644 ntp.conf "$DESTDIR"/etc/ntp.conf system-integration: ntpd-misc: 00-add-ntpd-user: diff --git a/swift/etc/ntp.conf b/swift/etc/ntp.conf index b50886a4..54522871 100644 --- a/swift/etc/ntp.conf +++ b/swift/etc/ntp.conf @@ -19,3 +19,7 @@ server 3.pool.ntp.org iburst restrict -4 default kod notrap nomodify restrict -6 default kod notrap nomodify {% endif %} + +# The default rlimit isn't enough in some cases +# so we set a higher limit here +rlimit memlock 256 diff --git a/swift/manifest b/swift/manifest index 63ea2c2c..7fd76206 100644 --- a/swift/manifest +++ b/swift/manifest @@ -11,5 +11,5 @@ 0100644 0 0 /usr/share/swift/etc/rsyncd.j2 0100644 0 0 /usr/lib/systemd/system/swift-storage-setup.service 0100644 0 0 /usr/lib/systemd/system/swift-storage.service -template 0100644 0 0 /etc/ntp.conf +template overwrite 0100644 0 0 /etc/ntp.conf overwrite 0100644 0 0 /usr/lib/systemd/system/rsync.service diff --git a/systems/swift-system-x86_64.morph b/systems/swift-system-x86_64.morph index 385f9cd5..442c2609 100644 --- a/systems/swift-system-x86_64.morph +++ b/systems/swift-system-x86_64.morph @@ -31,4 +31,3 @@ configuration-extensions: - install-files - fstab - swift-storage -- ntpd -- cgit v1.2.1