From 44a052accb95ef2e26b882b1264441796222f1c6 Mon Sep 17 00:00:00 2001
From: Emanuel Haupt <ehaupt@FreeBSD.org>
Date: Wed, 1 Apr 2009 17:47:22 +0000
Subject: [PATCH] Provide an rc_subr script

PR:		133267
Submitted by:	Alexander Logvinov <ports@logvinov.com>
---
 sysutils/watchfolder/Makefile        |  2 ++
 sysutils/watchfolder/files/watchd.in | 29 ++++++++++++++++++++++++++++
 2 files changed, 31 insertions(+)
 create mode 100644 sysutils/watchfolder/files/watchd.in

diff --git a/sysutils/watchfolder/Makefile b/sysutils/watchfolder/Makefile
index ca4659a9d292..71e4f7df4a90 100644
--- a/sysutils/watchfolder/Makefile
+++ b/sysutils/watchfolder/Makefile
@@ -7,6 +7,7 @@
 
 PORTNAME=	watchfolder
 PORTVERSION=	0.3.3
+PORTREVISION=	1
 CATEGORIES=	sysutils
 MASTER_SITES=	http://dstunrea.sdf-eu.org/files/ \
 		CRITICAL
@@ -17,6 +18,7 @@ COMMENT=	Watch folders for new files and process them
 MAKE_JOBS_SAFE=	yes
 
 WRKSRC=		${WRKDIR}/watchd-${PORTVERSION}
+USE_RC_SUBR=	watchd
 
 post-patch:
 	@${REINPLACE_CMD} -e 's|gcc $$(OPT)|${CC} ${CFLAGS}|' \
diff --git a/sysutils/watchfolder/files/watchd.in b/sysutils/watchfolder/files/watchd.in
new file mode 100644
index 000000000000..b8c0156d44d7
--- /dev/null
+++ b/sysutils/watchfolder/files/watchd.in
@@ -0,0 +1,29 @@
+#!/bin/sh
+#
+# $FreeBSD$
+#
+# PROVIDE: watchd
+# REQUIRE: DAEMON
+# KEYWORD: shutdown
+#
+# Add the following line to /etc/rc.conf[.local] to enable watchd
+#
+# watchd_enable (bool):		Set to "NO" by default.
+#                               Set it to "YES" to enable watchd.
+
+. %%RC_SUBR%%
+
+name="watchd"
+rcvar=${name}_enable
+
+load_rc_config $name
+
+: ${watchd_enable="NO"}
+: ${watchd_config="%%PREFIX%%/etc/watchd.conf"}
+: ${watchd_log="/var/log/watchd.log"}
+
+command="%%PREFIX%%/bin/watchd"
+command_args="${watchd_config} >> ${watchd_log}"
+required_files="${watchd_config}"
+
+run_rc_command "$1"