Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- #
- # /etc/rc.d/init.d/gogs
- #
- # Runs the Gogs Go Git Service.
- #
- #
- # chkconfig: - 85 15
- #
- ### BEGIN INIT INFO
- # Provides: gogs
- # Required-Start: $remote_fs $syslog
- # Required-Stop: $remote_fs $syslog
- # Default-Start: 2 3 4 5
- # Default-Stop: 0 1 6
- # Short-Description: Start gogs at boot time.
- # Description: Control gogs.
- ### END INIT INFO
- # Source function library.
- . /etc/init.d/functions
- # Default values
- NAME=gogs
- GOGS_HOME=/root/gogs/gogs
- GOGS_PATH=${GOGS_HOME}/$NAME
- GOGS_USER=root
- SERVICENAME="Gogs Go Git Service"
- LOCKFILE=/var/lock/subsys/gogs
- LOGPATH=${GOGS_HOME}/log
- LOGFILE=${LOGPATH}/gogs.log
- RETVAL=0
- # tested with these environment variables. with these or without these makes no difference
- USER=root
- USERNAME=root
- # Read configuration from /etc/sysconfig/gogs to override defaults
- [ -r /etc/sysconfig/$NAME ] && . /etc/sysconfig/$NAME
- # Don't do anything if nothing is installed
- [ -x ${GOGS_PATH} ] || exit 0
- # exit if logpath dir is not created.
- [ -x ${LOGPATH} ] || exit 0
- DAEMON_OPTS="--check $NAME --user=git"
- # Set additional options, if any
- [ ! -z "$GOGS_USER" ] && DAEMON_OPTS="$DAEMON_OPTS --user=${GOGS_USER}"
- start() {
- cd ${GOGS_HOME}
- echo -n "Starting ${SERVICENAME}: "
- # this is the original code. doesn't work and gives an error.
- daemon $DAEMON_OPTS "${GOGS_PATH} web --port=30000 &"
- # 2nd variant tested by me. does not work either
- # /root/gogs/gogs/gogs web --port=30000 &
- RETVAL=$?
- echo
- [ $RETVAL = 0 ] && touch ${LOCKFILE}
- return $RETVAL
- }
- stop() {
- cd ${GOGS_HOME}
- echo -n "Shutting down ${SERVICENAME}: "
- killproc ${NAME}
- RETVAL=$?
- echo
- [ $RETVAL = 0 ] && rm -f ${LOCKFILE}
- }
- case "$1" in
- start)
- status ${NAME} > /dev/null 2>&1 && exit 0
- start
- ;;
- stop)
- stop
- ;;
- status)
- status ${NAME}
- ;;
- restart)
- stop
- start
- ;;
- reload)
- stop
- start
- ;;
- *)
- echo "Usage: ${NAME} {start|stop|status|restart}"
- exit 1
- ;;
- esac
- exit $RETVAL
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement