From 59a02c294a843f09140a5991e9a331fec66479a8 Mon Sep 17 00:00:00 2001 From: Julien Cristau Date: Sun, 17 May 2015 16:30:05 +0200 Subject: [PATCH] ship /etc/init.d/ntp Will let us patch it to try and fix restart under systemd Signed-off-by: Julien Cristau --- modules/ntp/files/ntp.init | 92 +++++++++++++++++++++++++++++++++++ modules/ntp/manifests/init.pp | 5 ++ 2 files changed, 97 insertions(+) create mode 100755 modules/ntp/files/ntp.init diff --git a/modules/ntp/files/ntp.init b/modules/ntp/files/ntp.init new file mode 100755 index 00000000..3a5ccc5d --- /dev/null +++ b/modules/ntp/files/ntp.init @@ -0,0 +1,92 @@ +#!/bin/sh + +### BEGIN INIT INFO +# Provides: ntp +# Required-Start: $network $remote_fs $syslog +# Required-Stop: $network $remote_fs $syslog +# Default-Start: 2 3 4 5 +# Default-Stop: +# Short-Description: Start NTP daemon +### END INIT INFO + +PATH=/sbin:/bin:/usr/sbin:/usr/bin + +. /lib/lsb/init-functions + +DAEMON=/usr/sbin/ntpd +PIDFILE=/var/run/ntpd.pid + +test -x $DAEMON || exit 5 + +if [ -r /etc/default/ntp ]; then + . /etc/default/ntp +fi + +if [ -e /var/lib/ntp/ntp.conf.dhcp ]; then + NTPD_OPTS="$NTPD_OPTS -c /var/lib/ntp/ntp.conf.dhcp" +fi + + +LOCKFILE=/var/lock/ntpdate + +lock_ntpdate() { + if [ -x /usr/bin/lockfile-create ]; then + lockfile-create $LOCKFILE + lockfile-touch $LOCKFILE & + LOCKTOUCHPID="$!" + fi +} + +unlock_ntpdate() { + if [ -x /usr/bin/lockfile-create ] ; then + kill $LOCKTOUCHPID + lockfile-remove $LOCKFILE + fi +} + +RUNASUSER=ntp +UGID=$(getent passwd $RUNASUSER | cut -f 3,4 -d:) || true +if test "$(uname -s)" = "Linux"; then + NTPD_OPTS="$NTPD_OPTS -u $UGID" +fi + +case $1 in + start) + log_daemon_msg "Starting NTP server" "ntpd" + if [ -z "$UGID" ]; then + log_failure_msg "user \"$RUNASUSER\" does not exist" + exit 1 + fi + lock_ntpdate + start-stop-daemon --start --quiet --oknodo --pidfile $PIDFILE --startas $DAEMON -- -p $PIDFILE $NTPD_OPTS + status=$? + unlock_ntpdate + log_end_msg $status + ;; + stop) + log_daemon_msg "Stopping NTP server" "ntpd" + start-stop-daemon --stop --quiet --oknodo --pidfile $PIDFILE + log_end_msg $? + rm -f $PIDFILE + ;; + restart|force-reload) + $0 stop && sleep 2 && $0 start + ;; + try-restart) + if $0 status >/dev/null; then + $0 restart + else + exit 0 + fi + ;; + reload) + exit 3 + ;; + status) + status_of_proc $DAEMON "NTP server" + ;; + *) + echo "Usage: $0 {start|stop|restart|try-restart|force-reload|status}" + exit 2 + ;; +esac diff --git a/modules/ntp/manifests/init.pp b/modules/ntp/manifests/init.pp index 35f0669d..751e9d96 100644 --- a/modules/ntp/manifests/init.pp +++ b/modules/ntp/manifests/init.pp @@ -15,6 +15,11 @@ class ntp { rule => '&SERVICE(udp, 123)' } + file { '/etc/init.d/ntp': + source => 'puppet:///modules/ntp/ntp.init', + mode => '0555', + notify => Exec['systemctl daemon-reload'], + } file { '/var/lib/ntp': ensure => directory, owner => ntp, -- 2.39.2