2016-09-01 02:34:21 +05:30
|
|
|
#!/bin/sh
|
|
|
|
#
|
2016-11-07 17:24:17 +05:30
|
|
|
# /etc/init.d/gitea
|
2016-09-01 02:34:21 +05:30
|
|
|
#
|
2016-12-02 10:48:58 +05:30
|
|
|
# Runs the Gitea Git with a cup of tea.
|
2016-09-01 02:34:21 +05:30
|
|
|
#
|
|
|
|
|
|
|
|
### BEGIN INIT INFO
|
2016-11-07 17:24:17 +05:30
|
|
|
# Provides: gitea
|
2016-09-01 02:34:21 +05:30
|
|
|
# Required-Start: $remote_fs
|
|
|
|
# Required-Stop: $remote_fs
|
|
|
|
# Default-Start: 2 3 4 5
|
|
|
|
# Default-Stop: 0 1 6
|
2016-11-07 17:24:17 +05:30
|
|
|
# Short-Description: Start gitea at boot time.
|
|
|
|
# Description: Control gitea.
|
2016-09-01 02:34:21 +05:30
|
|
|
### END INIT INFO
|
|
|
|
|
|
|
|
# Default values
|
|
|
|
|
2016-11-07 17:24:17 +05:30
|
|
|
NAME=gitea
|
|
|
|
GITEA_HOME=/home/git/gitea
|
2016-11-07 16:11:50 +05:30
|
|
|
GITEA_PATH=${GITEA_HOME}/$NAME
|
|
|
|
GITEA_USER=git
|
2016-12-02 23:22:28 +05:30
|
|
|
SERVICENAME="Git - with a cup of tea"
|
2016-11-07 17:24:17 +05:30
|
|
|
LOCKFILE=/var/lock/subsys/gitea
|
2016-11-07 16:11:50 +05:30
|
|
|
LOGPATH=${GITEA_HOME}/log
|
2016-09-01 02:34:21 +05:30
|
|
|
LOGFILE=${LOGPATH}/error.log
|
2016-11-07 17:24:17 +05:30
|
|
|
# gitea creates its own gitea.log from stdout
|
2016-09-01 02:34:21 +05:30
|
|
|
RETVAL=0
|
|
|
|
|
2016-11-07 17:24:17 +05:30
|
|
|
# Read configuration from /etc/sysconfig/gitea to override defaults
|
2016-09-01 02:34:21 +05:30
|
|
|
[ -r /etc/sysconfig/$NAME ] && . /etc/sysconfig/$NAME
|
|
|
|
|
|
|
|
# Don't do anything if nothing is installed
|
2016-11-07 16:11:50 +05:30
|
|
|
test -x ${GITEA_PATH} || { echo "$NAME not installed";
|
2016-09-01 02:34:21 +05:30
|
|
|
if [ "$1" = "stop" ]; then exit 0;
|
|
|
|
else exit 5; fi; }
|
|
|
|
|
|
|
|
# exit if logpath dir is not created.
|
|
|
|
test -r ${LOGPATH} || { echo "$LOGPATH not existing";
|
|
|
|
if [ "$1" = "stop" ]; then exit 0;
|
|
|
|
else exit 6; fi; }
|
|
|
|
|
|
|
|
# Source function library.
|
|
|
|
. /etc/rc.status
|
|
|
|
|
|
|
|
# Reset status of this service
|
|
|
|
rc_reset
|
|
|
|
|
|
|
|
|
|
|
|
case "$1" in
|
|
|
|
start)
|
|
|
|
echo -n "Starting ${SERVICENAME} "
|
|
|
|
|
|
|
|
# As we can't use startproc, we have to check ourselves if the service is already running
|
2016-11-07 16:11:50 +05:30
|
|
|
/sbin/checkproc ${GITEA_PATH}
|
2016-09-01 02:34:21 +05:30
|
|
|
if [ $? -eq 0 ]; then
|
|
|
|
# return skipped as service is already running
|
|
|
|
(exit 5)
|
|
|
|
else
|
2016-11-07 16:11:50 +05:30
|
|
|
su - ${GITEA_USER} -c "USER=${GITEA_USER} ${GITEA_PATH} web 2>&1 >>${LOGFILE} &"
|
2016-09-01 02:34:21 +05:30
|
|
|
fi
|
|
|
|
|
|
|
|
# Remember status and be verbose
|
|
|
|
rc_status -v
|
|
|
|
;;
|
|
|
|
|
|
|
|
stop)
|
|
|
|
echo -n "Shutting down ${SERVICENAME} "
|
|
|
|
|
|
|
|
## Stop daemon with killproc(8) and if this fails
|
|
|
|
## killproc sets the return value according to LSB.
|
2016-11-07 16:11:50 +05:30
|
|
|
/sbin/killproc ${GITEA_PATH}
|
2016-09-01 02:34:21 +05:30
|
|
|
|
|
|
|
# Remember status and be verbose
|
|
|
|
rc_status -v
|
|
|
|
;;
|
|
|
|
|
|
|
|
restart)
|
|
|
|
## Stop the service and regardless of whether it was
|
|
|
|
## running or not, start it again.
|
|
|
|
$0 stop
|
|
|
|
$0 start
|
|
|
|
|
|
|
|
# Remember status and be quiet
|
|
|
|
rc_status
|
|
|
|
;;
|
|
|
|
|
|
|
|
status)
|
|
|
|
echo -n "Checking for ${SERVICENAME} "
|
|
|
|
## Check status with checkproc(8), if process is running
|
|
|
|
## checkproc will return with exit status 0.
|
|
|
|
|
|
|
|
# Return value is slightly different for the status command:
|
|
|
|
# 0 - service up and running
|
|
|
|
# 1 - service dead, but /var/run/ pid file exists
|
|
|
|
# 2 - service dead, but /var/lock/ lock file exists
|
|
|
|
# 3 - service not running (unused)
|
|
|
|
# 4 - service status unknown :-(
|
|
|
|
# 5--199 reserved (5--99 LSB, 100--149 distro, 150--199 appl.)
|
|
|
|
|
|
|
|
# NOTE: checkproc returns LSB compliant status values.
|
2016-11-07 16:11:50 +05:30
|
|
|
/sbin/checkproc ${GITEA_PATH}
|
2016-09-01 02:34:21 +05:30
|
|
|
# NOTE: rc_status knows that we called this init script with
|
|
|
|
# "status" option and adapts its messages accordingly.
|
|
|
|
rc_status -v
|
|
|
|
;;
|
|
|
|
|
|
|
|
*)
|
|
|
|
echo "Usage: $0 {start|stop|status|restart}"
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
|
|
|
|
esac
|
|
|
|
rc_exit
|