ports/153162: [MAINTAINER UPDATE] net-mgmt/torrus: 1.0.9 to 1.0.9_1

Corey Smith corsmith at gmail.com
Wed Dec 22 21:21:35 UTC 2010


On Tue, Dec 21, 2010 at 5:15 PM, Corey Smith <corsmith at gmail.com> wrote:
> I will send an updated patch shortly.

Attached is the latest version of the patch that has been converted to
use the USERS/GROUPS macros as well as the GIDs/UIDs diffs.  I also
created FreeBSD style startup script for the collector and monitor.  I
will work with the developer to see if this can be added to the
original project.

Thanks for your help.

-Corey Smith
-------------- next part --------------
diff -urN net-mgmt/torrus-1.0.9/Makefile net-mgmt/torrus/Makefile
--- net-mgmt/torrus-1.0.9/Makefile	2010-11-26 06:16:34.000000000 -0500
+++ net-mgmt/torrus/Makefile	2010-12-22 16:14:09.853386089 -0500
@@ -7,6 +7,7 @@
 
 PORTNAME=	torrus
 PORTVERSION=	1.0.9
+PORTREVISION=	1
 CATEGORIES=	net-mgmt
 MASTER_SITES=	SF
 
@@ -30,12 +31,13 @@
 USE_PERL5_RUN=	5.8.1+
 GNU_CONFIGURE=	YES
 
-TORRUS_USER?=	torrus
-PLIST_SUB=	TORRUS_USER=${TORRUS_USER}
+USERS=		torrus
+GROUPS=		torrus
+PLIST_SUB=	TORRUS_USER=${USERS}
 
 CONFIGURE_ARGS=	--prefix=${PREFIX} \
-		var_user=${TORRUS_USER} var_group=${TORRUS_USER} \
-		torrus_user=${TORRUS_USER} \
+		var_user=${USERS} var_group=${USERS} \
+		torrus_user=${USERS} \
 		defrrddir=/var/torrus/collector_rrd \
 		pkghome=${DATADIR} \
 		pkgbindir=${PREFIX}/libexec/torrus \
@@ -60,18 +62,9 @@
 
 .include <bsd.port.pre.mk>
 
-pre-install:
-	@if ! pw groupshow ${TORRUS_USER}; then \
-		pw groupadd ${TORRUS_USER}; \
-	fi
-	@if ! pw usershow ${TORRUS_USER}; then \
-		pw useradd ${TORRUS_USER} -g ${TORRUS_USER} \
-			-h - -d ${PREFIX}/torrus -c "torrus daemon"; \
-		pw usermod www -G ${TORRUS_USER}; \
-	fi
-
 post-install:
-	${INSTALL_SCRIPT} ${WRKSRC}/init.d/torrus ${PREFIX}/etc/rc.d/torrus.sh
+	${INSTALL_SCRIPT} ${FILESDIR}/torrus_collector ${PREFIX}/etc/rc.d/torrus_collector
+	${INSTALL_SCRIPT} ${FILESDIR}/torrus_monitor ${PREFIX}/etc/rc.d/torrus_monitor
 	@${CAT} pkg-message
 
 .include <bsd.port.post.mk>
