From owner-freebsd-ports-bugs@FreeBSD.ORG Thu Sep 6 09:10:02 2012 Return-Path: Delivered-To: freebsd-ports-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7DA4E106566B for ; Thu, 6 Sep 2012 09:10:02 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 494178FC18 for ; Thu, 6 Sep 2012 09:10:02 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.5/8.14.5) with ESMTP id q869A22p062415 for ; Thu, 6 Sep 2012 09:10:02 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.5/8.14.5/Submit) id q869A2k7062407; Thu, 6 Sep 2012 09:10:02 GMT (envelope-from gnats) Resent-Date: Thu, 6 Sep 2012 09:10:02 GMT Resent-Message-Id: <201209060910.q869A2k7062407@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-ports-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, "Oleg A. Mamontov" Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 49AA1106564A; Thu, 6 Sep 2012 09:08:54 +0000 (UTC) (envelope-from lonerr@luna.park.rambler.ru) Received: from pmx1.rambler.ru (mail02.park.rambler.ru [81.19.66.13]) by mx1.freebsd.org (Postfix) with ESMTP id F0C008FC0C; Thu, 6 Sep 2012 09:08:52 +0000 (UTC) Received: from luna.park.rambler.ru ([10.12.2.4]) by pmx1.rambler.ru with esmtp (Exim 4.77 (FreeBSD)) (envelope-from ) id 1T9Xag-000Fmw-Q5; Thu, 06 Sep 2012 12:37:34 +0400 Received: from luna.park.rambler.ru (localhost [127.0.0.1]) by luna.park.rambler.ru (8.14.5/8.14.5) with ESMTP id q868bYbk084409; Thu, 6 Sep 2012 12:37:34 +0400 (MSK) (envelope-from lonerr@luna.park.rambler.ru) Received: (from lonerr@localhost) by luna.park.rambler.ru (8.14.5/8.14.5/Submit) id q868bYkg084404; Thu, 6 Sep 2012 12:37:34 +0400 (MSK) (envelope-from lonerr) Message-Id: <201209060837.q868bYkg084404@luna.park.rambler.ru> Date: Thu, 6 Sep 2012 12:37:34 +0400 (MSK) From: "Oleg A. Mamontov" To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Cc: osa@FreeBSD.org Subject: ports/171372: [PATCH] databases/redis: rc script with multiple profiles support X-BeenThere: freebsd-ports-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Ports bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 06 Sep 2012 09:10:02 -0000 >Number: 171372 >Category: ports >Synopsis: [PATCH] databases/redis: rc script with multiple profiles support >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-ports-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Thu Sep 06 09:10:01 UTC 2012 >Closed-Date: >Last-Modified: >Originator: Oleg A. Mamontov >Release: FreeBSD 8.2-STABLE amd64 >Organization: >Environment: System: FreeBSD luna.park.rambler.ru 8.2-STABLE FreeBSD 8.2-STABLE #1: Fri Sep 23 19:19:19 MSD 2011 >Description: [DESCRIBE CHANGES] Port maintainer (osa@FreeBSD.org) is cc'd. Generated with FreeBSD Port Tools 0.99 >How-To-Repeat: >Fix: --- redis-2.4.17.patch begins here --- diff -ruN --exclude=CVS /usr/ports/databases/redis/files/redis.in /usr/home/lonerr/redis/files/redis.in --- /usr/ports/databases/redis/files/redis.in 2012-09-06 12:07:20.000000000 +0400 +++ /usr/home/lonerr/redis/files/redis.in 2012-09-06 12:08:28.000000000 +0400 @@ -1,17 +1,18 @@ #!/bin/sh # -# $FreeBSD: ports/databases/redis/files/redis.in,v 1.1 2012/07/18 06:10:17 osa Exp $ +# $FreeBSD$ # - # PROVIDE: redis # REQUIRE: LOGIN # BEFORE: securelevel # KEYWORD: shutdown - -# Add the following line to /etc/rc.conf to enable `redis': # -#redis_enable="YES" +# Add the following lines to /etc/rc.conf to run redis: # +# redis_enable (bool): Set it to "YES" to enable redis. +# Default is "NO". +# redis_profiles (strings): Example - "foo bar" +# Default is empty. . /etc/rc.subr @@ -20,15 +21,46 @@ extra_commands="reload" -command="%%PREFIX%%/bin/redis-server" -config_file="%%PREFIX%%/etc/$name.conf" +command=%%PREFIX%%/bin/redis-server +config_file="%%PREFIX%%/etc/${name}.conf" command_args="${config_file}" pidfile="%%REDIS_RUNDIR%%/$name.pid" required_files="${config_file}" # read configuration and set defaults -load_rc_config "$name" +load_rc_config "${name}" : ${redis_enable="NO"} : ${redis_user="%%REDIS_USER%%"} + +_profile_exists() { + for _p in ${redis_profiles}; do + [ "${_p}" = "$1" ] && return 1; + done + return 0 +} + +if [ $# -eq 2 ]; then + _profile=$2 + _profile_exists $_profile + _exists=$? + [ ${_exists} -ne 1 ] && { + echo "`basename %%PREFIX%%/etc/rc.d/redis`: no '$2' in 'redis_profiles'" + exit 1 + }; + echo "-- Profile: ${_profile} --" + config_file="%%PREFIX%%/etc/${name}-${_profile}.conf" + command_args="${config_file}" + pidfile="%%REDIS_RUNDIR%%/${_profile}.pid" + required_files="${config_file}" +elif [ -n "${redis_profiles}" ]; then + _swap=$*; shift; _profiles=$* + _profiles=${_profiles:-${redis_profiles}} + set -- ${_swap} + for _profile in ${_profiles}; do + %%PREFIX%%/etc/rc.d/redis $1 ${_profile} + done + exit 0 +fi + run_rc_command "$1" --- redis-2.4.17.patch ends here --- >Release-Note: >Audit-Trail: >Unformatted: