0
0
Fork 0
mirror of https://github.com/go-gitea/gitea synced 2024-11-04 21:29:12 +01:00
gitea/scripts/init/centos/gogs

94 lines
1.8 KiB
Text
Raw Normal View History

2014-09-29 10:41:29 +02:00
#!/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=/home/git/gogs
GOGS_PATH=${GOGS_HOME}/$NAME
GOGS_USER=git
SERVICENAME="Gogs Go Git Service"
LOCKFILE=/var/lock/subsys/gogs
2015-10-31 13:32:34 +01:00
LOGPATH=${GOGS_HOME}/log
LOGFILE=${LOGPATH}/gogs.log
2014-09-29 10:41:29 +02:00
RETVAL=0
# Read configuration from /etc/sysconfig/gogs to override defaults
[ -r /etc/sysconfig/$NAME ] && . /etc/sysconfig/$NAME
2014-09-29 10:41:29 +02:00
# Don't do anything if nothing is installed
[ -x ${GOGS_PATH} ] || exit 0
2015-10-31 13:32:34 +01:00
# exit if logpath dir is not created.
[ -x ${LOGPATH} ] || exit 0
2014-09-29 10:41:29 +02:00
DAEMON_OPTS="--check $NAME"
2014-09-29 10:41:29 +02:00
# Set additional options, if any
2014-09-29 10:43:51 +02:00
[ ! -z "$GOGS_USER" ] && DAEMON_OPTS="$DAEMON_OPTS --user=${GOGS_USER}"
2014-09-29 10:41:29 +02:00
start() {
cd ${GOGS_HOME}
echo -n "Starting ${SERVICENAME}: "
daemon $DAEMON_OPTS "${GOGS_PATH} web > ${LOGFILE} 2>&1 &"
2014-09-29 10:41:29 +02:00
RETVAL=$?
echo
[ $RETVAL = 0 ] && touch ${LOCKFILE}
return $RETVAL
}
stop() {
cd ${GOGS_HOME}
echo -n "Shutting down ${SERVICENAME}: "
killproc ${NAME}
2014-09-29 10:41:29 +02:00
RETVAL=$?
echo
[ $RETVAL = 0 ] && rm -f ${LOCKFILE}
2014-09-29 10:41:29 +02:00
}
case "$1" in
start)
status ${NAME} > /dev/null 2>&1 && exit 0
start
;;
stop)
stop
;;
status)
status ${NAME}
2014-09-29 10:41:29 +02:00
;;
restart)
stop
start
;;
reload)
stop
start
;;
*)
echo "Usage: ${NAME} {start|stop|status|restart}"
exit 1
;;
esac
exit $RETVAL