diff -urN net-mgmt/torrus-1.0.9/files/torrus_collector net-mgmt/torrus/files/torrus_collector
--- net-mgmt/torrus-1.0.9/files/torrus_collector	1969-12-31 19:00:00.000000000 -0500
+++ net-mgmt/torrus/files/torrus_collector	2010-12-22 14:58:06.396165980 -0500
@@ -0,0 +1,94 @@
+#!/bin/sh
+#
+# $FreeBSD $
+#
+# PROVIDE: torrus_collector
+# REQUIRE: DAEMON
+#
+# Add the following lines to /etc/rc.conf to run torrus_collector:
+#
+# torrus_collector_enable (bool):	Set it to "YES" to enable torrus_collector.
+#			Default is "NO".
+# torrus_collector_flags (flags):	Set extra flags here. More options in torrus_collector(1)
+#			Default is empty "".
+# torrus_collector_user (user):	Set user to run torrus_collector.
+#			Default is "torrus".
+#
+
+. /etc/rc.subr
+
+name="torrus_collector"
+rcvar=${name}_enable
+
+load_rc_config ${name}
+
+: ${torrus_collector_enable="NO"}
+: ${torrus_collector_user="torrus"}
+
+start_cmd=${name}_start
+status_cmd=${name}_status
+stop_cmd=${name}_stop
+command=/usr/local/libexec/torrus/collector
+
+torrus_collector_init()
+{
+	eval trees_collector=\"`/usr/bin/perl -e 'require "'/usr/local/share/torrus/conf_defaults/torrus-config.pl'";
+		while((my $key, $val) = each %Torrus::Global::treeConfig) {
+			print "$key " if $val->{run}{'collector'};
+		};'`\"
+
+	# Get the collector instance numbers for each tree
+	eval trees=\"\$\{trees_collector\}\"  
+	for t in ${trees}; do
+		eval col_inst_${t}=\"`/usr/bin/perl -e 'require "'/usr/local/share/torrus/conf_defaults/torrus-config.pl'";
+			print join(" ",
+			(0 .. $Torrus::Global::treeConfig{'${t}'}{run}{collector}-1))'`\"
+	done
+}
+
+torrus_collector_start()
+{
+	start_cmd=""
+	torrus_collector_init
+	eval trees=\"\$\{trees_collector\}\"
+    	for t in ${trees}; do
+		eval instances=\"\$\{col_inst_${t}\}\"
+		for i in ${instances}; do
+			echo "starting Torrus collector instance ${i} for tree ${t}"
+			command_args="--tree=${t} --instance=${i}"
+			run_rc_command "start"
+		done
+	done
+}
+
+torrus_collector_status()
+{
+	status_cmd=""
+	torrus_collector_init
+	eval trees=\"\$\{trees_collector\}\"
+    	for t in ${trees}; do
+		eval instances=\"\$\{col_inst_${t}\}\"
+		for i in ${instances}; do
+			pidfile="/var/run/torrus/collector.${t}_${i}.pid"
+			run_rc_command "status"
+		done
+	done
+}
+
+torrus_collector_stop()
+{
+	stop_cmd=""
+	torrus_collector_init
+	eval trees=\"\$\{trees_collector\}\"
+    	for t in ${trees}; do
+		eval instances=\"\$\{col_inst_${t}\}\"
+		for i in ${instances}; do
+			pidfile="/var/run/torrus/collector.${t}_${i}.pid"
+			echo "stopping Torrus collector instance ${i} for tree ${t}"
+			stop_postcmd="if [ -f $pidfile ]; then /bin/rm $pidfile; fi"
+			run_rc_command "stop"
+		done
+	done
+}
+
+run_rc_command "$1"
diff -urN net-mgmt/torrus-1.0.9/files/torrus_monitor net-mgmt/torrus/files/torrus_monitor
--- net-mgmt/torrus-1.0.9/files/torrus_monitor	1969-12-31 19:00:00.000000000 -0500
+++ net-mgmt/torrus/files/torrus_monitor	2010-12-22 14:59:30.638546331 -0500
@@ -0,0 +1,76 @@
+#!/bin/sh
+#
+# $FreeBSD $
+#
+# PROVIDE: torrus_monitor
+# REQUIRE: DAEMON
+#
+# Add the following lines to /etc/rc.conf to run torrus_monitor:
+#
+# torrus_monitor_enable (bool):	Set it to "YES" to enable torrus_monitor.
+#			Default is "NO".
+# torrus_monitor_flags (flags):	Set extra flags here. More options in torrus_monitor(1)
+#			Default is empty "".
+# torrus_monitor_user (user):	Set user to run torrus_monitor.
+#			Default is "torrus".
+#
+
+. /etc/rc.subr
+
+name="torrus_monitor"
+rcvar=${name}_enable
+
+load_rc_config ${name}
+
+: ${torrus_monitor_enable="NO"}
+: ${torrus_monitor_user="torrus"}
+
+start_cmd=${name}_start
+status_cmd=${name}_status
+stop_cmd=${name}_stop
+command=/usr/local/libexec/torrus/monitor
+
+torrus_monitor_init()
+{
+	eval trees_monitor=\"`/usr/bin/perl -e 'require "'/usr/local/share/torrus/conf_defaults/torrus-config.pl'";
+		while((my $key, $val) = each %Torrus::Global::treeConfig) {
+			print "$key " if $val->{run}{'monitor'};
+		};'`\"
+}
+
+torrus_monitor_start()
+{
+	start_cmd=""
+	torrus_monitor_init
+	eval trees=\"\$\{trees_monitor\}\"
+    	for t in ${trees}; do
+		echo "starting Torrus monitor for tree ${t}"
+		command_args="--tree=${t}"
+		run_rc_command "start"
+	done
+}
+
+torrus_monitor_status()
+{
+	status_cmd=""
+	torrus_monitor_init
+	eval trees=\"\$\{trees_monitor\}\"
+    	for t in ${trees}; do
+		pidfile="/var/run/torrus/monitor.${t}.pid"
+		run_rc_command "status"
+	done
+}
+
+torrus_monitor_stop()
+{
+	stop_cmd=""
+	torrus_monitor_init
+	eval trees=\"\$\{trees_monitor\}\"
+    	for t in ${trees}; do
+		pidfile="/var/run/torrus/monitor.${t}.pid"
+		echo "stopping Torrus monitor for tree ${t}"
+		run_rc_command "stop"
+	done
+}
+
+run_rc_command "$1"
diff -urN net-mgmt/torrus-1.0.9/pkg-plist net-mgmt/torrus/pkg-plist
--- net-mgmt/torrus-1.0.9/pkg-plist	2010-11-26 06:16:34.000000000 -0500
+++ net-mgmt/torrus/pkg-plist	2010-12-22 15:00:20.304052804 -0500
@@ -1,5 +1,6 @@
 bin/torrus
