diff options
| -rw-r--r-- | PKGBUILD | 6 | ||||
| -rw-r--r-- | chronyd.confd | 4 | ||||
| -rw-r--r-- | chronyd.initd | 68 | 
3 files changed, 67 insertions, 11 deletions
@@ -9,7 +9,7 @@  # Gentoo version just doesn't work properly  pkgname=chrony-openrc -pkgver=20181217 +pkgver=20190120  pkgrel=1  pkgdesc="OpenRC chronyd init script"  arch=('any') @@ -21,8 +21,8 @@ conflicts=('ntp' 'ntp-openrc')  backup=('etc/conf.d/chronyd')  source=("chronyd.initd"          "chronyd.confd") -sha256sums=('07395f2511f242740555403d8c28ae019dee53cb0eda71a7d78cd05ef703820f' -            'da63f49466574cd3d63ffda3176128e62c7de3549dd7f2f5ff33b4662f7dcbb4') +sha256sums=('e8e014f125a7a8000179e9fad2aad12d4707805bb49dbf702ed4f635b620d946' +            'b3d56d7e8a1b5a6a9de5e89a86523b62b292ecca5c95e7ca74f17ffdf2779462')  pkgver() {      date +%Y%m%d diff --git a/chronyd.confd b/chronyd.confd index f4cae7a..c2e3058 100644 --- a/chronyd.confd +++ b/chronyd.confd @@ -1,5 +1,7 @@  # /etc/conf.d/chronyd +CFGFILE="/etc/chrony/chrony.conf" +  # Configuration dependant options :  #      -s - Set system time from RTC if rtcfile directive present  #      -r - Reload sample histories if dumponexit directive present @@ -7,4 +9,4 @@  # The combination of "-s -r" allows chronyd to perform long term averaging of  # the gain or loss rate across system reboots and shutdowns. -CHRONY_ARGS="-4 -u chrony -f /etc/chrony.conf" +ARGS="-4 -u chrony" diff --git a/chronyd.initd b/chronyd.initd index 0b50a5a..3cca402 100644 --- a/chronyd.initd +++ b/chronyd.initd @@ -2,16 +2,70 @@  # Copyright 1999-2013 Gentoo Foundation  # Distributed under the terms of the GNU General Public License v2 -command="/usr/bin/chronyd" -command_args="${CHRONY_ARGS}" -pidfile="/run/${RC_SVCNAME}.pid" -start_stop_daemon_args="--background --make-pidfile" -  depend() {      need net  	use logger dns  } -stop_pre() { -        pkill -u chrony +checkconfig() { +	# Note that /etc/chrony/chrony.keys is *NOT* checked. This +	# is because the user may have specified another key +	# file, and we don't want to force the user to use that +	# exact name for the key file. +	if [ ! -f "${CFGFILE}" ] ; then +		eerror "Please create ${CFGFILE} and the" +		eerror "chrony key file (usually /etc/chrony/chrony.keys)" +		eerror "by using the" +		eerror "" +		eerror "        chrony.conf.example" +		eerror "        chrony.keys.example" +		eerror "" +		eerror "files (from the documentation directory)" +		eerror "as templates." +		return 1 +	else +		# Actually, I tried it, and chrony seems to ignore the pidfile +		# option. I'm going to leave it here anyway, since you never +		# know if it might be handy +		PIDFILE=`awk '/^ *pidfile/{print $2}' "${CFGFILE}"` +		[ -z "${PIDFILE}" ] && PIDFILE=/run/chrony/chronyd.pid +	fi +	return 0 +} + +setxtrarg() { +	if [ -c /dev/rtc ]; then +		grep -q '^rtcfile' "${CFGFILE}" && ARGS="${ARGS} -s" +	fi +	grep -q '^dumponexit$' "${CFGFILE}" && ARGS="${ARGS} -r" +	return 0 +} + +start() { +	checkconfig || return $? +	setxtrarg + +	[ -n "${PIDFILE}" ] || PIDFILE=/run/chronyd.pid + +	ebegin "Starting chronyd" +	start-stop-daemon \ +		--start \ +		--quiet \ +		--exec /usr/bin/chronyd \ +		--pidfile "${PIDFILE}" \ +		-- -f "${CFGFILE}" ${ARGS} +	eend $? "Failed to start chronyd" +} + +stop() { +	checkconfig || return $? + +	[ -n "${PIDFILE}" ] || PIDFILE=/run/chronyd.pid + +	ebegin "Stopping chronyd" +	start-stop-daemon \ +		--stop \ +		--quiet \ +		--pidfile "${PIDFILE}" +	eend $? "Failed to stop chronyd"  }  | 
