aboutsummaryrefslogtreecommitdiff
path: root/net-mgmt
diff options
context:
space:
mode:
authorPav Lucistnik <pav@FreeBSD.org>2010-12-22 21:59:21 +0000
committerPav Lucistnik <pav@FreeBSD.org>2010-12-22 21:59:21 +0000
commitac8d209699c70285c48e034a3aab91b8093b17c7 (patch)
tree083ae4bc135a9c6690a75268d98e402f88a6b51b /net-mgmt
parent58d6a7c84891c85c8a10ab802237999cae89d176 (diff)
downloadports-ac8d209699c70285c48e034a3aab91b8093b17c7.tar.gz
ports-ac8d209699c70285c48e034a3aab91b8093b17c7.zip
- Upgrade to USERS/GROUPS
- Provide new rc scripts PR: ports/153162 Submitted by: Corey Smith <corsmith@gmail.com> (maintainer)
Notes
Notes: svn path=/head/; revision=266739
Diffstat (limited to 'net-mgmt')
-rw-r--r--net-mgmt/torrus/Makefile26
-rw-r--r--net-mgmt/torrus/files/torrus_collector.in94
-rw-r--r--net-mgmt/torrus/files/torrus_monitor.in76
-rw-r--r--net-mgmt/torrus/pkg-plist4
4 files changed, 180 insertions, 20 deletions
diff --git a/net-mgmt/torrus/Makefile b/net-mgmt/torrus/Makefile
index 8b630b75871e..cb2a4584bf12 100644
--- a/net-mgmt/torrus/Makefile
+++ b/net-mgmt/torrus/Makefile
@@ -7,6 +7,7 @@
PORTNAME= torrus
PORTVERSION= 1.0.9
+PORTREVISION= 1
CATEGORIES= net-mgmt
MASTER_SITES= SF
@@ -30,12 +31,14 @@ USE_GNOME= libxml2
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}
+USE_RC_SUBR= torrus_collector torrus_monitor
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 \
@@ -58,20 +61,7 @@ MAN1= torrus.1 torrus_acledit.1 torrus_buildsearchdb.1 \
MAN7= torrus_action_printemail.7 torrus_action_snmptrap.7 \
torrus_action_notify.7 torrus_install_plugin.7
-.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
@${CAT} pkg-message
-.include <bsd.port.post.mk>
+.include <bsd.port.mk>
diff --git a/net-mgmt/torrus/files/torrus_collector.in b/net-mgmt/torrus/files/torrus_collector.in
new file mode 100644
index 000000000000..17ee0c3b79a2
--- /dev/null
+++ b/net-mgmt/torrus/files/torrus_collector.in
@@ -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=%%PREFIX%%/libexec/torrus/collector
+
+torrus_collector_init()
+{
+ eval trees_collector=\"`/usr/bin/perl -e 'require "'%%PREFIX%%/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 "'%%PREFIX%%/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 --git a/net-mgmt/torrus/files/torrus_monitor.in b/net-mgmt/torrus/files/torrus_monitor.in
new file mode 100644
index 000000000000..124ecf1f95e4
--- /dev/null
+++ b/net-mgmt/torrus/files/torrus_monitor.in
@@ -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=%%PREFIX%%/libexec/torrus/monitor
+
+torrus_monitor_init()
+{
+ eval trees_monitor=\"`/usr/bin/perl -e 'require "'%%PREFIX%%/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 --git a/net-mgmt/torrus/pkg-plist b/net-mgmt/torrus/pkg-plist
index 2b32311af47a..cde57ea8dade 100644
--- a/net-mgmt/torrus/pkg-plist
+++ b/net-mgmt/torrus/pkg-plist
@@ -1,5 +1,4 @@
bin/torrus
-etc/rc.d/torrus.sh
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 +268,8 @@ libexec/torrus/ttproclist
%%SITE_PERL%%/Torrus/SQL/SrvExport.pm
%%SITE_PERL%%/Torrus/SQL.pm
%%SITE_PERL%%/Torrus/TimeStamp.pm
+@exec install -d -g %%TORRUS_USER%% -o %%TORRUS_USER%% -m 2775 /var/log/torrus 2>/dev/null || true
+@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 +322,3 @@ libexec/torrus/ttproclist
@dirrm %%SITE_PERL%%/Torrus/Collector
@dirrm %%SITE_PERL%%/Torrus/ACL
@dirrm %%SITE_PERL%%/Torrus
-@exec mkdir -p /var/log/torrus