gogs 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. PID=/var/run/$NAME.pid
  28. LOCKFILE=/var/lock/subsys/gogs
  29. LOGFILE=${GOGS_HOME}/log/gogs.log
  30. RETVAL=0
  31. # Read configuration from /etc/sysconfig/gogs to override defaults
  32. [ -r /etc/sysconfig/$NAME ] && ./etc/sysconfig/$NAME
  33. # Don't do anything if nothing is installed
  34. [ -x ${GOGS_PATH} ] || exit 0
  35. DAEMON_OPTS=""
  36. # Set additional options, if any
  37. [ ! -z "$GOGS_USER" ] && DAEMON_OPTS="$DAEMON_OPTS --user=${GOGS_USER}"
  38. start() {
  39. cd ${GOGS_HOME}
  40. echo -n "Starting ${SERVICENAME}: "
  41. daemon $DAEMON_OPTS --pidfile=${PID} "${GOGS_PATH} web 2>&1 > ${LOGFILE} &"
  42. echo $! > ${PID}
  43. RETVAL=$?
  44. echo
  45. [ $RETVAL = 0 ] && touch ${LOCKFILE}
  46. return $RETVAL
  47. }
  48. stop() {
  49. cd ${GOGS_HOME}
  50. echo -n "Shutting down ${SERVICENAME}: "
  51. killproc -p ${PID} ${NAME}
  52. RETVAL=$?
  53. echo
  54. [ $RETVAL = 0 ] && rm -f ${LOCKFILE} ${PID}
  55. }
  56. case "$1" in
  57. start)
  58. status ${NAME} > /dev/null 2>&1 && exit 0
  59. start
  60. ;;
  61. stop)
  62. stop
  63. ;;
  64. status)
  65. status -p ${PID} ${NAME}
  66. ;;
  67. restart)
  68. stop
  69. start
  70. ;;
  71. reload)
  72. stop
  73. start
  74. ;;
  75. *)
  76. echo "Usage: ${NAME} {start|stop|status|restart}"
  77. exit 1
  78. ;;
  79. esac
  80. exit $RETVAL