rc.rsync 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #!@l_prefix@/lib/openpkg/bash @l_prefix@/etc/rc
  2. ##
  3. ## rc.rsync -- OpenPKG run-commands
  4. ##
  5. %config
  6. rsync_enable="yes"
  7. rsync_flags=""
  8. rsync_nicelevel="10"
  9. rsync_log_numfiles="5"
  10. rsync_log_minsize="512K"
  11. rsync_log_complevel="9"
  12. %common
  13. rsync_cfgfile="@l_prefix@/etc/rsync/rsync.conf"
  14. rsync_logfile="@l_prefix@/var/rsync/rsync.log"
  15. rsync_pidfile="@l_prefix@/var/rsync/rsync.pid"
  16. %start -p 200 -u root
  17. if opServiceEnabled rsync; then
  18. nice -n $rsync_nicelevel @l_prefix@/bin/rsync $rsync_flags \
  19. --daemon --config=$rsync_cfgfile
  20. fi
  21. %stop -p 200 -u root
  22. if opServiceEnabled rsync; then
  23. if [ -f $rsync_pidfile ]; then
  24. kill -TERM `cat $rsync_pidfile`
  25. fi
  26. fi
  27. %restart -u root
  28. if opServiceEnabled rsync; then
  29. if [ -f $rsync_pidfile ]; then
  30. kill -TERM `cat $rsync_pidfile`
  31. sleep 2
  32. fi
  33. nice -n $rsync_nicelevel @l_prefix@/bin/rsync $rsync_flags \
  34. --daemon --config=$rsync_cfgfile
  35. fi
  36. %daily -u root
  37. if opServiceEnabled rsync; then
  38. shtool rotate -f \
  39. -n ${rsync_log_numfiles} -s ${rsync_log_minsize} \
  40. -d -z ${rsync_log_complevel} -o @l_musr@ -g @l_mgrp@ -m 644 \
  41. -E "test -f $rsync_pidfile && kill -TERM `cat $rsync_pidfile`; sleep 2; \
  42. nice -n $rsync_nicelevel @l_prefix@/bin/rsync $rsync_flags --daemon --config=$rsync_cfgfile" \
  43. $rsync_logfile
  44. fi
  45. %env
  46. if opServiceEnabled rsync; then
  47. if [ -f "@l_prefix@/bin/ssh" ]; then
  48. RSYNC_RSH="@l_prefix@/bin/ssh"
  49. export RSYNC_RSH
  50. fi
  51. fi