gogs 1.9 KB

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