rc.bittorrent 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #!@l_prefix@/lib/openpkg/bash @l_prefix@/etc/rc
  2. ##
  3. ## rc.bittorrent -- Run-Commands
  4. ##
  5. %config
  6. bittorrent_enable="$openpkg_rc_def"
  7. bittorrent_port="6969"
  8. bittorrent_log_prolog="true"
  9. bittorrent_log_epilog="true"
  10. bittorrent_log_numfiles="10"
  11. bittorrent_log_minsize="1M"
  12. bittorrent_log_complevel="9"
  13. %common
  14. bittorrent_datafile="@l_prefix@/var/bittorrent/bttrack.data"
  15. bittorrent_logfile="@l_prefix@/var/bittorrent/bttrack.log"
  16. bittorrent_pidfile="@l_prefix@/var/bittorrent/bttrack.pid"
  17. bittorrent_signal () {
  18. [ -f $bittorrent_pidfile ] \
  19. && kill -$1 `cat $bittorrent_pidfile`
  20. }
  21. %status -u @l_susr@ -o
  22. bittorrent_usable="no"
  23. bittorrent_active="no"
  24. echo "bittorrent_enable=\"$bittorrent_enable\""
  25. echo "bittorrent_usable=\"$bittorrent_usable\""
  26. echo "bittorrent_active=\"$bittorrent_active\""
  27. %start -p 100 -u @l_rusr@
  28. rcService bittorrent enable yes || exit 0
  29. rcService bittorrent active yes && exit 0
  30. ( nohup @l_prefix@/bin/bttrack \
  31. --port $bittorrent_port \
  32. --dfile $bittorrent_datafile \
  33. >>$bittorrent_logfile \
  34. </dev/null 2>/dev/null &
  35. echo $! >$bittorrent_pidfile
  36. ) >/dev/null 2>&1
  37. %stop -p 100 -u @l_rusr@
  38. rcService bittorrent enable yes || exit 0
  39. rcService bittorrent active no && exit 0
  40. bittorrent_signal TERM
  41. sleep 2
  42. rm -f $bittorrent_pidfile 2>/dev/null || true
  43. %daily -u @l_susr@
  44. rcService bittorrent enable yes || exit 0
  45. shtool rotate -f \
  46. -n ${bittorrent_log_numfiles} -s ${bittorrent_log_minsize} -d \
  47. -z ${bittorrent_log_complevel} -m 644 -o @l_rusr@ -g @l_rgrp@ \
  48. -P "${bittorrent_log_prolog}" \
  49. -E "${bittorrent_log_epilog} && rc bittorrent restart" \
  50. $bittorrent_logfile