1
0
mirror of https://git.FreeBSD.org/ports.git synced 2024-10-18 19:49:40 +00:00

- 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
This commit is contained in:
Jason Helfman 2019-08-28 16:02:00 +00:00
parent 3d824592bd
commit 0adf8c88e5
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=510076
2 changed files with 17 additions and 21 deletions

View File

@ -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/

View File

@ -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
name=htpdate
desc="HTTP Time Protocol daemon"
rcvar=htpdate_enable
load_rc_config htpdate
htpdate_enable="${htpdate_enable:-"NO"}"
htpdate_servers="${htpdate_servers:-"www.example.com"}"
htpdate_flags="${htpdate_flags:-"-l -s -D"}"
: ${htpdate_enable:="NO"}
: ${htpdate_servers:="www.example.com"}
: ${htpdate_flags:="-l -s -D"}
name=htpdate
rcvar=htpdate_enable
servers=${htpdate_servers}
pidfile=/var/run/htpdate.pid
start_precmd=htpdate_prestart
command="%%PREFIX%%/bin/htpdate"
command_args="${htpdate_servers}"
command="/usr/local/bin/htpdate"
command_args="${htpdate_flags} $servers"
stop_cmd=htpdate_stop
htpdate_stop ()
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"