-etc/rc.d/torrus.sh
+etc/rc.d/torrus_collector
+etc/rc.d/torrus_monitor
 etc/torrus/discovery/README
 @unexec if cmp -s %D/etc/torrus/conf/devdiscover-siteconfig.pl.sample %D/etc/torrus/conf/devdiscover-siteconfig.pl; then rm -f %D/etc/torrus/conf/devdiscover-siteconfig.pl; fi
 etc/torrus/conf/devdiscover-siteconfig.pl.sample
@@ -269,6 +270,8 @@
 %%SITE_PERL%%/Torrus/SQL/SrvExport.pm
 %%SITE_PERL%%/Torrus/SQL.pm
 %%SITE_PERL%%/Torrus/TimeStamp.pm
+ at exec install -d -g %%TORRUS_USER%% -o %%TORRUS_USER%% -m 2775 /var/log/torrus 2>/dev/null || true
+ at exec install -d -g %%TORRUS_USER%% -o %%TORRUS_USER%% -m 2775 /var/run/torrus 2>/dev/null || true
 @exec install -d -g %%TORRUS_USER%% -o %%TORRUS_USER%% -m 755 /var/torrus 2>/dev/null || true
 @exec install -d -g %%TORRUS_USER%% -o %%TORRUS_USER%% -m 2775 /var/torrus/cache 2>/dev/null || true
 @exec install -d -g %%TORRUS_USER%% -o %%TORRUS_USER%% -m 2775 /var/torrus/collector_rrd 2>/dev/null || true
@@ -321,4 +324,3 @@
 @dirrm %%SITE_PERL%%/Torrus/Collector
 @dirrm %%SITE_PERL%%/Torrus/ACL
 @dirrm %%SITE_PERL%%/Torrus
- at exec mkdir -p /var/log/torrus
--- UIDs.orig	2010-12-21 14:42:03.427401782 -0500
+++ UIDs	2010-12-21 14:43:20.530418178 -0500
@@ -187,3 +187,4 @@
 activemq:*:929:929::0:0:ActiveMQ Daemon:/nonexistent:/sbin/nologin
 ifgraph:*:930:930::0:0:ifGraph:/nonexistent:/sbin/nologin
 asterisk:*:931:931::0:0:Asterisk User:/nonexistent:/sbin/nologin
+torrus:*:932:932::0:0:torrus daemon:/nonexistent:/sbin/nologin
--- GIDs.orig	2010-12-21 14:42:14.356421923 -0500
+++ GIDs	2010-12-21 15:49:58.048470037 -0500
@@ -179,3 +179,4 @@
 activemq:*:929:
 ifgraph:*:930:
 asterisk:*:931:
+torrus:*:932:www


More information about the freebsd-ports-bugs mailing list