|
1 #!@l_prefix@/bin/openpkg rc |
|
2 ## |
|
3 ## rc.tor -- Run-Commands |
|
4 ## |
|
5 |
|
6 %config |
|
7 tor_enable="$openpkg_rc_def" |
|
8 tor_log_prolog="true" |
|
9 tor_log_epilog="true" |
|
10 tor_log_numfiles="10" |
|
11 tor_log_minsize="1M" |
|
12 tor_log_complevel="9" |
|
13 |
|
14 %common |
|
15 tor_logfile="@l_prefix@/var/tor/tor.log" |
|
16 tor_pidfile="@l_prefix@/var/tor/tor.pid" |
|
17 tor_signal () { |
|
18 [ -f $tor_pidfile ] && kill -$1 `cat $tor_pidfile` |
|
19 } |
|
20 |
|
21 %status -u @l_rusr@ -o |
|
22 tor_usable="unknown" |
|
23 tor_active="no" |
|
24 rcService tor enable yes && \ |
|
25 tor_signal 0 && tor_active="yes" |
|
26 echo "tor_enable=\"$tor_enable\"" |
|
27 echo "tor_usable=\"$tor_usable\"" |
|
28 echo "tor_active=\"$tor_active\"" |
|
29 |
|
30 %start -u @l_rusr@ |
|
31 rcService tor enable yes || exit 0 |
|
32 rcService tor active yes && exit 0 |
|
33 @l_prefix@/bin/tor |
|
34 |
|
35 %stop -u @l_rusr@ |
|
36 rcService tor enable yes || exit 0 |
|
37 rcService tor active no && exit 0 |
|
38 tor_signal TERM |
|
39 sleep 2 |
|
40 rm -f $tor_pidfile >/dev/null 2>&1 || true |
|
41 |
|
42 %restart -u @l_rusr@ |
|
43 rcService tor enable yes || exit 0 |
|
44 rcService tor active no && exit 0 |
|
45 rc tor stop start |
|
46 |
|
47 %reload -u @l_rusr@ |
|
48 rcService tor enable yes || exit 0 |
|
49 rcService tor active no && exit 0 |
|
50 tor_signal HUP |
|
51 |
|
52 %daily -u @l_susr@ |
|
53 rcService tor enable yes || exit 0 |
|
54 shtool rotate -f \ |
|
55 -n ${tor_log_numfiles} -s ${tor_log_minsize} -d \ |
|
56 -z ${tor_log_complevel} -m 664 -o @l_rusr@ -g @l_rgrp@ \ |
|
57 -P "${tor_log_prolog}" \ |
|
58 -E "${tor_log_epilog}; rc tor restart" \ |
|
59 ${tor_logfile} |
|
60 |