Lines 30-35
Link Here
|
30 |
|
30 |
|
31 |
name="tor" |
31 |
name="tor" |
32 |
rcvar=tor_enable |
32 |
rcvar=tor_enable |
|
|
33 |
exit_code=0 |
33 |
|
34 |
|
34 |
load_rc_config ${name} |
35 |
load_rc_config ${name} |
35 |
|
36 |
|
Lines 42-54
Link Here
|
42 |
: ${tor_datadir="/var/db/tor"} |
43 |
: ${tor_datadir="/var/db/tor"} |
43 |
: ${tor_disable_default_instance="NO"} |
44 |
: ${tor_disable_default_instance="NO"} |
44 |
|
45 |
|
45 |
instance=${2} |
46 |
instance=${slave_instance} |
46 |
if [ -n "${instance}" ]; then |
47 |
if [ -n "${instance}" ]; then |
47 |
# extended instance: parameters are set explicitly |
|
|
48 |
inst_def=${instance} |
48 |
inst_def=${instance} |
49 |
inst_name=${inst_def%%:*} |
49 |
inst_name=${inst_def%%:*} |
|
|
50 |
[ "${inst_name}" != "main" ] || err 1 "${name} instance can't be named 'main'" |
50 |
inst_def=${inst_def#$inst_name} |
51 |
inst_def=${inst_def#$inst_name} |
51 |
if [ -n "$inst_def" ]; then |
52 |
if [ -n "$inst_def" ]; then |
|
|
53 |
# extended instance: parameters are set explicitly |
52 |
inst_def=${inst_def#:} |
54 |
inst_def=${inst_def#:} |
53 |
tor_conf=${inst_def%%:*} |
55 |
tor_conf=${inst_def%%:*} |
54 |
inst_def=${inst_def#$tor_conf:} |
56 |
inst_def=${inst_def#$tor_conf:} |
Lines 59-65
Link Here
|
59 |
tor_pidfile=${inst_def%%:*} |
61 |
tor_pidfile=${inst_def%%:*} |
60 |
tor_datadir=${inst_def#$tor_pidfile:} |
62 |
tor_datadir=${inst_def#$tor_pidfile:} |
61 |
if [ -z "${tor_conf}" -o -z "${tor_user}" -o -z "${tor_group}" -o -z "${tor_pidfile}" -o -z "${tor_datadir}" ]; then |
63 |
if [ -z "${tor_conf}" -o -z "${tor_user}" -o -z "${tor_group}" -o -z "${tor_pidfile}" -o -z "${tor_datadir}" ]; then |
62 |
warn "invalid tor instance ${inst_name} settings" |
64 |
warn "invalid tor instance ${inst_name} settings: ${instance}" |
63 |
exit 1 |
65 |
exit 1 |
64 |
fi |
66 |
fi |
65 |
else |
67 |
else |
Lines 82-91
Link Here
|
82 |
fi |
84 |
fi |
83 |
|
85 |
|
84 |
if [ -z "${instance}" -a -n "${tor_instances}" ]; then |
86 |
if [ -z "${instance}" -a -n "${tor_instances}" ]; then |
|
|
87 |
inst_only="$2" |
88 |
inst_done=0 |
85 |
for i in ${tor_instances}; do |
89 |
for i in ${tor_instances}; do |
86 |
%%PREFIX%%/etc/rc.d/tor $1 ${i} || warn "$1 failed for the tor instance $i" |
90 |
inst_name=${i%%:*} |
|
|
91 |
if [ -z "${inst_only}" -o "${inst_name}" = "${inst_only}" ]; then |
92 |
echo -n "${name} instance ${inst_name}: " |
93 |
if ! slave_instance=${i} /usr/local/etc/rc.d/tor "$1"; then |
94 |
exit_code=1 |
95 |
fi |
96 |
inst_done=$((inst_done+1)) |
97 |
fi |
87 |
done |
98 |
done |
88 |
checkyesno tor_disable_default_instance && return 0 |
99 |
if [ -z "${inst_only}" -o "${inst_only}" = "main" ]; then |
|
|
100 |
checkyesno tor_disable_default_instance && return $exit_code |
101 |
echo -n "${name} main instance: " |
102 |
elif [ -n "${inst_only}" ]; then |
103 |
[ $inst_done -gt 0 ] || err 1 "${name} instance '$inst_only' isn't defined" |
104 |
return $exit_code |
105 |
fi |
89 |
fi |
106 |
fi |
90 |
|
107 |
|
91 |
required_files=${tor_conf} |
108 |
required_files=${tor_conf} |
Lines 95-99
Link Here
|
95 |
command_args="-f ${tor_conf} --PidFile ${tor_pidfile} --RunAsDaemon 1 --DataDirectory ${tor_datadir}" |
112 |
command_args="-f ${tor_conf} --PidFile ${tor_pidfile} --RunAsDaemon 1 --DataDirectory ${tor_datadir}" |
96 |
extra_commands="reload" |
113 |
extra_commands="reload" |
97 |
|
114 |
|
98 |
run_rc_command "$1" |
115 |
if ! run_rc_command "$1"; then |
|
|
116 |
exit_code=1 |
117 |
fi |
99 |
|
118 |
|
|
|
119 |
return $exit_code |