ports/171372: [PATCH] databases/redis: rc script with multiple profiles support
Oleg A. Mamontov
oleg at mamontov.net
Thu Sep 6 09:10:02 UTC 2012
>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 at 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:
More information about the freebsd-ports-bugs
mailing list