summaryrefslogtreecommitdiff
path: root/user/chrony/chronyd.initd
diff options
context:
space:
mode:
authorDan Theisen <djt@hxx.in>2018-06-26 04:28:07 -0700
committerDan Theisen <djt@hxx.in>2018-06-26 18:44:39 -0700
commitb00cda0fc4fbeb6c64801e8180c2a2feeb288766 (patch)
tree8f376def6b56eebebfbefb2208118925b4001622 /user/chrony/chronyd.initd
parent586c518d3cdca10f7c83ca73efd2a41a1f295d4a (diff)
downloadpackages-b00cda0fc4fbeb6c64801e8180c2a2feeb288766.tar.gz
packages-b00cda0fc4fbeb6c64801e8180c2a2feeb288766.tar.bz2
packages-b00cda0fc4fbeb6c64801e8180c2a2feeb288766.tar.xz
packages-b00cda0fc4fbeb6c64801e8180c2a2feeb288766.zip
user/chrony: new package, import from alpine, clean up
Diffstat (limited to 'user/chrony/chronyd.initd')
-rw-r--r--user/chrony/chronyd.initd71
1 files changed, 71 insertions, 0 deletions
diff --git a/user/chrony/chronyd.initd b/user/chrony/chronyd.initd
new file mode 100644
index 000000000..771bb5b53
--- /dev/null
+++ b/user/chrony/chronyd.initd
@@ -0,0 +1,71 @@
+#!/sbin/openrc-run
+# Copyright 1999-2007 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/net-misc/chrony/files/chronyd.rc,v 1.8 2007/03/22 14:32:09 tove Exp $
+
+description="NTP daemon"
+
+depend() {
+ need net
+ after firewall
+ provide ntp-client ntp-server
+ use 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=/var/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=/var/run/chronyd.pid
+
+ ebegin "Stopping chronyd"
+ start-stop-daemon --stop --quiet \
+ --pidfile "${PIDFILE}"
+ eend $? "Failed to stop chronyd"
+}