Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 14 Sep 2015 22:29:08 +0000 (UTC)
From:      Carlo Strub <cs@FreeBSD.org>
To:        ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org
Subject:   svn commit: r396939 - in head/dns/dnscrypt-proxy: . files
Message-ID:  <201509142229.t8EMT83I004705@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: cs
Date: Mon Sep 14 22:29:08 2015
New Revision: 396939
URL: https://svnweb.freebsd.org/changeset/ports/396939

Log:
  Add support for multiple service instances
  
  PR:		195698
  Submitted by:	Igor <arabesc@bk.ru>
  Approved by:	maintainer

Added:
  head/dns/dnscrypt-proxy/files/dnscrypt-proxy_multi.in   (contents, props changed)
  head/dns/dnscrypt-proxy/files/pkg-message_multi.in   (contents, props changed)
Modified:
  head/dns/dnscrypt-proxy/Makefile
  head/dns/dnscrypt-proxy/files/pkg-message.in

Modified: head/dns/dnscrypt-proxy/Makefile
==============================================================================
--- head/dns/dnscrypt-proxy/Makefile	Mon Sep 14 21:51:52 2015	(r396938)
+++ head/dns/dnscrypt-proxy/Makefile	Mon Sep 14 22:29:08 2015	(r396939)
@@ -3,7 +3,7 @@
 
 PORTNAME=	dnscrypt-proxy
 PORTVERSION=	1.6.0
-PORTREVISION=	0
+PORTREVISION=	1
 CATEGORIES=	dns
 MASTER_SITES=	http://download.dnscrypt.org/dnscrypt-proxy/ \
 		http://www.dns-lab.com/downloads/dnscrypt-proxy/
@@ -19,9 +19,23 @@ LIB_DEPENDS=	libsodium.so:${PORTSDIR}/se
 GNU_CONFIGURE=	yes
 USES=		execinfo gmake
 
-SUB_FILES=	pkg-message
-
+OPTIONS_DEFINE=	DOCS
+OPTIONS_SINGLE=	RCWHICH
+OPTIONS_SINGLE_RCWHICH=	RCSINGLE RCMULTI
+RCWHICH_DESC=	rc script to use:
+RCSINGLE_DESC=	use default rc script for single daemon
+RCMULTI_DESC=	use experimental rc script for multiple instances
+OPTIONS_DEFAULT=RCSINGLE
+
+.include <bsd.port.options.mk>
+
+.if ${PORT_OPTIONS:MRCMULTI}
+USE_RC_SUBR=	${PORTNAME}_multi
+SUB_FILES=	pkg-message_multi
+.else
 USE_RC_SUBR=	${PORTNAME}
+SUB_FILES=	pkg-message
+.endif
 
 USERS=		_dnscrypt-proxy
 
@@ -29,8 +43,6 @@ PORTDOCS=	AUTHORS ChangeLog INSTALL NEWS
 		README-PLUGINS.markdown README-WINDOWS.markdown \
 		README.markdown TECHNOTES THANKS
 
-OPTIONS_DEFINE=	DOCS
-
 post-install:
 	@${MKDIR} ${STAGEDIR}${DOCSDIR}
 	${INSTALL_DATA} ${PORTDOCS:S,^,${WRKSRC}/,} ${STAGEDIR}${DOCSDIR}

