Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 28 Aug 2019 16:02:00 +0000 (UTC)
From:      Jason Helfman <jgh@FreeBSD.org>
To:        ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org
Subject:   svn commit: r510076 - in head/net/htpdate: . files
Message-ID:  <201908281602.x7SG20nJ010700@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jgh
Date: Wed Aug 28 16:02:00 2019
New Revision: 510076
URL: https://svnweb.freebsd.org/changeset/ports/510076

Log:
  - fix service script
  
  For some reason the PID written to the pidfile by htpdate does not match its
  actual PID, which renders the standard PID-handling mechanism of rc.subr(8)
  useless.
  
  As a solution, depend only on the process name to figure out the PID of the
  running process.
  
  NB: the old pidfile has to be removed before starting htpdate. Otherwise,
  the program complains about the pidfile already existing (which htpdate
  interprets as another instance of htpdate already running).
  
  Also:
  - Use %%PREFIX%% to let the ports provide a proper path for the binary.
  - Do not specify htpdate_flags in command_args. htpdate_flags are already
    passed to the program by rc.subr(8).
  
  In response to this mailing list thread:
  https://lists.freebsd.org/pipermail/freebsd-rc/2019-August/004047.html
  
  Submitted by:	0mp@
  Differential Revision:	https://reviews.freebsd.org/D21431

Modified:
  head/net/htpdate/Makefile
  head/net/htpdate/files/htpdate.in

Modified: head/net/htpdate/Makefile
==============================================================================
--- head/net/htpdate/Makefile	Wed Aug 28 15:59:59 2019	(r510075)
+++ head/net/htpdate/Makefile	Wed Aug 28 16:02:00 2019	(r510076)
@@ -3,6 +3,7 @@
 
 PORTNAME=	htpdate
 PORTVERSION=	1.2.2
+PORTREVISION=	1
 CATEGORIES=	net ipv6
 MASTER_SITES=	http://www.vervest.org/htp/archive/c/ \
 		http://twekkel.home.xs4all.nl/htp/

Modified: head/net/htpdate/files/htpdate.in
==============================================================================
--- head/net/htpdate/files/htpdate.in	Wed Aug 28 15:59:59 2019	(r510075)
+++ head/net/htpdate/files/htpdate.in	Wed Aug 28 16:02:00 2019	(r510076)
@@ -3,8 +3,7 @@
 # $FreeBSD$
 
 # PROVIDE: htpdate
-# REQUIRE: NETWORKING SERVERS
-# BEFORE: DAEMON
+# REQUIRE: NETWORKING syslogd
 # KEYWORD: shutdown
 
 # Add the following line to /etc/rc.conf to enable htpdate:
@@ -14,31 +13,27 @@
 
 . /etc/rc.subr
 
-load_rc_config htpdate
-
-htpdate_enable="${htpdate_enable:-"NO"}"
-htpdate_servers="${htpdate_servers:-"www.example.com"}"
-htpdate_flags="${htpdate_flags:-"-l -s -D"}"
-
 name=htpdate
+desc="HTTP Time Protocol daemon"
 rcvar=htpdate_enable
-servers=${htpdate_servers}
-pidfile=/var/run/htpdate.pid
 
-command="/usr/local/bin/htpdate"
-command_args="${htpdate_flags} $servers"
-stop_cmd=htpdate_stop
+load_rc_config htpdate
 
-htpdate_stop ()
+: ${htpdate_enable:="NO"}
+: ${htpdate_servers:="www.example.com"}
+: ${htpdate_flags:="-l -s -D"}
+
+start_precmd=htpdate_prestart
+command="%%PREFIX%%/bin/htpdate"
+command_args="${htpdate_servers}"
+
+htpdate_prestart()
 {
-	if [ -f ${pidfile} ]; then
-		echo "Stopping htpdate."
-		kill `cat ${pidfile}`
-	else
-		echo "htpdate is not running."
-	fi
+	local _pidfile="/var/run/htpdate.pid"
 
-	rm -f ${pidfile}
+	if [ -z "$(check_process "${command}")" ]; then
+		rm -f -- "${_pidfile}"
+	fi
 }
 
 run_rc_command "$1"



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201908281602.x7SG20nJ010700>