gogs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. #!/bin/sh
  2. #
  3. # /etc/rc.d/init.d/gogs
  4. #
  5. # Runs the Gogs Go Git Service.
  6. #
  7. #
  8. # chkconfig: - 85 15
  9. #
  10. ### BEGIN INIT INFO
  11. # Provides: gogs
  12. # Required-Start: $remote_fs $syslog
  13. # Required-Stop: $remote_fs $syslog
  14. # Default-Start: 2 3 4 5
  15. # Default-Stop: 0 1 6
  16. # Short-Description: Start gogs at boot time.
  17. # Description: Control gogs.
  18. ### END INIT INFO
  19. # Source function library.
  20. . /etc/init.d/functions
  21. # Default values
  22. NAME=gogs
  23. GOGS_HOME=/home/git/gogs
  24. GOGS_PATH=${GOGS_HOME}/$NAME
  25. GOGS_USER=git
  26. SERVICENAME="Gogs Go Git Service"
  27. LOCKFILE=/var/lock/subsys/gogs
  28. LOGFILE=${GOGS_HOME}/log/gogs.log
  29. RETVAL=0
  30. # Read configuration from /etc/sysconfig/gogs to override defaults
  31. [ -r /etc/sysconfig/$NAME ] && . /etc/sysconfig/$NAME
  32. # Don't do anything if nothing is installed
  33. [ -x ${GOGS_PATH} ] || exit 0
  34. DAEMON_OPTS="--check $NAME"
  35. # Set additional options, if any
  36. [ ! -z "$GOGS_USER" ] && DAEMON_OPTS="$DAEMON_OPTS --user=${GOGS_USER}"
  37. start() {
  38. cd ${GOGS_HOME}
  39. echo -n "Starting ${SERVICENAME}: "
  40. daemon $DAEMON_OPTS "${GOGS_PATH} web > ${LOGFILE} 2>&1 &"
  41. RETVAL=$?
  42. echo
  43. [ $RETVAL = 0 ] && touch ${LOCKFILE}
  44. return $RETVAL
  45. }
  46. stop() {
  47. cd ${GOGS_HOME}
  48. echo -n "Shutting down ${SERVICENAME}: "
  49. killproc ${NAME}
  50. RETVAL=$?
  51. echo
  52. [ $RETVAL = 0 ] && rm -f ${LOCKFILE}
  53. }
  54. case "$1" in
  55. start)
  56. status ${NAME} > /dev/null 2>&1 && exit 0
  57. start
  58. ;;
  59. stop)
  60. stop
  61. ;;
  62. status)
  63. status ${NAME}
  64. ;;
  65. restart)
  66. stop
  67. start
  68. ;;
  69. reload)
  70. stop
  71. start
  72. ;;
  73. *)
  74. echo "Usage: ${NAME} {start|stop|status|restart}"
  75. exit 1
  76. ;;
  77. esac
  78. exit $RETVAL