Lines 1-71
Link Here
|
1 |
#!/bin/sh |
1 |
#!/bin/sh |
2 |
# |
2 |
# |
3 |
# $FreeBSD$ |
3 |
# $FreeBSD$ |
4 |
# |
4 |
# |
5 |
# PROVIDE: dnscrypt_proxy |
5 |
# PROVIDE: dnscrypt_proxy |
6 |
# REQUIRE: SERVERS cleanvar ldconfig |
6 |
# REQUIRE: SERVERS cleanvar ldconfig |
7 |
# BEFORE: named local_unbound unbound |
7 |
# BEFORE: named local_unbound unbound |
8 |
# KEYWORD: shutdown |
8 |
# KEYWORD: shutdown |
9 |
# |
9 |
# |
10 |
# Add the following lines to /etc/rc.conf to enable dnscrypt-proxy: |
10 |
# Add the following lines to /etc/rc.conf to enable dnscrypt-proxy: |
11 |
# |
11 |
# |
12 |
# dnscrypt_proxy_instances (str): Set to "dnscrypt_proxy" by default. |
12 |
# dnscrypt_proxy_instances (str): Set to "dnscrypt_proxy" by default. |
13 |
# List of dnscrypt_proxy instance id's, |
13 |
# List of dnscrypt_proxy instance id's, |
14 |
# e.g. "dnscrypt_proxy_1 dnscrypt_proxy_2", etc. |
14 |
# e.g. "dnscrypt_proxy_1 dnscrypt_proxy_2", etc. |
15 |
# {instance_id}_enable (bool): Set to NO by default. |
15 |
# {instance_id}_enable (bool): Set to NO by default. |
16 |
# Set to YES to enable dnscrypt-proxy. |
16 |
# Set to YES to enable dnscrypt-proxy. |
17 |
# {instance_id}_uid (str): Set to "_dnscrypt-proxy" by default. |
17 |
# {instance_id}_uid (str): Set to "_dnscrypt-proxy" by default. |
18 |
# User to switch to after starting. |
18 |
# User to switch to after starting. |
19 |
# {instance_id}_resolver (str): Set to "opendns" by default. |
19 |
# {instance_id}_resolver (str): Set to "opendns" by default. |
20 |
# Choose a different upstream resolver. |
20 |
# Choose a different upstream resolver. |
21 |
# {instance_id}_pidfile (str): default: "/var/run/dnscrypt-proxy.pid" |
21 |
# {instance_id}_pidfile (str): default: "/var/run/dnscrypt-proxy.pid" |
22 |
# Location of pid file. |
22 |
# Location of pid file. |
23 |
# {instance_id}_logfile (str): default: "/var/log/dnscrypt-proxy.log" |
23 |
# {instance_id}_logfile (str): default: "/var/log/dnscrypt-proxy.log" |
24 |
# Location of log file. |
24 |
# Location of log file. |
25 |
# |
25 |
# |
26 |
# To redirect a local resolver through dnscrypt-proxy, point it at 127.0.0.2 |
26 |
# To redirect a local resolver through dnscrypt-proxy, point it at 127.0.0.2 |
27 |
# and add the following to rc.conf: |
27 |
# and add the following to rc.conf: |
28 |
# ifconfig_lo0_alias0="inet 127.0.0.2 netmask 0xffffffff" |
28 |
# ifconfig_lo0_alias0="inet 127.0.0.2 netmask 0xffffffff" |
29 |
# dnscrypt_proxy_flags='-a 127.0.0.2' |
29 |
# dnscrypt_proxy_flags='-a 127.0.0.2' |
30 |
|
30 |
|
31 |
. /etc/rc.subr |
31 |
. /etc/rc.subr |
32 |
|
32 |
|
33 |
name=dnscrypt_proxy |
33 |
name=dnscrypt_proxy |
34 |
rcvar=dnscrypt_proxy_enable |
34 |
rcvar=dnscrypt_proxy_enable |
35 |
|
35 |
|
36 |
load_rc_config ${name} |
36 |
load_rc_config ${name} |
37 |
|
37 |
|
38 |
: ${dnscrypt_proxy_instances="${name}"} |
38 |
: ${dnscrypt_proxy_instances="${name}"} |
39 |
: ${dnscrypt_proxy_enable:=NO} |
39 |
: ${dnscrypt_proxy_enable:=NO} |
40 |
|
40 |
|
41 |
dnscrypt_proxy_enable_tmp=${dnscrypt_proxy_enable} |
41 |
dnscrypt_proxy_enable_tmp=${dnscrypt_proxy_enable} |
42 |
|
42 |
|
43 |
command=%%PREFIX%%/sbin/dnscrypt-proxy |
43 |
command=%%PREFIX%%/sbin/dnscrypt-proxy |
44 |
procname=%%PREFIX%%/sbin/dnscrypt-proxy |
44 |
procname=%%PREFIX%%/sbin/dnscrypt-proxy |
45 |
|
45 |
|
46 |
for i in $dnscrypt_proxy_instances; do |
46 |
for i in $dnscrypt_proxy_instances; do |
47 |
name=${i} |
47 |
name=${i} |
48 |
|
48 |
|
49 |
eval ${name}_enable=${dnscrypt_proxy_enable_tmp} |
49 |
eval ${name}_enable=${dnscrypt_proxy_enable_tmp} |
50 |
rcvar=${name}_enable |
50 |
rcvar=${name}_enable |
51 |
|
51 |
|
52 |
load_rc_config ${i} |
52 |
load_rc_config ${i} |
53 |
|
53 |
|
54 |
eval dnscrypt_proxy_uid_tmp=\${${i}_uid} |
54 |
eval dnscrypt_proxy_uid_tmp=\${${i}_uid} |
55 |
eval dnscrypt_proxy_resolver_tmp=\${${i}_resolver} |
55 |
eval dnscrypt_proxy_resolver_tmp=\${${i}_resolver} |
56 |
eval dnscrypt_proxy_pidfile_tmp=\${${i}_pidfile} |
56 |
eval dnscrypt_proxy_pidfile_tmp=\${${i}_pidfile} |
57 |
eval dnscrypt_proxy_logfile_tmp=\${${i}_logfile} |
57 |
eval dnscrypt_proxy_logfile_tmp=\${${i}_logfile} |
58 |
|
58 |
|
59 |
: ${dnscrypt_proxy_uid_tmp:=_dnscrypt-proxy} # User to run daemon as |
59 |
: ${dnscrypt_proxy_uid_tmp:=_dnscrypt-proxy} # User to run daemon as |
60 |
: ${dnscrypt_proxy_resolver_tmp:=cisco} # resolver to use |
60 |
: ${dnscrypt_proxy_resolver_tmp:=random} # resolver to use |
61 |
: ${dnscrypt_proxy_pidfile_tmp:=/var/run/${i}.pid} # Path to pid file |
61 |
: ${dnscrypt_proxy_pidfile_tmp:=/var/run/${i}.pid} # Path to pid file |
62 |
: ${dnscrypt_proxy_logfile_tmp:=/var/log/${i}.log} # Path to log file |
62 |
: ${dnscrypt_proxy_logfile_tmp:=/var/log/${i}.log} # Path to log file |
63 |
|
63 |
|
64 |
command_args="-d -p ${dnscrypt_proxy_pidfile_tmp} -l ${dnscrypt_proxy_logfile_tmp} -u ${dnscrypt_proxy_uid_tmp} -R ${dnscrypt_proxy_resolver_tmp}" |
64 |
command_args="-d -p ${dnscrypt_proxy_pidfile_tmp} -l ${dnscrypt_proxy_logfile_tmp} -u ${dnscrypt_proxy_uid_tmp} -R ${dnscrypt_proxy_resolver_tmp}" |
65 |
|
65 |
|
66 |
pidfile=${dnscrypt_proxy_pidfile_tmp} |
66 |
pidfile=${dnscrypt_proxy_pidfile_tmp} |
67 |
|
67 |
|
68 |
_rc_restart_done=false # workaround for: service dnscrypt-proxy restart |
68 |
_rc_restart_done=false # workaround for: service dnscrypt-proxy restart |
69 |
|
69 |
|
70 |
run_rc_command "$1" |
70 |
run_rc_command "$1" |
71 |
done |
71 |
done |