Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 3 Mar 2014 20:07:11 +0000 (UTC)
From:      Ryan Steinmetz <zi@FreeBSD.org>
To:        ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org
Subject:   svn commit: r346957 - in head/net/samplicator: . files
Message-ID:  <201403032007.s23K7BhE095067@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: zi
Date: Mon Mar  3 20:07:11 2014
New Revision: 346957
URL: http://svnweb.freebsd.org/changeset/ports/346957
QAT: https://qat.redports.org/buildarchive/r346957/

Log:
  - Add rc script
  - Bump PORTREVISION
  Submitted by:	me
  Approved by:	me@falz.net (maintainer)

Added:
  head/net/samplicator/files/
  head/net/samplicator/files/samplicator.in   (contents, props changed)
Modified:
  head/net/samplicator/Makefile

Modified: head/net/samplicator/Makefile
==============================================================================
--- head/net/samplicator/Makefile	Mon Mar  3 19:45:19 2014	(r346956)
+++ head/net/samplicator/Makefile	Mon Mar  3 20:07:11 2014	(r346957)
@@ -2,6 +2,7 @@
 
 PORTNAME=	samplicator
 PORTVERSION=	1.3.7.b6
+PORTREVISION=	1
 CATEGORIES=	net
 MASTER_SITES=	${MASTER_SITE_GOOGLE_CODE}
 MASTER_SITE_SUBDIR=	samplicator
@@ -14,6 +15,7 @@ LICENSE=	GPLv2
 LICENSE_FILE=	${WRKSRC}/COPYING
 
 GNU_CONFIGURE=	yes
+USE_RC_SUBR=	${PORTNAME}
 
 PLIST_FILES=	bin/samplicate
 PORTDOCS=	NEWS README

Added: head/net/samplicator/files/samplicator.in
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/net/samplicator/files/samplicator.in	Mon Mar  3 20:07:11 2014	(r346957)
@@ -0,0 +1,70 @@
+#!/bin/sh
+
+# $FreeBSD$
+#
+# PROVIDE: samplicator
+# REQUIRE: LOGIN
+# KEYWORD: shutdown
+#
+# Add the following line(s) to /etc/rc.conf to enable samplicator:
+#
+#  samplicator_enable="YES"
+#  # optional
+#  samplicator_flags="-S -p 2055 -c %%PREFIX%%/etc/samplicator.conf"
+#  samplicator_user="nobody"
+#
+# The default is to run samplicator as nobody, which will prevent you from
+# using the -S flag (maintain (spoof) source addresses).
+# If you want to maintain (spoof) source addresses, you will need to run as
+# root.
+# This can be accomplished by adding samplicator_user="root" to /etc/rc.conf
+
+. /etc/rc.subr
+
+name=samplicator
+rcvar=samplicator_enable
+load_rc_config $name
+
+# Set defaults
+samplicator_enable=${samplicator_enable:-"NO"}
+samplicator_flags=${samplicator_flags:-"-p 2055 -c %%PREFIX%%/etc/samplicator.conf"}
+samplicator_user=${samplicator_user:-"nobody"}
+
+pidfile=/var/run/samplicator.pid
+command=%%PREFIX%%/bin/samplicate
+required_files=%%PREFIX%%/etc/samplicator.conf
+
+start_precmd=samplicator_precmd
+start_cmd=samplicator_start
+stop_postcmd=samplicator_cleanup
+
+samplicator_precmd()
+{
+    # since we are using daemon(1) to drop privs, we cannot let samplicator fork
+    %%ECHO%% "${samplicator_flags}" | %%EGREP%% -q "(^\-f| \-f)" 2>&1 > /dev/null
+    if [ $? -eq 0 ]; then
+        %%ECHO%% "Please remove parameter -f from samplicator_flags"
+        %%ECHO%%
+        return 1
+    fi
+
+    # root is required for -S, do a pre-launch sanity check
+    %%ECHO%% "${samplicator_flags}" | %%EGREP%% -q "(^\-S| \-S)" 2>&1 > /dev/null
+    if [ $? -eq 0 && ${samplicator_user} -ne "root" ]; then
+        %%ECHO%% "-S requires that samplicator_user be set to root."
+        %%ECHO%%
+        return 1
+    fi
+}
+
+samplicator_start() {
+    echo "Starting samplicator."
+    %%TOUCH%% ${pidfile} && %%CHOWN%% ${samplicator_user} ${pidfile}
+    /usr/sbin/daemon -cf -p ${pidfile} -u ${samplicator_user} ${command} ${samplicator_flags}
+}
+
+samplicator_cleanup() {
+    [ -f ${pidfile} ] && %%RM%% ${pidfile}
+}
+
+run_rc_command "$1"



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201403032007.s23K7BhE095067>