Lines 11-19
Link Here
|
11 |
# they are command line options. |
11 |
# they are command line options. |
12 |
# |
12 |
# |
13 |
# tor_enable (bool): Set it to "YES" to enable tor. Default: NO |
13 |
# tor_enable (bool): Set it to "YES" to enable tor. Default: NO |
|
|
14 |
# tor_instances (str): Set it to "YES" to enable tor. Default: "" |
14 |
# tor_conf (str): Points to your torrc file. |
15 |
# tor_conf (str): Points to your torrc file. |
15 |
# Default: %%PREFIX%%/etc/tor/torrc |
16 |
# Default: %%PREFIX%%/etc/tor/torrc |
16 |
# tor_user (str): Tor daemon user. Default: _tor |
17 |
# tor_user (str): Tor daemon user. Default: %%USER%% |
|
|
18 |
# tor_group (str): Tor daemon user. Default: %%GROUP%% |
19 |
# tor_pidfile (str): Tor pid file. Default: /var/run/tor/tor.pid |
17 |
# tor_datadir (str): Tor datadir. Default: /var/db/tor |
20 |
# tor_datadir (str): Tor datadir. Default: /var/db/tor |
18 |
# |
21 |
# |
19 |
|
22 |
|
Lines 25-35
Link Here
|
25 |
load_rc_config ${name} |
28 |
load_rc_config ${name} |
26 |
|
29 |
|
27 |
: ${tor_enable="NO"} |
30 |
: ${tor_enable="NO"} |
|
|
31 |
: ${tor_instances=""} |
28 |
: ${tor_conf="%%PREFIX%%/etc/tor/torrc"} |
32 |
: ${tor_conf="%%PREFIX%%/etc/tor/torrc"} |
29 |
: ${tor_user="%%USER%%"} |
33 |
: ${tor_user="%%USER%%"} |
|
|
34 |
: ${tor_group="%%GROUP%%"} |
30 |
: ${tor_pidfile="/var/run/tor/tor.pid"} |
35 |
: ${tor_pidfile="/var/run/tor/tor.pid"} |
31 |
: ${tor_datadir="/var/db/tor"} |
36 |
: ${tor_datadir="/var/db/tor"} |
32 |
|
37 |
|
|
|
38 |
instance=${2} |
39 |
if [ -n "${instance}" ]; then |
40 |
# extended instance definition: parameters are set explicitly |
41 |
# the instance definition: inst_name{:inst_conf:inst_user:inst_group:inst_pidfile:inst_data_dir} |
42 |
inst_def=${instance} |
43 |
inst_name=${inst_def%%:*} |
44 |
inst_def=${inst_def#$inst_name} |
45 |
if [ -n "$inst_def" ]; then |
46 |
inst_def=${inst_def#:} |
47 |
tor_conf=${inst_def%%:*} |
48 |
inst_def=${inst_def#$tor_conf:} |
49 |
tor_user=${inst_def%%:*} |
50 |
inst_def=${inst_def#$tor_user:} |
51 |
tor_group=${inst_def%%:*} |
52 |
inst_def=${inst_def#$tor_group:} |
53 |
tor_pidfile=${inst_def%%:*} |
54 |
inst_def=${inst_def#$tor_pidfile:} |
55 |
tor_datadir=${inst_def#$tor_pidfile:} |
56 |
if [ -z "${tor_conf}" -o -z "${tor_user}" -o -z "${tor_group}" -o -z "${tor_pidfile}" -o -z "${tor_datadir}" ]; then |
57 |
warn "invalid tor instance ${inst_name} settings" |
58 |
exit 1 |
59 |
fi |
60 |
else |
61 |
# short instance definition: default parameters are used |
62 |
tor_conf=${tor_conf}@${inst_name} |
63 |
tor_pidfile=${tor_pidfile}@${inst_name} |
64 |
tor_datadir=${tor_datadir}/instance@${inst_name} |
65 |
fi |
66 |
if ! [ -r ${tor_conf} ]; then |
67 |
warn "tor instance ${inst_name} config file ${tor_conf} doesn't exist or isn't readable" |
68 |
warn "you can copy the sample config %%PREFIX%%/etc/tor/torrc.sample and modify it" |
69 |
exit 1 |
70 |
fi |
71 |
if ! [ -d ${tor_datadir} ]; then |
72 |
mkdir -p ${tor_datadir} && \ |
73 |
chown ${tor_user}:${tor_group} ${tor_datadir} && \ |
74 |
chmod 0700 ${tor_datadir} && \ |
75 |
echo "${name}: created the instance data directory ${tor_datadir}" |
76 |
fi |
77 |
fi |
78 |
|
79 |
if [ -z "${instance}" -a -n "${tor_instances}" ]; then |
80 |
for i in ${tor_instances}; do |
81 |
%%PREFIX%%/etc/rc.d/tor $1 ${i} || warn "$1 failed for the tor instance $i" |
82 |
done |
83 |
fi |
84 |
|
33 |
required_files=${tor_conf} |
85 |
required_files=${tor_conf} |
34 |
required_dirs=${tor_datadir} |
86 |
required_dirs=${tor_datadir} |
35 |
pidfile=${tor_pidfile} |
87 |
pidfile=${tor_pidfile} |