Last active
April 16, 2016 04:42
-
-
Save lbeltrame/f5e3f363cc9edc8e94d5 to your computer and use it in GitHub Desktop.
CentOS Gogs init script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# /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 | |
GOGS_HOME=/home/git/gogs | |
GOGS_PATH=${GOGS_HOME}/gogs | |
GOGS_USER=git | |
PROG=$(basename $GOGS_PATH) | |
NAME="Gogs Go Git Service" | |
PID=/var/run/$PROG.pid | |
LOCKFILE=/var/lock/subsys/gogs | |
RETVAL=0 | |
start() { | |
[ -x ${GOGS_PATH} ] || exit 5 | |
cd ${GOGS_HOME} | |
echo -n "Starting ${NAME}: " | |
daemon --user=${GOGS_USER} --pidfile=${PID} "${GOGS_PATH} web 2>&1 > ${GOGS_HOME}/log/gogs.log &" | |
echo $(pidof ${PROG}) > ${PID} | |
RETVAL=$? | |
echo | |
[ $RETVAL = 0 ] && touch ${LOCKFILE} | |
return $RETVAL | |
} | |
stop() { | |
cd ${GOGS_HOME} | |
echo -n "Shutting down ${NAME}: " | |
killproc -p ${PID} ${PROG} | |
RETVAL=$? | |
echo | |
[ $RETVAL = 0 ] && rm -f ${LOCKFILE} ${PID} | |
} | |
case "$1" in | |
start) | |
status ${PROG} > /dev/null 2>&1 && exit 0 | |
start | |
;; | |
stop) | |
stop | |
;; | |
status) | |
status -p ${PID} ${PROG} | |
;; | |
restart) | |
stop | |
start | |
;; | |
reload) | |
stop | |
start | |
;; | |
*) | |
echo "Usage: ${PROG} {start|stop|status|restart}" | |
exit 1 | |
;; | |
esac | |
exit $RETVAL |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment