From feld@feld.me  Wed May 22 15:32:57 2013
Return-Path: <feld@feld.me>
Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115])
	by hub.freebsd.org (Postfix) with ESMTP id 9EF47181
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 22 May 2013 15:32:57 +0000 (UTC)
	(envelope-from feld@feld.me)
Received: from smtp.supranet.net (smtp.supranet.net [IPv6:2607:f4e0:100:111::10])
	by mx1.freebsd.org (Postfix) with ESMTP id 4EE31E4F
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 22 May 2013 15:32:56 +0000 (UTC)
Received: from mwi1.coffeenet.org (feld.me [66.170.3.2])
	by smtp.supranet.net (Postfix) with ESMTP id A8DFB10EFE5
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 22 May 2013 10:32:53 -0500 (CDT)
Received: from localhost (1000@localhost [local]);
	by mwi1.coffeenet.org (OpenSMTPD) with ESMTP id c50e7e12;
	for <FreeBSD-gnats-submit@freebsd.org>;
	Wed, 22 May 2013 10:32:51 -0500 (CDT)
Message-Id: <3046546331.enqueue@mwi1.coffeenet.org>
Date: Wed, 22 May 2013 10:32:51 -0500 (CDT)
From: Mark Felder <feld@feld.me>
To: FreeBSD-gnats-submit@freebsd.org
Subject: [PATCH] net-mgmt/devmon: polish port
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         178834
>Category:       ports
>Synopsis:       [PATCH] net-mgmt/devmon: polish port
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    swills
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          maintainer-update
>Submitter-Id:   current-users
>Arrival-Date:   Wed May 22 15:40:00 UTC 2013
>Closed-Date:    Mon May 27 02:30:27 UTC 2013
>Last-Modified:  Mon May 27 02:40:00 UTC 2013
>Originator:     feld
>Release:        FreeBSD 9.1-RELEASE amd64
>Organization:
>Environment:
System: FreeBSD mwi1.coffeenet.org 9.1-RELEASE FreeBSD 9.1-RELEASE #6 r243808: Mon Dec  3 07:51:34
>Description:
Port polishing to fix some issues

-rc script passes rclint
-daemon runs as its own user

UIDs
devmon:*:283:283::0:0:devmon monitor:/nonexistent:/usr/sbin/nologin

GIDs
devmon:*:283:

Generated with FreeBSD Port Tools 0.99_7 (mode: change, diff: ports)
>How-To-Repeat:
>Fix:

--- devmon-0.3.1.b1_1.patch begins here ---
diff -ruN /usr/ports/net-mgmt/devmon/Makefile ./Makefile
--- /usr/ports/net-mgmt/devmon/Makefile	2013-03-02 14:20:12.000000000 -0600
+++ ./Makefile	2013-05-22 10:25:57.339578498 -0500
@@ -3,6 +3,7 @@
 
 PORTNAME=	devmon
 DISTVERSION=	0.3.1-beta1
+PORTREVISION=	1
 CATEGORIES=	net-mgmt
 MASTER_SITES=	SF/${PORTNAME}/${PORTNAME}/${DISTVERSION}
 
@@ -17,6 +18,12 @@
 NO_BUILD=	yes
 USE_RC_SUBR=	devmon
 
+USERS=	devmon
+GROUPS=	devmon
+
+SUB_LIST=	USERS=${USERS} \
+		GROUPS=${GROUPS}
+
 OPTIONS_DEFINE=	MYSQL
 
 .include <bsd.port.options.mk>
@@ -43,6 +50,7 @@
 	${INSTALL_DATA} ${WRKSRC}/README ${DOCSDIR}/
 	${INSTALL} -d ${DOCSDIR}/docs
 	${INSTALL} -d ${DOCSDIR}/extras
+	${INSTALL} -d -o ${USERS} -g ${GROUPS} /var/run/devmon
 	(cd ${WRKSRC}/docs && ${COPYTREE_SHARE} \* ${DOCSDIR}/docs/)
 	(cd ${WRKSRC}/extras && ${COPYTREE_SHARE} \* ${DOCSDIR}/extras/)
 .endif
