From g.olgeni@colby.it  Fri Mar 20 10:39:08 2009
Return-Path: <g.olgeni@colby.it>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 581F91065675
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 20 Mar 2009 10:39:08 +0000 (UTC)
	(envelope-from g.olgeni@colby.it)
Received: from aa002msb.fastweb.it (aa002msb.fastweb.it [85.18.95.81])
	by mx1.freebsd.org (Postfix) with ESMTP id 9929A8FC16
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 20 Mar 2009 10:39:07 +0000 (UTC)
	(envelope-from g.olgeni@colby.it)
Received: from exchange.colby.local (81.208.57.5) by aa002msb.fastweb.it (8.0.013.8)
        id 499B6EFC06346642; Fri, 20 Mar 2009 11:39:03 +0100
Received: from exchange.colby.local ([192.168.1.11] helo=exchange.colby.local)
	by bsdbox.colby.local; 20 Mar 2009 11:39:28 +0100
Received: from backoffice.colby.local ([192.168.1.56]) by exchange.colby.local over TLS secured channel with Microsoft SMTPSVC(6.0.3790.3959);
	 Fri, 20 Mar 2009 11:39:03 +0100
Received: from backoffice.colby.local (localhost [127.0.0.1])
	by backoffice.colby.local (8.14.3/8.14.3) with ESMTP id n2KAd266061030;
	Fri, 20 Mar 2009 11:39:03 +0100 (CET)
	(envelope-from olgeni@backoffice.colby.local)
Received: (from olgeni@localhost)
	by backoffice.colby.local (8.14.3/8.14.3/Submit) id n2KAd2Gm061029;
	Fri, 20 Mar 2009 11:39:02 +0100 (CET)
	(envelope-from olgeni)
Message-Id: <200903201039.n2KAd2Gm061029@backoffice.colby.local>
Date: Fri, 20 Mar 2009 11:39:02 +0100 (CET)
From: Jimmy Olgeni <olgeni@freebsd.org>
To: FreeBSD-gnats-submit@freebsd.org
Cc: vivek@khera.org
Subject: [PATCH] databases/slony1: rework startup script (daemon, rc.subr)
X-Send-Pr-Version: 3.113
X-GNATS-Notify: vivek@khera.org

>Number:         132849
>Category:       ports
>Synopsis:       [PATCH] databases/slony1: rework startup script (daemon, rc.subr)
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    olgeni
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Fri Mar 20 10:40:01 UTC 2009
>Closed-Date:    Sun Mar 22 13:29:51 UTC 2009
>Last-Modified:  Sun Mar 22 13:30:05 UTC 2009
>Originator:     Jimmy Olgeni
>Release:        FreeBSD 7.1-RELEASE i386
>Organization:
>Environment:
System: FreeBSD backoffice 7.1-RELEASE FreeBSD 7.1-RELEASE #1: Mon Jan  5 15:38:58 CET
>Description:
Refactor slon.sh to improve support for rc.subr; also start slon
with the daemon(8) utility to detach it from the terminal.

Limit logging by default to avoid overflowing syslog, and remove
some (disabled) debug code.

Port maintainer (vivek@khera.org) is cc'd.

Generated with FreeBSD Port Tools 0.77
>How-To-Repeat:
>Fix:

--- slony1-1.2.15.patch begins here ---
Index: files/slon.conf-sample
===================================================================
RCS file: /home/pcvs/ports/databases/slony1/files/slon.conf-sample,v
retrieving revision 1.1
diff -u -u -r1.1 slon.conf-sample
--- files/slon.conf-sample	24 Jun 2005 11:22:43 -0000	1.1
+++ files/slon.conf-sample	20 Mar 2009 10:35:43 -0000
@@ -3,8 +3,8 @@
 # not all settings are shown here.
 
 syslog 0
-log_level 4
-log_timestamp 1
+log_level 0
+log_timestamp 0
 
 cluster_name sample
 conn_info 'dbname=pgbench user=postgres host=localhost port=5432'
Index: files/slon.sh.in
===================================================================
RCS file: /home/pcvs/ports/databases/slony1/files/slon.sh.in,v
retrieving revision 1.4
diff -u -u -r1.4 slon.sh.in
--- files/slon.sh.in	8 Sep 2007 12:22:49 -0000	1.4
+++ files/slon.sh.in	20 Mar 2009 10:35:43 -0000
@@ -6,13 +6,13 @@
 # $Id$ 
 #
 
-# sed -e 's/%%PREFIX%%/\/usr\/local/g' < slon.in > slon
+# sed -e 's/%%PREFIX%%/\/usr\/local/g' < slon.sh.in > slon
 
 # PROVIDE: slon
 # REQUIRE: postgresql
 # KEYWORD: shutdown
 
