gogs 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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