diff -ruN /usr/ports/net-mgmt/devmon/files/devmon.in ./files/devmon.in
--- /usr/ports/net-mgmt/devmon/files/devmon.in	2013-03-02 14:20:12.000000000 -0600
+++ ./files/devmon.in	2013-05-22 10:22:57.939621835 -0500
@@ -1,56 +1,88 @@
 #!/bin/sh
 # $FreeBSD: net-mgmt/devmon/files/devmon.in 313295 2013-03-02 20:20:12Z swills $
-
 # PROVIDE: devmon
 # REQUIRE: LOGIN
 # KEYWORD: shutdown
 
-: ${devmon_enable="NO"}
+. /etc/rc.subr
+
+name=devmon
+rcvar=devmon_enable
+load_rc_config ${name}
+
+: ${devmon_enable:=NO}
 : ${devmon_config="%%PREFIX%%/devmon/devmon.cfg"}
 : ${devmon_db="%%PREFIX%%/devmon/hosts.db"}
-: ${devmon_pid="/var/run/devmon.pid"}
+: ${devmon_pid="/var/run/devmon/devmon.pid"}
+: ${devmon_user="%%USERS%%"}
+: ${devmon_group="%%GROUPS%%"}
 
-. /etc/rc.subr
-
-name="devmon"
-rcvar="devmon_enable"
-load_rc_config $name
 command="%%PREFIX%%/devmon/devmon"
 command_args="-c ${devmon_config} -d ${devmon_db}"
-command_interpreter="/usr/bin/perl"
+command_interpreter=/usr/bin/perl
 pidfile=${devmon_pid}
 
-stop_cmd="devmon_stopcmd"
-status_cmd="devmon_statuscmd"
+start_precmd=devmon_startprecmd
+status_cmd=devmon_statuscmd
+stop_cmd=devmon_stopcmd
+
+devmon_startprecmd()
+{
+	if [ ! -e ${devmon_config} ];
+		then
+		echo "Error: ${devmon_config} does not exist."
+	exit 1;
+	fi
+
+	TEMPLATESDIR=%%PREFIX%%/devmon/templates
+	if [ ! -e ${TEMPLATESDIR} ]
+		then
+		echo ""
+		echo "  ERROR: no templates exist. Please install device templates"
+		echo "  to: ${TEMPLATESDIR}"
+		echo "  They are available on the devmon SourceForge page via SVN."
+		echo "  Note, the older template tarballs do not work reliably."
+		echo ""
+		echo "  # svn co svn://svn.code.sf.net/p/devmon/code/trunk/templates ${TEMPLATESDIR}"
+		echo ""
+	exit 1;
+	fi
+
+	DEVMONLOG=$(grep "^LOGFILE=" ${devmon_config} | awk -F '=' '{print $2}')
+	if [ ! -e ${DEVMONLOG} ];
+		then
+		install -o devmon -g devmon /dev/null ${DEVMONLOG}
+	fi
+}
 
-devmon_statuscmd()                                                                                                                                                              
+devmon_statuscmd()
 {
-if [ ! -e $pidfile ];                                                                                                                                                      
-    then
-        echo "pidfile does not exist. $name is not running?";
-    exit 1;
-fi
-
-if pgrep -F $pidfile >/dev/null;
-    then
-        echo "$name is running.";
-    else
-        echo "$name is not running.";
-    exit 1;
-fi
+	if [ ! -e ${pidfile} ];
+		then
+		echo "pidfile does not exist. ${name} is not running?";
+	exit 1;
+	fi
+
+	if pgrep -F ${pidfile} >/dev/null;
+		then
+		echo "${name} is running.";
+	else
+		echo "${name} is not running.";
+	exit 1;
+	fi
 }
 
 devmon_stopcmd()
 {
-if pgrep -F $pidfile >/dev/null;
-    then
-	mypid=`cat $pidfile`;
-        kill $sig_stop $mypid;
-        wait_for_pids $mypid;
-    else
-        echo "$name is not running.";
-        exit 1;
-fi
+	if pgrep -F ${pidfile} >/dev/null;
+		then
+		mypid=`cat ${pidfile}`;
+		kill ${sig_stop} ${mypid};
+		wait_for_pids ${mypid};
+	else
+		echo "${name} is not running.";
+	exit 1;
+	fi
 }
 
 run_rc_command "$1"