Added: head/dns/dnscrypt-proxy/files/dnscrypt-proxy_multi.in
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/dns/dnscrypt-proxy/files/dnscrypt-proxy_multi.in	Mon Sep 14 22:29:08 2015	(r396939)
@@ -0,0 +1,71 @@
+#!/bin/sh
+#
+# $FreeBSD: $
+#
+# PROVIDE: dnscrypt_proxy
+# REQUIRE: SERVERS cleanvar
+# BEFORE: named local_unbound unbound
+# KEYWORD: shutdown
+#
+# Add the following lines to /etc/rc.conf to enable dnscrypt-proxy:
+#
+# dnscrypt_proxy_instances (str): Set to "dnscrypt_proxy" by default.
+#                                 List of dnscrypt_proxy instance id's,
+#                                 e.g. "dnscrypt_proxy_1 dnscrypt_proxy_2", etc.
+# {instance_id}_enable (bool):    Set to NO by default.
+#                                 Set to YES to enable dnscrypt-proxy.
+# {instance_id}_uid (str):        Set to "_dnscrypt-proxy" by default.
+#                              	  User to switch to after starting.
+# {instance_id}_resolver (str):   Set to "opendns" by default.
+#                              	  Choose a different upstream resolver.
+# {instance_id}_pidfile (str):    default: "/var/run/dnscrypt-proxy.pid"
+#                              	  Location of pid file.
+# {instance_id}_logfile (str):	  default: "/var/log/dnscrypt-proxy.log"
+#                                 Location of log file.
+#
+# To redirect a local resolver through dnscrypt-proxy, point it at 127.0.0.2
+# and add the following to rc.conf:
+# ifconfig_lo0_alias0="inet 127.0.0.2 netmask 0xffffffff"
+# dnscrypt_proxy_flags='-a 127.0.0.2'
+
+. /etc/rc.subr
+
+name=dnscrypt_proxy
+rcvar=dnscrypt_proxy_enable
+
+load_rc_config ${name}
+
+: ${dnscrypt_proxy_instances="${name}"}
+: ${dnscrypt_proxy_enable:=NO}
+
+dnscrypt_proxy_enable_tmp=${dnscrypt_proxy_enable}
+
+command=%%PREFIX%%/sbin/dnscrypt-proxy
+procname=%%PREFIX%%/sbin/dnscrypt-proxy
+
+for i in $dnscrypt_proxy_instances; do
+    name=${i}
+
+    eval ${name}_enable=${dnscrypt_proxy_enable_tmp}
+    rcvar=${name}_enable
+
+    load_rc_config ${i}
+
+    eval dnscrypt_proxy_uid_tmp=\${${i}_uid}
+    eval dnscrypt_proxy_resolver_tmp=\${${i}_resolver}
+    eval dnscrypt_proxy_pidfile_tmp=\${${i}_pidfile}
+    eval dnscrypt_proxy_logfile_tmp=\${${i}_logfile}
+
+:   ${dnscrypt_proxy_uid_tmp:=_dnscrypt-proxy}       # User to run daemon as
+:   ${dnscrypt_proxy_resolver_tmp:=opendns}          # resolver to use
+:   ${dnscrypt_proxy_pidfile_tmp:=/var/run/${i}.pid} # Path to pid file
+:   ${dnscrypt_proxy_logfile_tmp:=/var/log/${i}.log} # Path to log file
+
+    command_args="-d -p ${dnscrypt_proxy_pidfile_tmp} -l ${dnscrypt_proxy_logfile_tmp} -u ${dnscrypt_proxy_uid_tmp} -R ${dnscrypt_proxy_resolver_tmp}"
+
+    pidfile=${dnscrypt_proxy_pidfile_tmp}
+
+    _rc_restart_done=false # workaround for: service dnscrypt-proxy restart
+
+    run_rc_command "$1"
+done

Modified: head/dns/dnscrypt-proxy/files/pkg-message.in
==============================================================================
--- head/dns/dnscrypt-proxy/files/pkg-message.in	Mon Sep 14 21:51:52 2015	(r396938)
+++ head/dns/dnscrypt-proxy/files/pkg-message.in	Mon Sep 14 22:29:08 2015	(r396939)
@@ -1,18 +1,13 @@
 
 This port/software comes all 'working out of the box'.
 
-By default this port is using OpenDNS' resolvers,
-but other nameservers are also possible.
-
-To view available options, run:
-%%PREFIX%%/sbin/dnscrypt-proxy --help
-or read the manual: `man dnscrypt-proxy`
-
-You might like to adjust
-%%ETCDIR%%/rc.d/dnscrypt-proxy
-accordingly with your needs and/or preferences.
+By default this port is using OpenDNS' resolvers, other services are possible.
 
 To enable dnscrypt-proxy at boot:
 echo dnscrypt_proxy_enable=\"YES\" >> /etc/rc.conf
+echo dnscrypt_proxy_flags=\"-a 127.0.0.2\" >> /etc/rc.conf
 
+To view available options, run:
+%%PREFIX%%/sbin/dnscrypt-proxy --help
+or read the manual: `man dnscrypt-proxy`
 

Added: head/dns/dnscrypt-proxy/files/pkg-message_multi.in
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/dns/dnscrypt-proxy/files/pkg-message_multi.in	Mon Sep 14 22:29:08 2015	(r396939)
@@ -0,0 +1,19 @@
+
+This port/software comes all 'working out of the box'.
+
+By default this port is using OpenDNS' resolvers, other services are possible.
+
+To enable dnscrypt-proxy at boot:
+echo dnscrypt_proxy_enable=\"YES\"            >> /etc/rc.conf
+echo dnscrypt_proxy_instances=\"dnscrypt_proxy_1 dnscrypt_proxy_2 dnscrypt_proxy_3\" >> /etc/rc.conf
+echo dnscrypt_proxy_1_resolver=\"soltysiak\"  >> /etc/rc.conf
+echo dnscrypt_proxy_1_flags=\"-a 127.0.0.2\"  >> /etc/rc.conf
+echo dnscrypt_proxy_2_resolver=\"okturtles\"  >> /etc/rc.conf
+echo dnscrypt_proxy_2_flags=\"-a 127.0.0.3\"  >> /etc/rc.conf
+echo dnscrypt_proxy_3_resolver=\"cypherpunk\" >> /etc/rc.conf
+echo dnscrypt_proxy_3_flags=\"-a 127.0.0.4\"  >> /etc/rc.conf
+
+To view available options, run:
+%%PREFIX%%/sbin/dnscrypt-proxy --help
+or read the manual: `man dnscrypt-proxy`
+



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201509142229.t8EMT83I004705>