tor/rc.tor

changeset 789
cbbc8daa8174
child 791
a5b2210360f9
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/tor/rc.tor	Wed Jan 22 21:02:10 2014 +0100
     1.3 @@ -0,0 +1,60 @@
     1.4 +#!@l_prefix@/bin/openpkg rc
     1.5 +##
     1.6 +##  rc.tor -- Run-Commands
     1.7 +##
     1.8 +
     1.9 +%config
    1.10 +    tor_enable="$openpkg_rc_def"
    1.11 +    tor_log_prolog="true"
    1.12 +    tor_log_epilog="true"
    1.13 +    tor_log_numfiles="10"
    1.14 +    tor_log_minsize="1M"
    1.15 +    tor_log_complevel="9"
    1.16 +
    1.17 +%common
    1.18 +    tor_logfile="@l_prefix@/var/tor/tor.log"
    1.19 +    tor_pidfile="@l_prefix@/var/tor/tor.pid"
    1.20 +    tor_signal () {
    1.21 +        [ -f $tor_pidfile ] && kill -$1 `cat $tor_pidfile`
    1.22 +    }
    1.23 +
    1.24 +%status -u @l_rusr@ -o
    1.25 +    tor_usable="unknown"
    1.26 +    tor_active="no"
    1.27 +    rcService tor enable yes && \
    1.28 +        tor_signal 0 && tor_active="yes"
    1.29 +    echo "tor_enable=\"$tor_enable\""
    1.30 +    echo "tor_usable=\"$tor_usable\""
    1.31 +    echo "tor_active=\"$tor_active\""
    1.32 +
    1.33 +%start -u @l_rusr@
    1.34 +    rcService tor enable yes || exit 0
    1.35 +    rcService tor active yes && exit 0
    1.36 +    @l_prefix@/bin/tor
    1.37 +
    1.38 +%stop -u @l_rusr@
    1.39 +    rcService tor enable yes || exit 0
    1.40 +    rcService tor active no  && exit 0
    1.41 +    tor_signal TERM
    1.42 +    sleep 2
    1.43 +    rm -f $tor_pidfile >/dev/null 2>&1 || true
    1.44 +
    1.45 +%restart -u @l_rusr@
    1.46 +    rcService tor enable yes || exit 0
    1.47 +    rcService tor active no  && exit 0
    1.48 +    rc tor stop start
    1.49 +
    1.50 +%reload -u @l_rusr@
    1.51 +    rcService tor enable yes || exit 0
    1.52 +    rcService tor active no  && exit 0
    1.53 +    tor_signal HUP
    1.54 +
    1.55 +%daily -u @l_susr@
    1.56 +    rcService tor enable yes || exit 0
    1.57 +    shtool rotate -f \
    1.58 +        -n ${tor_log_numfiles} -s ${tor_log_minsize} -d \
    1.59 +        -z ${tor_log_complevel} -m 664 -o @l_rusr@ -g @l_rgrp@ \
    1.60 +        -P "${tor_log_prolog}" \
    1.61 +        -E "${tor_log_epilog}; rc tor restart" \
    1.62 +        ${tor_logfile}
    1.63 +

mercurial