diff -ruN /usr/ports/net-mgmt/devmon/pkg-plist ./pkg-plist
--- /usr/ports/net-mgmt/devmon/pkg-plist	2013-03-02 14:20:12.000000000 -0600
+++ ./pkg-plist	2013-05-22 10:28:32.667682107 -0500
@@ -24,7 +24,8 @@
 %%PORTDOCS%%%%DOCSDIR%%/COPYING
 %%PORTDOCS%%%%DOCSDIR%%/CHANGELOG
 @dirrm devmon/modules
-@dirrm devmon
+@dirrmtry devmon
+@dirrmtry /var/run/devmon
 %%PORTDOCS%%@dirrm %%DOCSDIR%%/extras
 %%PORTDOCS%%@dirrm %%DOCSDIR%%/docs
 %%PORTDOCS%%@dirrm %%DOCSDIR%%
--- devmon-0.3.1.b1_1.patch ends here ---

>Release-Note:
>Audit-Trail:
Class-Changed-From-To: change-request->maintainer-update 
Class-Changed-By: edwin 
Class-Changed-When: Wed May 22 15:40:09 UTC 2013 
Class-Changed-Why:  
Fix category (submitter is maintainer) (via the GNATS Auto Assign Tool) 

http://www.freebsd.org/cgi/query-pr.cgi?pr=178834 
Responsible-Changed-From-To: freebsd-ports-bugs->swills 
Responsible-Changed-By: edwin 
Responsible-Changed-When: Wed May 22 15:40:11 UTC 2013 
Responsible-Changed-Why:  
swills@ wants this submitter's PRs (via the GNATS Auto Assign Tool) 

