summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjc_gargma <jc_gargma@iserlohn-fortress.net>2018-07-14 11:20:45 -0700
committerjc_gargma <jc_gargma@iserlohn-fortress.net>2018-07-14 11:20:45 -0700
commitf1412dd728712115da07f682a83cad691a8de70d (patch)
treeb92876cb110fe8ccc1d5f0352bb0d739ba56f420
downloadchrony-openrc-f1412dd728712115da07f682a83cad691a8de70d.tar.xz
Initial commit
-rw-r--r--PKGBUILD41
-rw-r--r--chronyd.confd12
-rw-r--r--chronyd.initd70
3 files changed, 123 insertions, 0 deletions
diff --git a/PKGBUILD b/PKGBUILD
new file mode 100644
index 0000000..c2beb02
--- /dev/null
+++ b/PKGBUILD
@@ -0,0 +1,41 @@
+# Maintainer: artoo <artoo@artixlinux.org>
+
+_url="https://raw.githubusercontent.com/gentoo/gentoo/master"
+
+pkgname=chrony-openrc
+pkgver=20180712
+pkgrel=2
+pkgdesc="OpenRC chronyd init script"
+arch=('any')
+url="https://github.com/artix-linux/packages"
+license=('GPL2')
+groups=('openrc-system')
+depends=('openrc' 'chrony')
+conflicts=('ntp' 'ntp-openrc')
+backup=('etc/init.d/chronyd')
+source=("chronyd.initd"
+ "chronyd.confd")
+sha256sums=('3048e489bb9d8381ef386b903472ea65da19b12fea6ee2934bde515e2a24ed6d'
+ '7997a9453e030d18342937e4aa923eb541b9cee4450660f332aa5ba3eebfaca4')
+
+pkgver() {
+ date +%Y%m%d
+}
+
+_inst_initd(){
+ install -Dm755 ${srcdir}/$1.initd ${pkgdir}/etc/init.d/$1
+
+ sed -e 's|/var/run|/run|g' \
+ -e 's|#!/sbin/openrc-run|#!/usr/bin/openrc-run|g' \
+ -e 's|/usr/sbin|/usr/bin|g' \
+ -i ${pkgdir}/etc/init.d/$1
+}
+
+_inst_confd(){
+ install -Dm755 ${srcdir}/$1.confd ${pkgdir}/etc/conf.d/$1
+}
+
+package() {
+ _inst_initd 'chronyd'
+ _inst_confd 'chronyd'
+}
diff --git a/chronyd.confd b/chronyd.confd
new file mode 100644
index 0000000..37653bc
--- /dev/null
+++ b/chronyd.confd
@@ -0,0 +1,12 @@
+# /etc/conf.d/chronyd
+
+CFGFILE="/etc/chrony.conf"
+
+# Configuration dependant options :
+# -s - Set system time from RTC if rtcfile directive present
+# -r - Reload sample histories if dumponexit directive present
+#
+# The combination of "-s -r" allows chronyd to perform long term averaging of
+# the gain or loss rate across system reboots and shutdowns.
+
+ARGS="-4 -u chrony"
diff --git a/chronyd.initd b/chronyd.initd
new file mode 100644
index 0000000..d27d27e
--- /dev/null
+++ b/chronyd.initd
@@ -0,0 +1,70 @@
+#!/sbin/openrc-run
+# Copyright 1999-2013 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+depend() {
+ need net
+ use logger dns
+}
+
+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}"`
+ 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/sbin/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"
+}