michael@789: #!@l_prefix@/bin/openpkg rc michael@789: ## michael@789: ## rc.tor -- Run-Commands michael@789: ## michael@789: michael@789: %config michael@789: tor_enable="$openpkg_rc_def" michael@789: tor_log_prolog="true" michael@789: tor_log_epilog="true" michael@789: tor_log_numfiles="10" michael@789: tor_log_minsize="1M" michael@789: tor_log_complevel="9" michael@789: michael@789: %common michael@789: tor_logfile="@l_prefix@/var/tor/tor.log" michael@789: tor_pidfile="@l_prefix@/var/tor/tor.pid" michael@789: tor_signal () { michael@789: [ -f $tor_pidfile ] && kill -$1 `cat $tor_pidfile` michael@789: } michael@789: michael@791: %status -u @l_susr@ -o michael@789: tor_usable="unknown" michael@789: tor_active="no" michael@789: rcService tor enable yes && \ michael@789: tor_signal 0 && tor_active="yes" michael@789: echo "tor_enable=\"$tor_enable\"" michael@789: echo "tor_usable=\"$tor_usable\"" michael@789: echo "tor_active=\"$tor_active\"" michael@789: michael@791: %start -u @l_susr@ michael@789: rcService tor enable yes || exit 0 michael@789: rcService tor active yes && exit 0 michael@789: @l_prefix@/bin/tor michael@789: michael@791: %stop -u @l_susr@ michael@789: rcService tor enable yes || exit 0 michael@789: rcService tor active no && exit 0 michael@789: tor_signal TERM michael@789: sleep 2 michael@789: rm -f $tor_pidfile >/dev/null 2>&1 || true michael@789: michael@791: %restart -u @l_susr@ michael@789: rcService tor enable yes || exit 0 michael@789: rcService tor active no && exit 0 michael@789: rc tor stop start michael@789: michael@791: %reload -u @l_susr@ michael@789: rcService tor enable yes || exit 0 michael@789: rcService tor active no && exit 0 michael@789: tor_signal HUP michael@789: michael@789: %daily -u @l_susr@ michael@789: rcService tor enable yes || exit 0 michael@789: shtool rotate -f \ michael@789: -n ${tor_log_numfiles} -s ${tor_log_minsize} -d \ michael@791: -z ${tor_log_complevel} -m 664 -o @l_susr@ -g @l_rgrp@ \ michael@789: -P "${tor_log_prolog}" \ michael@789: -E "${tor_log_epilog}; rc tor restart" \ michael@789: ${tor_logfile} michael@789: