aboutsummaryrefslogtreecommitdiff
path: root/security/tor
diff options
context:
space:
mode:
authorJan Beich <jbeich@FreeBSD.org>2016-11-07 06:24:37 +0000
committerJan Beich <jbeich@FreeBSD.org>2016-11-07 06:24:37 +0000
commit6c5afc2ab97f44fa776b4339503b307263e849d8 (patch)
tree57ca8bc20c449ef89edccd3e4d0b357eab7ce43a /security/tor
parent9b52f573fd7d5e061e0c498703b333b2e8b6ef1d (diff)
downloadports-6c5afc2ab97f44fa776b4339503b307263e849d8.tar.gz
ports-6c5afc2ab97f44fa776b4339503b307263e849d8.zip
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@rawbw.com> (maintainer)
Notes
Notes: svn path=/head/; revision=425595
Diffstat (limited to 'security/tor')
-rw-r--r--security/tor/Makefile2
-rw-r--r--security/tor/files/tor.in32
2 files changed, 27 insertions, 7 deletions
diff --git a/security/tor/Makefile b/security/tor/Makefile
index 3a04a6860785..7d7ecae0940b 100644
--- a/security/tor/Makefile
+++ b/security/tor/Makefile
@@ -3,7 +3,7 @@
PORTNAME= tor
PORTVERSION= 0.2.8.9
-PORTREVISION= 1
+PORTREVISION= 2
CATEGORIES= security net ipv6
MASTER_SITES= TOR
diff --git a/security/tor/files/tor.in b/security/tor/files/tor.in
index a279e326b0ae..185d9fe3370f 100644
--- a/security/tor/files/tor.in
+++ b/security/tor/files/tor.in
@@ -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