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