rc.sendfile 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #!@l_prefix@/lib/openpkg/bash @l_prefix@/etc/rc
  2. ##
  3. ## rc.sendfile -- Run-Commands
  4. ##
  5. %config
  6. sendfile_enable="$openpkg_rc_def"
  7. sendfile_bind="127.0.0.1"
  8. sendfile_port="487"
  9. sendfile_flags=""
  10. sendfile_log_prolog="true"
  11. sendfile_log_epilog="true"
  12. sendfile_log_numfiles="10"
  13. sendfile_log_minsize="1M"
  14. sendfile_log_complevel="9"
  15. %common
  16. sendfile_pidfile="@l_prefix@/var/sendfile/run/sendfiled.pid"
  17. sendfile_signal () {
  18. [ -f $sendfile_pidfile ] && kill -$1 `cat $sendfile_pidfile`
  19. }
  20. sendfile_start () {
  21. ( @l_prefix@/sbin/sendfiledx ${sendfile_bind}${sendfile_bind:+:}${sendfile_port:-sendfile} \
  22. @l_prefix@/sbin/sendfiled ${sendfile_flags} \
  23. </dev/null >/dev/null 2>&1 &
  24. echo $! >$sendfile_pidfile
  25. ) </dev/null >/dev/null 2>&1
  26. }
  27. %status -u @l_susr@ -o
  28. sendfile_usable="no"
  29. sendfile_active="no"
  30. rcService sendfile enable yes && \
  31. sendfile_signal 0 && sendfile_active="yes"
  32. echo "sendfile_enable=\"$sendfile_enable\""
  33. echo "sendfile_usable=\"$sendfile_usable\""
  34. echo "sendfile_active=\"$sendfile_active\""
  35. %start -p 100 -u @l_susr@
  36. rcService sendfile enable yes || exit 0
  37. rcService sendfile active yes && exit 0
  38. sendfile_start
  39. %stop -p 900 -u @l_susr@
  40. rcService sendfile enable yes || exit 0
  41. rcService sendfile active no && exit 0
  42. sendfile_signal TERM
  43. sleep 2
  44. rm -f $sendfile_pidfile 2>/dev/null || true
  45. %restart -p 100 -u @l_susr@
  46. rcService sendfile enable yes || exit 0
  47. rcService sendfile active no && exit 0
  48. rc sendfile stop start