diff options
author | Luca Beltrame <lbeltrame@kde.org> | 2014-09-29 10:41:29 +0200 |
---|---|---|
committer | Luca Beltrame <lbeltrame@kde.org> | 2014-09-29 10:41:29 +0200 |
commit | 5e48c89c5eee43eee76c6b5c906b720ea986285f (patch) | |
tree | 792c3edf75995cb5ef56a0eb18019b5624e1b301 /scripts | |
parent | 3cfa4a581ca3cf3cb5e5105725d77f4c594de478 (diff) | |
download | gitea-5e48c89c5eee43eee76c6b5c906b720ea986285f.tar.gz gitea-5e48c89c5eee43eee76c6b5c906b720ea986285f.zip |
Add a CentOS init script
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/init/centos/gogs | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/scripts/init/centos/gogs b/scripts/init/centos/gogs new file mode 100644 index 0000000000..41c56d7554 --- /dev/null +++ b/scripts/init/centos/gogs @@ -0,0 +1,92 @@ +#!/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" +PID=/var/run/$NAME.pid +LOCKFILE=/var/lock/subsys/gogs +LOGFILE=${GOGS_HOME}/log/gogs.log +RETVAL=0 + +# 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 + +DAEMON_OPTS="" + +# Set additional options, if any +[ ! -z "$GOGS_USER" ] && DAEMON_OPTS="$DAEMON_OPTS --user=${USER}" + +start() { + cd ${GOGS_HOME} + echo -n "Starting ${SERVICENAME}: " + daemon $DAEMON_OPTS --pidfile=${PID} "${GOGS_PATH} web 2>&1 > ${LOGFILE} &" + echo $! > ${PID} + RETVAL=$? + echo + [ $RETVAL = 0 ] && touch ${LOCKFILE} + + return $RETVAL +} + +stop() { + cd ${GOGS_HOME} + echo -n "Shutting down ${SERVICENAME}: " + killproc -p ${PID} ${NAME} + RETVAL=$? + echo + [ $RETVAL = 0 ] && rm -f ${LOCKFILE} ${PID} +} + +case "$1" in + start) + status ${NAME} > /dev/null 2>&1 && exit 0 + start + ;; + stop) + stop + ;; + status) + status -p ${PID} ${NAME} + ;; + restart) + stop + start + ;; + reload) + stop + start + ;; + *) + echo "Usage: ${NAME} {start|stop|status|restart}" + exit 1 + ;; +esac +exit $RETVAL |