gogs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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. LOGPATH=${GOGS_HOME}/log
  29. LOGFILE=${LOGPATH}/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. # exit if logpath dir is not created.
  36. [ -x ${LOGPATH} ] || exit 0
  37. DAEMON_OPTS="--check $NAME"
  38. # Set additional options, if any
  39. [ ! -z "$GOGS_USER" ] && DAEMON_OPTS="$DAEMON_OPTS --user=${GOGS_USER}"
  40. start() {
  41. cd ${GOGS_HOME}
  42. echo -n "Starting ${SERVICENAME}: "
  43. daemon $DAEMON_OPTS "${GOGS_PATH} web > ${LOGFILE} 2>&1 &"
  44. RETVAL=$?
  45. echo
  46. [ $RETVAL = 0 ] && touch ${LOCKFILE}
  47. return $RETVAL
  48. }
  49. stop() {
  50. cd ${GOGS_HOME}
  51. echo -n "Shutting down ${SERVICENAME}: "
  52. killproc ${NAME}
  53. RETVAL=$?
  54. echo
  55. [ $RETVAL = 0 ] && rm -f ${LOCKFILE}
  56. }
  57. case "$1" in
  58. start)
  59. status ${NAME} > /dev/null 2>&1 && exit 0
  60. start
  61. ;;
  62. stop)
  63. stop
  64. ;;
  65. status)
  66. status ${NAME}
  67. ;;
  68. restart)
  69. stop
  70. start
  71. ;;
  72. reload)
  73. stop
  74. start
  75. ;;
  76. *)
  77. echo "Usage: ${NAME} {start|stop|status|restart}"
  78. exit 1
  79. ;;
  80. esac
  81. exit $RETVAL