Fork to maintain patches against the official gitea for https://code.ceondo.com https://github.com/go-gitea/gitea

gitea 2.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. #!/bin/sh
  2. #
  3. # /etc/init.d/gitea
  4. #
  5. # Runs the Gitea Git with a cup of tea.
  6. #
  7. ### BEGIN INIT INFO
  8. # Provides: gitea
  9. # Required-Start: $remote_fs
  10. # Required-Stop: $remote_fs
  11. # Default-Start: 2 3 4 5
  12. # Default-Stop: 0 1 6
  13. # Short-Description: Start gitea at boot time.
  14. # Description: Control gitea.
  15. ### END INIT INFO
  16. # Default values
  17. NAME=gitea
  18. GITEA_HOME=/home/git/gitea
  19. GITEA_PATH=${GITEA_HOME}/$NAME
  20. GITEA_USER=git
  21. SERVICENAME="Git - with a cup of tea"
  22. LOCKFILE=/var/lock/subsys/gitea
  23. LOGPATH=${GITEA_HOME}/log
  24. LOGFILE=${LOGPATH}/error.log
  25. # gitea creates its own gitea.log from stdout
  26. RETVAL=0
  27. # Read configuration from /etc/sysconfig/gitea to override defaults
  28. [ -r /etc/sysconfig/$NAME ] && . /etc/sysconfig/$NAME
  29. # Don't do anything if nothing is installed
  30. test -x ${GITEA_PATH} || { echo "$NAME not installed";
  31. if [ "$1" = "stop" ]; then exit 0;
  32. else exit 5; fi; }
  33. # exit if logpath dir is not created.
  34. test -r ${LOGPATH} || { echo "$LOGPATH not existing";
  35. if [ "$1" = "stop" ]; then exit 0;
  36. else exit 6; fi; }
  37. # Source function library.
  38. . /etc/rc.status
  39. # Reset status of this service
  40. rc_reset
  41. case "$1" in
  42. start)
  43. echo -n "Starting ${SERVICENAME} "
  44. # As we can't use startproc, we have to check ourselves if the service is already running
  45. /sbin/checkproc ${GITEA_PATH}
  46. if [ $? -eq 0 ]; then
  47. # return skipped as service is already running
  48. (exit 5)
  49. else
  50. su - ${GITEA_USER} -c "USER=${GITEA_USER} ${GITEA_PATH} web 2>&1 >>${LOGFILE} &"
  51. fi
  52. # Remember status and be verbose
  53. rc_status -v
  54. ;;
  55. stop)
  56. echo -n "Shutting down ${SERVICENAME} "
  57. ## Stop daemon with killproc(8) and if this fails
  58. ## killproc sets the return value according to LSB.
  59. /sbin/killproc ${GITEA_PATH}
  60. # Remember status and be verbose
  61. rc_status -v
  62. ;;
  63. restart)
  64. ## Stop the service and regardless of whether it was
  65. ## running or not, start it again.
  66. $0 stop
  67. $0 start
  68. # Remember status and be quiet
  69. rc_status
  70. ;;
  71. status)
  72. echo -n "Checking for ${SERVICENAME} "
  73. ## Check status with checkproc(8), if process is running
  74. ## checkproc will return with exit status 0.
  75. # Return value is slightly different for the status command:
  76. # 0 - service up and running
  77. # 1 - service dead, but /var/run/ pid file exists
  78. # 2 - service dead, but /var/lock/ lock file exists
  79. # 3 - service not running (unused)
  80. # 4 - service status unknown :-(
  81. # 5--199 reserved (5--99 LSB, 100--149 distro, 150--199 appl.)
  82. # NOTE: checkproc returns LSB compliant status values.
  83. /sbin/checkproc ${GITEA_PATH}
  84. # NOTE: rc_status knows that we called this init script with
  85. # "status" option and adapts its messages accordingly.
  86. rc_status -v
  87. ;;
  88. *)
  89. echo "Usage: $0 {start|stop|status|restart}"
  90. exit 1
  91. ;;
  92. esac
  93. rc_exit