Advertisement
Guest User

Untitled

a guest
Mar 18th, 2016
380
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.17 KB | None | 0 0
  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.  
  11. ### BEGIN INIT INFO
  12. # Provides:          gogs
  13. # Required-Start:    $remote_fs $syslog
  14. # Required-Stop:     $remote_fs $syslog
  15. # Default-Start:     2 3 4 5
  16. # Default-Stop:      0 1 6
  17. # Short-Description: Start gogs at boot time.
  18. # Description:       Control gogs.
  19. ### END INIT INFO
  20.  
  21. # Source function library.
  22. . /etc/init.d/functions
  23.  
  24. # Default values
  25.  
  26. NAME=gogs
  27. GOGS_HOME=/root/gogs/gogs
  28. GOGS_PATH=${GOGS_HOME}/$NAME
  29. GOGS_USER=root
  30. SERVICENAME="Gogs Go Git Service"
  31. LOCKFILE=/var/lock/subsys/gogs
  32. LOGPATH=${GOGS_HOME}/log
  33. LOGFILE=${LOGPATH}/gogs.log
  34. RETVAL=0
  35.  
  36. # tested with these environment variables. with these or without these makes no difference
  37. USER=root
  38. USERNAME=root
  39.  
  40. # Read configuration from /etc/sysconfig/gogs to override defaults
  41. [ -r /etc/sysconfig/$NAME ] && . /etc/sysconfig/$NAME
  42.  
  43. # Don't do anything if nothing is installed
  44. [ -x ${GOGS_PATH} ] || exit 0
  45. # exit if logpath dir is not created.
  46. [ -x ${LOGPATH} ] || exit 0
  47.  
  48. DAEMON_OPTS="--check $NAME --user=git"
  49.  
  50. # Set additional options, if any
  51. [ ! -z "$GOGS_USER" ] && DAEMON_OPTS="$DAEMON_OPTS --user=${GOGS_USER}"
  52.  
  53. start() {
  54.   cd ${GOGS_HOME}
  55.   echo -n "Starting ${SERVICENAME}: "
  56. # this is the original code. doesn't work and gives an error.
  57.   daemon $DAEMON_OPTS "${GOGS_PATH} web --port=30000 &"
  58.  
  59. # 2nd variant tested by me. does not work either
  60. #  /root/gogs/gogs/gogs web --port=30000 &
  61.   RETVAL=$?
  62.   echo
  63.   [ $RETVAL = 0 ] && touch ${LOCKFILE}
  64.  
  65.   return $RETVAL
  66. }
  67.  
  68. stop() {
  69.   cd ${GOGS_HOME}
  70.         echo -n "Shutting down ${SERVICENAME}: "
  71.         killproc ${NAME}
  72.         RETVAL=$?
  73.         echo
  74.         [ $RETVAL = 0 ] && rm -f ${LOCKFILE}
  75. }
  76.  
  77. case "$1" in
  78.     start)
  79.         status ${NAME} > /dev/null 2>&1 && exit 0
  80.         start
  81.         ;;
  82.     stop)
  83.         stop
  84.         ;;
  85.     status)
  86.         status ${NAME}
  87.         ;;
  88.     restart)
  89.        stop
  90.         start
  91.         ;;
  92.     reload)
  93.         stop
  94.         start
  95.         ;;
  96.     *)
  97.         echo "Usage: ${NAME} {start|stop|status|restart}"
  98.         exit 1
  99.         ;;
  100. esac
  101. exit $RETVAL
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement