rc.git 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #!@l_prefix@/bin/openpkg rc
  2. ##
  3. ## rc.git -- Run-Commands
  4. ##
  5. %config
  6. git_enable="$openpkg_rc_def"
  7. git_daemon="no"
  8. git_daemon_flags=""
  9. git_daemon_host="127.0.0.1"
  10. git_daemon_port="9418"
  11. git_daemon_user="@l_rusr@"
  12. git_daemon_group="@l_rgrp@"
  13. git_daemon_basedir="@l_prefix@/var/git/db"
  14. git_log_prolog="true"
  15. git_log_epilog="true"
  16. git_log_numfiles="10"
  17. git_log_minsize="1M"
  18. git_log_complevel="9"
  19. %common
  20. git_daemon_pidfile="@l_prefix@/var/git/run/git-daemon.pid"
  21. git_daemon_logfile="@l_prefix@/var/git/run/git-daemon.log"
  22. git_daemon_signal () {
  23. [ -f $git_daemon_pidfile ] && kill -$1 `cat $git_daemon_pidfile`
  24. }
  25. %status -u @l_susr@ -o
  26. git_usable="unknown"
  27. git_active="no"
  28. rcService git enable yes && \
  29. rcVarIsYes git_daemon && \
  30. git_daemon_signal 0 && \
  31. git_active="yes"
  32. echo "git_enable=\"$git_enable\""
  33. echo "git_usable=\"$git_usable\""
  34. echo "git_active=\"$git_active\""
  35. %start -u @l_susr@
  36. rcService git enable yes || exit 0
  37. rcService git active yes && exit 0
  38. if rcVarIsYes git_daemon; then
  39. ( nohup @l_prefix@/bin/git daemon \
  40. --reuseaddr \
  41. --listen="$git_daemon_host" \
  42. --port="$git_daemon_port" \
  43. --user="$git_daemon_user" \
  44. --group="$git_daemon_group" \
  45. --base-path="$git_daemon_basedir" \
  46. $git_daemon_flags \
  47. </dev/null >>$git_daemon_logfile 2>&1 &
  48. echo $! >$git_daemon_pidfile
  49. ) </dev/null >/dev/null 2>&1
  50. fi
  51. %stop -u @l_susr@
  52. rcService git enable yes || exit 0
  53. rcService git active no && exit 0
  54. if rcVarIsYes git_daemon; then
  55. git_daemon_signal TERM
  56. sleep 1
  57. rm -f $git_daemon_pidfile 2>/dev/null || true
  58. fi
  59. %restart -u @l_susr@
  60. rcService git enable yes || exit 0
  61. rcService git active no && exit 0
  62. rc git stop start
  63. %daily -u @l_susr@
  64. rcService git enable yes || exit 0
  65. shtool rotate -f \
  66. -n ${git_log_numfiles} -s ${git_log_minsize} -d \
  67. -z ${git_log_complevel} -m 644 -o @l_rusr@ -g @l_rusr@ \
  68. -P "${git_log_prolog}" \
  69. -E "${git_log_epilog}" \
  70. $git_daemon_logfile