From owner-svn-ports-all@freebsd.org Mon Nov 7 06:24:38 2016 Return-Path: Delivered-To: svn-ports-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id CE6C1C33384; Mon, 7 Nov 2016 06:24:38 +0000 (UTC) (envelope-from jbeich@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id A7E2C681; Mon, 7 Nov 2016 06:24:38 +0000 (UTC) (envelope-from jbeich@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uA76ObhW080931; Mon, 7 Nov 2016 06:24:37 GMT (envelope-from jbeich@FreeBSD.org) Received: (from jbeich@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uA76ObMG080929; Mon, 7 Nov 2016 06:24:37 GMT (envelope-from jbeich@FreeBSD.org) Message-Id: <201611070624.uA76ObMG080929@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jbeich set sender to jbeich@FreeBSD.org using -f From: Jan Beich Date: Mon, 7 Nov 2016 06:24:37 +0000 (UTC) To: ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org Subject: svn commit: r425595 - in head/security/tor: . files X-SVN-Group: ports-head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-ports-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the ports tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Nov 2016 06:24:38 -0000 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 (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