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