From c9c8d13afb0c75bf00644a2afcb94c6f1cf9adb3 Mon Sep 17 00:00:00 2001 From: Roy Marples Date: Fri, 7 Mar 2014 14:29:52 +0000 Subject: [PATCH] Detect OpenBSD rc system (check instead of status). If ntpd.conf exists but ntp.conf does not, configure ntpd.conf instead. --- dhcpcd-hooks/50-ntp.conf | 13 +++++++++++-- dhcpcd-run-hooks.in | 2 ++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/dhcpcd-hooks/50-ntp.conf b/dhcpcd-hooks/50-ntp.conf index c0781360..4b1284cc 100644 --- a/dhcpcd-hooks/50-ntp.conf +++ b/dhcpcd-hooks/50-ntp.conf @@ -6,7 +6,7 @@ # dhcpcd -e NTP_CONF=/usr/pkg/etc/ntpd.conf # or by adding this to /etc/dhcpcd.enter-hook # NTP_CONF=/usr/pkg/etc/ntpd.conf -# to use openntpd from pkgsrc instead of the system provided ntp. +# to use OpenNTPD instead of the default NTP. if type invoke-rc.d >/dev/null 2>&1; then # Debian has a seperate file for DHCP config to avoid stamping on @@ -19,7 +19,16 @@ fi : ${ntp_service:=ntpd} : ${ntp_restart_cmd:=service_condcommand $ntp_service restart} ntp_conf_dir="$state_dir/ntp.conf" -ntp_conf=${NTP_CONF:-/etc/ntp.conf} + +# If we have installed OpenNTPD but not NTP then prefer it +# XXX If both exist then update both? +if [ -z "$NTP_CONF" -a -e /etc/ntpd.conf -a ! -e /etc/ntp.conf ]; then + : ${NTP_CONF:=/etc/ntpd.conf} +else + : ${NTP_CONF:=/etc/ntp.conf} +fi + +ntp_conf=${NTP_CONF} NL=" " diff --git a/dhcpcd-run-hooks.in b/dhcpcd-run-hooks.in index ccefc1b6..365becf5 100644 --- a/dhcpcd-run-hooks.in +++ b/dhcpcd-run-hooks.in @@ -264,6 +264,8 @@ detect_init() done if [ -e /etc/arch-release ]; then _service_status="[ -e /var/run/daemons/\$1 ]" + elif [ "$x" = "/etc/rc.d" -a -e /etc/rc.d/rc.subr ]; then + _service_status="$x/\$1 check 1>/dev/null 2>&1" fi fi -- 2.47.3