-. "/etc/rc.subr"
+. /etc/rc.subr
 
 name="slon"
 rcvar=`set_rcvar`
@@ -20,89 +20,83 @@
 load_rc_config "$name"
 _pidprefix="/var/run/${name}"
 pidfile="${_pidprefix}.pid" # Used as fall-through in event of no profiles
+procname="%%PREFIX%%/bin/slon"
 
 # From global rc.conf(5); if unset, set them here
-[ -z "$slon_enable" ]       && slon_enable="NO"
-[ -z "$slon_profiles" ]     && slon_profiles=""
+[ -z "$slon_enable" ]   && slon_enable="NO"
+[ -z "$slon_profiles" ] && slon_profiles=""
 
-configfile_path="/usr/local/etc/${name}.conf"
-command_args="-f ${configfile_path} -p ${pidfile} &"
+configfile_path="%%PREFIX%%/etc/${name}.conf"
+command_args="-f ${configfile_path}"
 required_files="${configfile_path}"
 
-command="/usr/local/bin/slon"
+isProfile () {
+    local profile
 
-isProfile() {
-        match=0;
-        for curMember in $slon_profiles; do
-                if [ "$curMember" = "$1" ]; then
-                        #echo "DEBUG: Match"
-                        match=1
-                fi
-        done
-        return $match;
+    for profile in $slon_profiles; do
+        if [ "$profile" = "$1" ]; then
+            return 0
+        fi
+    done
+
+    return 1
 }
 
+if [ -n "$2" ]; then
+    if [ "x${slon_profiles}" = "x" ]; then # This checks that profiles are indeed defined
+        echo "$0: extra profile argument ignored, no profiles defined"
+        exit 1
+    fi
 
+    profile="$2" # A profile argument has been given (presumably)
 
-if [ -n "$2" ]; then
-	profile="$2" # A profile argument has been given (presumably)
-	if [ "x${slon_profiles}" != "x" ]; then # This checks that profiles are indeed defined
-		echo "-- Profile: $profile --"
-		# Now let's check to make sure that both the profile, the profile's config path variable, config file exists
-		configfile_default_path="/usr/local/etc/${name}-${profile}.conf"
-		configfile_override_varname="\$${name}_${profile}_configfile" # Basic string substitution gets variable name
-		configfile_override_varname_nop="${name}_${profile}_configfile" # Basic string substitution gets variable name
-		#echo "DEBUG default path: $configfile_default_path"
-		#echo "DEBUG override variable name: $configfile_override_varname";
-		#echo "DEBUG override variable name noprefix: $configfile_override_varname_nop";
-		eval configfile_path=\${$configfile_override_varname_nop:-${configfile_default_path}} # e.g., $configfile_varname="$slon_sex_configfile"
-		#echo "DEBUG final: $configfile_path";
-		isProfile $profile
-		searchForProfile=$?
-		# testing for true
-		if [ ! -r "$configfile_path" -o $searchForProfile -lt 1 ]; then
-			echo "$0: no such profile defined, profile config file defined, or cant read profile config file!";
-			exit 1;
-		fi
-		required_files=${configfile_path}
-		
-		pidfile_default="${_pidprefix}-${profile}.pid"
-		eval pidfile=\${${name}_${profile}_pidfile:-${pidfile_default}}
-
-		command_args="-f ${configfile_path} -p ${pidfile} &"
-		#echo "DEBUG argspre: $command_args"
-		#echo "DEBUG subst: ${name}_${profile}_flags"
-		#eval echo "DEBUG subst: \$${name}_${profile}_flags"
-		#eval echo "DEBUG subst2: command_args=\${${name}_${profile}_flags:-${command_args}}"
-		eval command_args=\${${name}_${profile}_flags:-${command_args}}
-		#echo "DEBUG args: $command_args"
-	else
-		echo "$0: extra profile argument ignored, no profiles defined"
-	fi
-	
+    # Now let's check to make sure that both the profile, the profile's
+    # config path variable, config file exists
+
+    if ! isProfile $profile; then
+        echo "$0: no such profile defined in slon_profiles."
+        exit 1
+    fi
+
+    configfile_default_path="%%PREFIX%%/etc/${name}-${profile}.conf"
+
+    # Basic string substitution gets variable name
+    configfile_varname="${name}_${profile}_configfile"
 
+    eval configfile_path=\${$configfile_varname:-${configfile_default_path}}
+
+    if [ ! -r "$configfile_path" ]; then
+        echo "$0: unable to read configuration file."
+        exit 1
+    fi
+
+    required_files="${configfile_path}"
+    
+    pidfile_default="${_pidprefix}-${profile}.pid"
+    eval pidfile=\${${name}_${profile}_pidfile:-${pidfile_default}}
+
+    command_args="-f ${configfile_path}"
+    eval command_args=\${${name}_${profile}_flags:-${command_args}}
 else
-	# We get to here if $2 is not defined at command line, but we do have profiles
-	# so apply $1 command to all profiles!
-	# This block uses recursion to call ourself with each-profile defined as $2
-	if [ "x${slon_profiles}" != "x" -a "x$1" != "x" ]; then
-		if [ "x$1" != "xrestart" ]; then
-			for profile in ${slon_profiles}; do
-				echo "===> ${name} profile: ${profile}"
-				/usr/local/etc/rc.d/${name} $1 ${profile}
-				retcode="$?"
-				if [ "0${retcode}" -ne 0 ]; then
-					failed="${profile} (${retcode}) ${failed:-}"
-				else
-					success="${profile} ${success:-}"
-				fi
-			done
-			exit 0
-		else
-			restart_precmd=""
-		fi
-	fi
+    # We get to here if $2 is not defined at command line, but we do have profiles
+    # so apply $1 command to all profiles!
+    # This block uses recursion to call ourself with each-profile defined as $2.
+
+    if [ "x${slon_profiles}" != "x" -a "x$1" != "x" ]; then
+        for profile in ${slon_profiles}; do
+            echo "Processing ${name} profile: ${profile}"
+            %%PREFIX%%/etc/rc.d/${name} $1 ${profile}
+        done
+        exit 0
+    fi
 # else = no profile argument given
 fi
 
+slon_start () {
+    echo "Starting ${name}."
+    /usr/sbin/daemon -cf -p ${pidfile} %%PREFIX%%/bin/slon ${command_args}
+}
+
+start_cmd=slon_start
+
 run_rc_command "$1"
--- slony1-1.2.15.patch ends here ---

>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-ports-bugs->olgeni 
Responsible-Changed-By: edwin 
Responsible-Changed-When: Fri Mar 20 10:40:12 UTC 2009 
Responsible-Changed-Why:  
Submitter has GNATS access (via the GNATS Auto Assign Tool) 

http://www.freebsd.org/cgi/query-pr.cgi?pr=132849 
State-Changed-From-To: open->feedback 
State-Changed-By: edwin 
State-Changed-When: Fri Mar 20 10:40:17 UTC 2009 
State-Changed-Why:  
Awaiting maintainers feedback (via the GNATS Auto Assign Tool) 

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

From: Edwin Groothuis <edwin@FreeBSD.org>
To: vivek@khera.org
Cc: bug-followup@FreeBSD.org
Subject: Re: ports/132849: [PATCH] databases/slony1: rework startup script (daemon, rc.subr)
Date: Fri, 20 Mar 2009 10:40:14 UT

 Maintainer of databases/slony1,
 
 Please note that PR ports/132849 has just been submitted.
 
 If it contains a patch for an upgrade, an enhancement or a bug fix
 you agree on, reply to this email stating that you approve the patch
 and a committer will take care of it.
 
 The full text of the PR can be found at:
     http://www.freebsd.org/cgi/query-pr.cgi?pr=ports/132849
 
 -- 
 Edwin Groothuis via the GNATS Auto Assign Tool
 edwin@FreeBSD.org

From: Vick Khera <vivek@mailermailer.com>
To: bug-followup@FreeBSD.org,
 olgeni@freebsd.org
Cc:  
Subject: Re: ports/132849: [PATCH] databases/slony1: rework startup script (daemon, rc.subr)
Date: Fri, 20 Mar 2009 09:34:01 -0400

 I'll agree to the update.  I don't personally use the rc script to  
 start slon; I prefer using the daemontools to manage the processes, so  
 I don't have a configuration with which to test this out.
 
 It looks good to me, and given the submitter has commit bits, I'll  
 presume it is tested and works.
 
 Thanks for the update!
 
State-Changed-From-To: feedback->closed 
State-Changed-By: olgeni 
State-Changed-When: Sun Mar 22 13:29:27 UTC 2009 
State-Changed-Why:  
Patch committed. 

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

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: ports/132849: commit references a PR
Date: Sun, 22 Mar 2009 13:28:34 +0000 (UTC)

 olgeni      2009-03-22 13:28:24 UTC
 
   FreeBSD ports repository
 
   Modified files:
     databases/slony1/files slon.conf-sample slon.sh.in 
   Log:
   Run slon with daemon(8) to properly detach from the console.
   Set default log levels to 0.
   Remove debug code from startup script.
   
   PR:             ports/132849
   Approved by:    maintainer
   
   Revision  Changes    Path
   1.2       +2 -2      ports/databases/slony1/files/slon.conf-sample
   1.5       +67 -73    ports/databases/slony1/files/slon.sh.in
 _______________________________________________
 cvs-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/cvs-all
 To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
 
>Unformatted:
