svn commit: r425595 - in head/security/tor: . files
Jan Beich
jbeich at FreeBSD.org
Mon Nov 7 06:24:38 UTC 2016
Author: jbeich
Date: Mon Nov 7 06:24:37 2016
New Revision: 425595
URL: https://svnweb.freebsd.org/changeset/ports/425595
Log:
security/tor: improve multi-instance support
- rc.d commands now accept optional instance argument
- `status` command output is no longer ambigous
before:
$ service tor status
tor is running as pid 22222.
tor is running as pid 33333.
tor is running as pid 11111.
after:
$ service tor status
tor instance inst1: tor is running as pid 22222.
tor instance inst2: tor is running as pid 33333.
tor main instance: tor is running as pid 11111.
$ service tor restart inst1
tor instance inst1: Stopping tor.
Waiting for PIDS: 22222.
Starting tor.
[...]
PR: 207129
Submitted by: Yuri Victorovich <yuri at rawbw.com> (maintainer)
Modified:
head/security/tor/Makefile (contents, props changed)
head/security/tor/files/tor.in
Modified: head/security/tor/Makefile
==============================================================================
--- head/security/tor/Makefile Mon Nov 7 06:18:47 2016 (r425594)
+++ head/security/tor/Makefile Mon Nov 7 06:24:37 2016 (r425595)
@@ -3,7 +3,7 @@
PORTNAME= tor
PORTVERSION= 0.2.8.9
-PORTREVISION= 1
+PORTREVISION= 2
CATEGORIES= security net ipv6
MASTER_SITES= TOR
Modified: head/security/tor/files/tor.in
==============================================================================
--- head/security/tor/files/tor.in Mon Nov 7 06:18:47 2016 (r425594)
+++ head/security/tor/files/tor.in Mon Nov 7 06:24:37 2016 (r425595)
@@ -30,6 +30,7 @@
name="tor"
rcvar=tor_enable
+exit_code=0
load_rc_config ${name}
@@ -42,13 +43,14 @@ load_rc_config ${name}
: ${tor_datadir="/var/db/tor"}
: ${tor_disable_default_instance="NO"}
-instance=${2}
+instance=${slave_instance}
if [ -n "${instance}" ]; then
- # extended instance: parameters are set explicitly
inst_def=${instance}
inst_name=${inst_def%%:*}
+ [ "${inst_name}" != "main" ] || err 1 "${name} instance can't be named 'main'"
inst_def=${inst_def#$inst_name}
if [ -n "$inst_def" ]; then
+ # extended instance: parameters are set explicitly
inst_def=${inst_def#:}
tor_conf=${inst_def%%:*}
inst_def=${inst_def#$tor_conf:}
@@ -59,7 +61,7 @@ if [ -n "${instance}" ]; then
tor_pidfile=${inst_def%%:*}
tor_datadir=${inst_def#$tor_pidfile:}
if [ -z "${tor_conf}" -o -z "${tor_user}" -o -z "${tor_group}" -o -z "${tor_pidfile}" -o -z "${tor_datadir}" ]; then
- warn "invalid tor instance ${inst_name} settings"
+ warn "invalid tor instance ${inst_name} settings: ${instance}"
exit 1
fi
else
@@ -82,10 +84,25 @@ if [ -n "${instance}" ]; then
fi
if [ -z "${instance}" -a -n "${tor_instances}" ]; then
+ inst_only="$2"
+ inst_done=0
for i in ${tor_instances}; do
- %%PREFIX%%/etc/rc.d/tor $1 ${i} || warn "$1 failed for the tor instance $i"
+ inst_name=${i%%:*}
+ if [ -z "${inst_only}" -o "${inst_name}" = "${inst_only}" ]; then
+ echo -n "${name} instance ${inst_name}: "
+ if ! slave_instance=${i} %%PREFIX%%/etc/rc.d/tor "$1"; then
+ exit_code=1
+ fi
+ inst_done=$((inst_done+1))
+ fi
done
- checkyesno tor_disable_default_instance && return 0
+ if [ -z "${inst_only}" -o "${inst_only}" = "main" ]; then
+ checkyesno tor_disable_default_instance && return $exit_code
+ echo -n "${name} main instance: "
+ elif [ -n "${inst_only}" ]; then
+ [ $inst_done -gt 0 ] || err 1 "${name} instance '$inst_only' isn't defined"
+ return $exit_code
+ fi
fi
required_files=${tor_conf}
@@ -95,5 +112,8 @@ command="%%PREFIX%%/bin/${name}"
command_args="-f ${tor_conf} --PidFile ${tor_pidfile} --RunAsDaemon 1 --DataDirectory ${tor_datadir}"
extra_commands="reload"
-run_rc_command "$1"
+if ! run_rc_command "$1"; then
+ exit_code=1
+fi
+return $exit_code
More information about the svn-ports-head
mailing list