1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- #!/bin/sh
- . /etc/init.d/functions
- NAME=gogs
- GOGS_HOME=/home/git/gogs
- GOGS_PATH=${GOGS_HOME}/$NAME
- GOGS_USER=git
- SERVICENAME="Gogs"
- LOCKFILE=/var/lock/subsys/gogs
- LOGPATH=${GOGS_HOME}/log
- LOGFILE=${LOGPATH}/gogs.log
- RETVAL=0
- [ -r /etc/sysconfig/$NAME ] && . /etc/sysconfig/$NAME
- [ -x ${GOGS_PATH} ] || exit 0
- [ -x ${LOGPATH} ] || exit 0
- DAEMON_OPTS="--check $NAME"
- [ ! -z "$GOGS_USER" ] && DAEMON_OPTS="$DAEMON_OPTS --user=${GOGS_USER}"
- start() {
- cd ${GOGS_HOME}
- echo -n "Starting ${SERVICENAME}: "
- daemon $DAEMON_OPTS "${GOGS_PATH} web > ${LOGFILE} 2>&1 &"
- 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
|