http://www.freebsd.org/cgi/query-pr.cgi?pr=178834 
State-Changed-From-To: open->closed 
State-Changed-By: swills 
State-Changed-When: Mon May 27 02:30:23 UTC 2013 
State-Changed-Why:  
Committed. Thanks! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=178834 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: ports/178834: commit references a PR
Date: Mon, 27 May 2013 02:29:58 +0000 (UTC)

 Author: swills
 Date: Mon May 27 02:29:49 2013
 New Revision: 319151
 URL: http://svnweb.freebsd.org/changeset/ports/319151
 
 Log:
   - rc script passes rclint
   - Runs as its own user
   - Switch to @unexec rmdir since portlint warns about absolute path in @dirrmtry
     not working
   
   PR:		ports/178834
   Submitted by:	Mark Felder <feld@feld.me> (maintainer)
 
 Modified:
   head/GIDs
   head/UIDs
   head/net-mgmt/devmon/Makefile
   head/net-mgmt/devmon/files/devmon.in   (contents, props changed)
   head/net-mgmt/devmon/pkg-plist   (contents, props changed)
 
 Modified: head/GIDs
 ==============================================================================
 --- head/GIDs	Mon May 27 02:16:43 2013	(r319150)
 +++ head/GIDs	Mon May 27 02:29:49 2013	(r319151)
 @@ -134,6 +134,7 @@ mrtg:*:279:
  xymon:*:280:
  prelude:*:281:
  spread:*:282:
 +devmon:*:283:
  backuppc:*:300:
  _sphinx:*:312:
  dkfilter:*:325:
 
 Modified: head/UIDs
 ==============================================================================
 --- head/UIDs	Mon May 27 02:16:43 2013	(r319150)
 +++ head/UIDs	Mon May 27 02:29:49 2013	(r319151)
 @@ -142,6 +142,7 @@ mrtg:*:279:279::0:0:MRTG daemon:/nonexis
  xymon:*:280:280::0:0:Xymon Monitor:/nonexistent:/usr/sbin/nologin
  prelude:*:281:281::0:0:Prelude user:/nonexistent:/usr/sbin/nologin
  spread:*:282:282::0:0:Spread user:/nonexistent:/usr/sbin/nologin
 +devmon:*:283:283::0:0:devmon monitor:/nonexistent:/usr/sbin/nologin
  backuppc:*:300:300::0:0:BackupPC pseudo-user:/nonexistent:/usr/sbin/nologin
  _sphinx:*:312:312::0:0:Sphinxsearch Owner:/nonexistent:/usr/sbin/nologin
  dkfilter:*:325:325::0:0:DK Filter Owner:/nonexistent:/usr/sbin/nologin
 
 Modified: head/net-mgmt/devmon/Makefile
 ==============================================================================
 --- head/net-mgmt/devmon/Makefile	Mon May 27 02:16:43 2013	(r319150)
 +++ head/net-mgmt/devmon/Makefile	Mon May 27 02:29:49 2013	(r319151)
 @@ -3,6 +3,7 @@
  
  PORTNAME=	devmon
  DISTVERSION=	0.3.1-beta1
 +PORTREVISION=	1
  CATEGORIES=	net-mgmt
  MASTER_SITES=	SF/${PORTNAME}/${PORTNAME}/${DISTVERSION}
  
 @@ -17,6 +18,12 @@ USE_PERL5=	yes
  NO_BUILD=	yes
  USE_RC_SUBR=	devmon
  
 +USERS=	devmon
 +GROUPS=	devmon
 +
 +SUB_LIST=	USERS=${USERS} \
 +		GROUPS=${GROUPS}
 +
  OPTIONS_DEFINE=	MYSQL
  
  .include <bsd.port.options.mk>
 @@ -43,6 +50,7 @@ post-install:
  	${INSTALL_DATA} ${WRKSRC}/README ${DOCSDIR}/
  	${INSTALL} -d ${DOCSDIR}/docs
  	${INSTALL} -d ${DOCSDIR}/extras
 +	${INSTALL} -d -o ${USERS} -g ${GROUPS} /var/run/devmon
  	(cd ${WRKSRC}/docs && ${COPYTREE_SHARE} \* ${DOCSDIR}/docs/)
  	(cd ${WRKSRC}/extras && ${COPYTREE_SHARE} \* ${DOCSDIR}/extras/)
  .endif
 
 Modified: head/net-mgmt/devmon/files/devmon.in
 ==============================================================================
 --- head/net-mgmt/devmon/files/devmon.in	Mon May 27 02:16:43 2013	(r319150)
 +++ head/net-mgmt/devmon/files/devmon.in	Mon May 27 02:29:49 2013	(r319151)
 @@ -1,56 +1,88 @@
  #!/bin/sh
  # $FreeBSD$
 -
  # PROVIDE: devmon
  # REQUIRE: LOGIN
  # KEYWORD: shutdown
  
 -: ${devmon_enable="NO"}
 +. /etc/rc.subr
 +
 +name=devmon
 +rcvar=devmon_enable
 +load_rc_config ${name}
 +
 +: ${devmon_enable:=NO}
  : ${devmon_config="%%PREFIX%%/devmon/devmon.cfg"}
  : ${devmon_db="%%PREFIX%%/devmon/hosts.db"}
 -: ${devmon_pid="/var/run/devmon.pid"}
 +: ${devmon_pid="/var/run/devmon/devmon.pid"}
 +: ${devmon_user="%%USERS%%"}
 +: ${devmon_group="%%GROUPS%%"}
  
 -. /etc/rc.subr
 -
 -name="devmon"
 -rcvar="devmon_enable"
 -load_rc_config $name
  command="%%PREFIX%%/devmon/devmon"
  command_args="-c ${devmon_config} -d ${devmon_db}"
 -command_interpreter="/usr/bin/perl"
 +command_interpreter=/usr/bin/perl
  pidfile=${devmon_pid}
  
 -stop_cmd="devmon_stopcmd"
 -status_cmd="devmon_statuscmd"
 +start_precmd=devmon_startprecmd
 +status_cmd=devmon_statuscmd
 +stop_cmd=devmon_stopcmd
 +
 +devmon_startprecmd()
 +{
 +	if [ ! -e ${devmon_config} ];
 +		then
 +		echo "Error: ${devmon_config} does not exist."
 +	exit 1;
 +	fi
 +
 +	TEMPLATESDIR=%%PREFIX%%/devmon/templates
 +	if [ ! -e ${TEMPLATESDIR} ]
 +		then
 +		echo ""
 +		echo "  ERROR: no templates exist. Please install device templates"
 +		echo "  to: ${TEMPLATESDIR}"
 +		echo "  They are available on the devmon SourceForge page via SVN."
 +		echo "  Note, the older template tarballs do not work reliably."
 +		echo ""
 +		echo "  # svn co svn://svn.code.sf.net/p/devmon/code/trunk/templates ${TEMPLATESDIR}"
 +		echo ""
 +	exit 1;
 +	fi
 +
 +	DEVMONLOG=$(grep "^LOGFILE=" ${devmon_config} | awk -F '=' '{print $2}')
 +	if [ ! -e ${DEVMONLOG} ];
 +		then
 +		install -o devmon -g devmon /dev/null ${DEVMONLOG}
 +	fi
 +}
  
 -devmon_statuscmd()                                                                                                                                                              
 +devmon_statuscmd()
  {
 -if [ ! -e $pidfile ];                                                                                                                                                      
 -    then
 -        echo "pidfile does not exist. $name is not running?";
 -    exit 1;
 -fi
 -
 -if pgrep -F $pidfile >/dev/null;
 -    then
 -        echo "$name is running.";
 -    else
 -        echo "$name is not running.";
 -    exit 1;
 -fi
 +	if [ ! -e ${pidfile} ];
 +		then
 +		echo "pidfile does not exist. ${name} is not running?";
 +	exit 1;
 +	fi
 +
 +	if pgrep -F ${pidfile} >/dev/null;
 +		then
 +		echo "${name} is running.";
 +	else
 +		echo "${name} is not running.";
 +	exit 1;
 +	fi
  }
  
  devmon_stopcmd()
  {
 -if pgrep -F $pidfile >/dev/null;
 -    then
 -	mypid=`cat $pidfile`;
 -        kill $sig_stop $mypid;
 -        wait_for_pids $mypid;
 -    else
 -        echo "$name is not running.";
 -        exit 1;
 -fi
 +	if pgrep -F ${pidfile} >/dev/null;
 +		then
 +		mypid=`cat ${pidfile}`;
 +		kill ${sig_stop} ${mypid};
 +		wait_for_pids ${mypid};
 +	else
 +		echo "${name} is not running.";
 +	exit 1;
 +	fi
  }
  
  run_rc_command "$1"
 
 Modified: head/net-mgmt/devmon/pkg-plist
 ==============================================================================
 --- head/net-mgmt/devmon/pkg-plist	Mon May 27 02:16:43 2013	(r319150)
 +++ head/net-mgmt/devmon/pkg-plist	Mon May 27 02:29:49 2013	(r319151)
 @@ -24,7 +24,8 @@ devmon/devmon
  %%PORTDOCS%%%%DOCSDIR%%/COPYING
  %%PORTDOCS%%%%DOCSDIR%%/CHANGELOG
  @dirrm devmon/modules
 -@dirrm devmon
 +@dirrmtry devmon
 +@unexec rmdir /var/run/devmon
  %%PORTDOCS%%@dirrm %%DOCSDIR%%/extras
  %%PORTDOCS%%@dirrm %%DOCSDIR%%/docs
  %%PORTDOCS%%@dirrm %%DOCSDIR%%
 _______________________________________________
 svn-ports-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-ports-all
 To unsubscribe, send any mail to "svn-ports-all-unsubscribe@freebsd.org"
 
>Unformatted:
