code.gitea.io/gitea@v1.21.7/contrib/init/suse/gitea (about)

     1  #!/bin/sh
     2  #
     3  #       /etc/init.d/gitea
     4  #
     5  #       Runs the Gitea Git with a cup of tea.
     6  #
     7  
     8  ### BEGIN INIT INFO
     9  # Provides:          gitea
    10  # Required-Start:    $remote_fs
    11  # Required-Stop:     $remote_fs
    12  # Default-Start:     2 3 4 5
    13  # Default-Stop:      0 1 6
    14  # Short-Description: Start gitea at boot time.
    15  # Description:       Control gitea.
    16  ### END INIT INFO
    17  
    18  # Default values
    19  
    20  NAME=gitea
    21  GITEA_HOME=/var/lib/$NAME
    22  GITEA_PATH=/usr/local/bin/$NAME
    23  GITEA_USER=git
    24  SERVICENAME="Gitea - Git with a cup of tea"
    25  LOCKFILE=/var/lock/subsys/gitea
    26  LOGPATH=${GITEA_HOME}/log
    27  LOGFILE=${LOGPATH}/error.log
    28  # gitea creates its own gitea.log from stdout
    29  RETVAL=0
    30  
    31  # Read configuration from /etc/sysconfig/gitea to override defaults
    32  [ -r /etc/sysconfig/$NAME ] && . /etc/sysconfig/$NAME
    33  
    34  # Don't do anything if nothing is installed
    35  test -x ${GITEA_PATH} || { echo "$NAME not installed";
    36  	if [ "$1" = "stop" ]; then exit 0;
    37  	else exit 5; fi; }
    38  
    39  # exit if logpath dir is not created.
    40  test -r ${LOGPATH} || { echo "$LOGPATH not existing";
    41  	if [ "$1" = "stop" ]; then exit 0;
    42  	else exit 6; fi; }
    43  
    44  # Source function library.
    45  . /etc/rc.status
    46  
    47  # Reset status of this service
    48  rc_reset
    49  
    50  
    51  case "$1" in
    52      start)
    53  		echo -n "Starting ${SERVICENAME} "
    54  
    55  		# As we can't use startproc, we have to check ourselves if the service is already running
    56  		/sbin/checkproc ${GITEA_PATH}
    57  		if [ $? -eq 0 ]; then
    58  			# return skipped as service is already running
    59  			(exit 5)
    60  		else
    61  			su - ${GITEA_USER} -c "USER=${GITEA_USER} GITEA_WORK_DIR=${GITEA_HOME} ${GITEA_PATH} web -c /etc/${NAME}/app.ini 2>&1 >>${LOGFILE} &"
    62  		fi
    63  
    64  		# Remember status and be verbose
    65  		rc_status -v
    66  	;;
    67  
    68  	stop)
    69  		echo -n "Shutting down ${SERVICENAME} "
    70  
    71  		## Stop daemon with killproc(8) and if this fails
    72  		## killproc sets the return value according to LSB.
    73  		/sbin/killproc ${GITEA_PATH}
    74  
    75  		# Remember status and be verbose
    76  		rc_status -v
    77  	;;
    78  
    79  	restart)
    80  		## Stop the service and regardless of whether it was
    81  		## running or not, start it again.
    82  		$0 stop
    83  		$0 start
    84  
    85  		# Remember status and be quiet
    86  		rc_status
    87  	;;
    88  
    89  	status)
    90  		echo -n "Checking for ${SERVICENAME} "
    91  		## Check status with checkproc(8), if process is running
    92  		## checkproc will return with exit status 0.
    93  
    94  		# Return value is slightly different for the status command:
    95  		# 0 - service up and running
    96  		# 1 - service dead, but /run/  pid  file exists
    97  		# 2 - service dead, but /var/lock/ lock file exists
    98  		# 3 - service not running (unused)
    99  		# 4 - service status unknown :-(
   100  		# 5--199 reserved (5--99 LSB, 100--149 distro, 150--199 appl.)
   101  
   102  		# NOTE: checkproc returns LSB compliant status values.
   103  		/sbin/checkproc ${GITEA_PATH}
   104  		# NOTE: rc_status knows that we called this init script with
   105  		# "status" option and adapts its messages accordingly.
   106  		rc_status -v
   107  	;;
   108  
   109      *)
   110  		echo "Usage: $0 {start|stop|status|restart}"
   111  		exit 1
   112  	;;
   113  
   114  esac
   115  rc_exit