summaryrefslogtreecommitdiffstats
path: root/contrib/init
diff options
context:
space:
mode:
authorDaniel Baumann <daniel@debian.org>2024-10-18 20:33:49 +0200
committerDaniel Baumann <daniel@debian.org>2024-10-18 20:33:49 +0200
commitdd136858f1ea40ad3c94191d647487fa4f31926c (patch)
tree58fec94a7b2a12510c9664b21793f1ed560c6518 /contrib/init
parentInitial commit. (diff)
downloadforgejo-dd136858f1ea40ad3c94191d647487fa4f31926c.tar.xz
forgejo-dd136858f1ea40ad3c94191d647487fa4f31926c.zip
Adding upstream version 9.0.0.
Signed-off-by: Daniel Baumann <daniel@debian.org>
Diffstat (limited to 'contrib/init')
-rw-r--r--contrib/init/centos/gitea93
-rw-r--r--contrib/init/debian/gitea89
-rw-r--r--contrib/init/freebsd/gitea48
-rw-r--r--contrib/init/gentoo/gitea44
-rwxr-xr-xcontrib/init/openbsd/gitea19
-rw-r--r--contrib/init/openwrt/gitea35
-rw-r--r--contrib/init/sunos/gitea.xml46
-rw-r--r--contrib/init/suse/gitea115
-rw-r--r--contrib/init/ubuntu/gitea84
9 files changed, 573 insertions, 0 deletions
diff --git a/contrib/init/centos/gitea b/contrib/init/centos/gitea
new file mode 100644
index 0000000..4f0d0d9
--- /dev/null
+++ b/contrib/init/centos/gitea
@@ -0,0 +1,93 @@
+#!/bin/sh
+#
+# /etc/rc.d/init.d/gitea
+#
+# Runs the Gitea Git with a cup of tea.
+#
+#
+# chkconfig: - 85 15
+#
+
+### BEGIN INIT INFO
+# Provides: gitea
+# Required-Start: $remote_fs $syslog
+# Required-Stop: $remote_fs $syslog
+# Default-Start: 2 3 4 5
+# Default-Stop: 0 1 6
+# Short-Description: Start gitea at boot time.
+# Description: Control gitea.
+### END INIT INFO
+
+# Source function library.
+. /etc/init.d/functions
+
+# Default values
+
+NAME=gitea
+GITEA_HOME=/var/lib/${NAME}
+GITEA_PATH=/usr/local/bin/${NAME}
+GITEA_USER=git
+SERVICENAME="Gitea - Git with a cup of tea"
+LOCKFILE=/var/lock/subsys/gitea
+LOGPATH=${GITEA_HOME}/log
+LOGFILE=${LOGPATH}/gitea.log
+RETVAL=0
+
+# Read configuration from /etc/sysconfig/gitea to override defaults
+[ -r /etc/sysconfig/$NAME ] && . /etc/sysconfig/$NAME
+
+# Don't do anything if nothing is installed
+[ -x ${GITEA_PATH} ] || exit 0
+# exit if logpath dir is not created.
+[ -x ${LOGPATH} ] || exit 0
+
+DAEMON_OPTS="--check $NAME"
+
+# Set additional options, if any
+[ ! -z "$GITEA_USER" ] && DAEMON_OPTS="$DAEMON_OPTS --user=${GITEA_USER}"
+
+start() {
+ cd ${GITEA_HOME}
+ echo -n "Starting ${SERVICENAME}: "
+ daemon $DAEMON_OPTS "${GITEA_PATH} web -c /etc/${NAME}/app.ini > ${LOGFILE} 2>&1 &"
+ RETVAL=$?
+ echo
+ [ $RETVAL = 0 ] && touch ${LOCKFILE}
+
+ return $RETVAL
+}
+
+stop() {
+ cd ${GITEA_HOME}
+ echo -n "Shutting down ${SERVICENAME}: "
+ killproc ${NAME}
+ RETVAL=$?
+ echo
+ [ $RETVAL = 0 ] && rm -f ${LOCKFILE}
+}
+
+case "$1" in
+ start)
+ status ${NAME} > /dev/null 2>&1 && exit 0
+ start
+ ;;
+ stop)
+ stop
+ ;;
+ status)
+ status ${NAME}
+ ;;
+ restart)
+ stop
+ start
+ ;;
+ reload)
+ stop
+ start
+ ;;
+ *)
+ echo "Usage: ${NAME} {start|stop|status|restart}"
+ exit 1
+ ;;
+esac
+exit $RETVAL
diff --git a/contrib/init/debian/gitea b/contrib/init/debian/gitea
new file mode 100644
index 0000000..2246309
--- /dev/null
+++ b/contrib/init/debian/gitea
@@ -0,0 +1,89 @@
+#!/bin/sh
+### BEGIN INIT INFO
+# Provides: gitea
+# Required-Start: $syslog $network
+# Required-Stop: $syslog
+# Default-Start: 2 3 4 5
+# Default-Stop: 0 1 6
+# Short-Description: A self-hosted Git service written in Go.
+# Description: A self-hosted Git service written in Go.
+### END INIT INFO
+
+# Author: Danny Boisvert
+
+# Do NOT "set -e"
+
+# PATH should only include /usr/* if it runs after the mountnfs.sh script
+PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin
+DESC="Gitea - Git with a cup of tea"
+NAME=gitea
+SERVICEVERBOSE=yes
+PIDFILE=/run/$NAME.pid
+SCRIPTNAME=/etc/init.d/$NAME
+WORKINGDIR=/var/lib/$NAME
+DAEMON=/usr/local/bin/$NAME
+DAEMON_ARGS="web -c /etc/$NAME/app.ini"
+USER=git
+USERBIND=""
+# If you want to bind Gitea to a port below 1024 uncomment
+# the line below
+#USERBIND="setcap cap_net_bind_service=+ep"
+STOP_SCHEDULE="${STOP_SCHEDULE:-QUIT/5/TERM/1/KILL/5}"
+
+# Read configuration variable file if it is present
+[ -r /etc/default/$NAME ] && . /etc/default/$NAME
+
+# Exit if the package is not installed
+[ -x "$DAEMON" ] || exit 0
+
+do_start()
+{
+ $USERBIND $DAEMON
+ sh -c "USER=$USER HOME=/home/$USER GITEA_WORK_DIR=$WORKINGDIR start-stop-daemon --start --quiet --pidfile $PIDFILE --make-pidfile \\
+ --background --chdir $WORKINGDIR --chuid $USER \\
+ --exec $DAEMON -- $DAEMON_ARGS"
+}
+
+do_stop()
+{
+ start-stop-daemon --stop --quiet --retry=$STOP_SCHEDULE --pidfile $PIDFILE --name $NAME --oknodo
+ rm -f $PIDFILE
+}
+
+do_status()
+{
+ if [ -f $PIDFILE ]; then
+ if kill -0 $(cat "$PIDFILE"); then
+ echo "$NAME is running, PID is $(cat $PIDFILE)"
+ else
+ echo "$NAME process is dead, but pidfile exists"
+ fi
+ else
+ echo "$NAME is not running"
+ fi
+}
+
+case "$1" in
+ start)
+ echo "Starting $DESC" "$NAME"
+ do_start
+ ;;
+ stop)
+ echo "Stopping $DESC" "$NAME"
+ do_stop
+ ;;
+ status)
+ do_status
+ ;;
+ restart)
+ echo "Restarting $DESC" "$NAME"
+ do_stop
+ do_start
+ ;;
+ *)
+ echo "Usage: $SCRIPTNAME {start|stop|status|restart}" >&2
+ exit 2
+ ;;
+esac
+
+exit 0
diff --git a/contrib/init/freebsd/gitea b/contrib/init/freebsd/gitea
new file mode 100644
index 0000000..2c034ce
--- /dev/null
+++ b/contrib/init/freebsd/gitea
@@ -0,0 +1,48 @@
+#!/bin/sh
+#
+# $FreeBSD$
+#
+# PROVIDE: gitea
+# REQUIRE: NETWORKING SYSLOG
+# KEYWORD: shutdown
+#
+# Add the following lines to /etc/rc.conf to enable gitea:
+#
+#gitea_enable="YES"
+
+. /etc/rc.subr
+
+name="gitea"
+rcvar="gitea_enable"
+
+load_rc_config $name
+
+: ${gitea_user:="git"}
+: ${gitea_enable:="NO"}
+: ${gitea_directory:="/var/lib/gitea"}
+
+command="/usr/local/bin/gitea web -c /etc/gitea/app.ini"
+procname="$(echo $command |cut -d' ' -f1)"
+
+pidfile="${gitea_directory}/${name}.pid"
+
+start_cmd="${name}_start"
+stop_cmd="${name}_stop"
+
+gitea_start() {
+ cd ${gitea_directory}
+ export USER=${gitea_user}
+ export HOME=/usr/home/${gitea_user}
+ export GITEA_WORK_DIR=${gitea_directory}
+ /usr/sbin/daemon -f -u ${gitea_user} -p ${pidfile} $command
+}
+
+gitea_stop() {
+ if [ ! -f $pidfile ]; then
+ echo "GITEA PID File not found. Maybe GITEA is not running?"
+ else
+ kill $(cat $pidfile)
+ fi
+}
+
+run_rc_command "$1"
diff --git a/contrib/init/gentoo/gitea b/contrib/init/gentoo/gitea
new file mode 100644
index 0000000..db904e7
--- /dev/null
+++ b/contrib/init/gentoo/gitea
@@ -0,0 +1,44 @@
+#!/sbin/openrc-run
+
+DIR=/var/lib/gitea
+USER=git
+HOME=/home/${USER}
+GITEA_WORK_DIR=${DIR}
+EXECUTABLE=/usr/local/bin/gitea
+
+export USER
+export HOME
+export GITEA_WORK_DIR
+
+name=$RC_SVCNAME
+cfgfile="/etc/$RC_SVCNAME/app.ini"
+command="${EXECUTABLE}"
+command_user="${USER}"
+command_args="web -c /etc/$RC_SVCNAME/app.ini"
+command_background="yes"
+pidfile="/run/$RC_SVCNAME/$RC_SVCNAME.pid"
+start_stop_daemon_args="--user ${USER} --chdir ${DIR}"
+
+depend()
+{
+ need net
+ ###
+ # Don't forget to add the database service requirements
+ ###
+ #after postgresql
+ #after mysql
+ #after mariadb
+ #after memcached
+ #after redis
+}
+
+start_pre()
+{
+ checkpath --directory --owner $command_user:$command_user --mode 0750 \
+ /run/$RC_SVCNAME /var/log/$RC_SVCNAME
+ ##
+ # If you want to bind Gitea to a port below 1024, uncomment
+ # the value below
+ ##
+ #setcap cap_net_bind_service=+ep "${EXECUTABLE}"
+}
diff --git a/contrib/init/openbsd/gitea b/contrib/init/openbsd/gitea
new file mode 100755
index 0000000..89d4f68
--- /dev/null
+++ b/contrib/init/openbsd/gitea
@@ -0,0 +1,19 @@
+#!/bin/sh
+#
+# $OpenBSD$
+
+daemon="/usr/local/bin/gitea"
+daemon_user="git"
+daemon_flags="web -c /etc/gitea/app.ini"
+
+gitea_directory="/var/lib/gitea"
+
+rc_bg=YES
+
+. /etc/rc.d/rc.subr
+
+rc_start() {
+ ${rcexec} "cd ${gitea_directory}; ${daemon} ${daemon_flags} ${_bg}"
+}
+
+rc_cmd $1
diff --git a/contrib/init/openwrt/gitea b/contrib/init/openwrt/gitea
new file mode 100644
index 0000000..67b4495
--- /dev/null
+++ b/contrib/init/openwrt/gitea
@@ -0,0 +1,35 @@
+#!/bin/sh /etc/rc.common
+
+USE_PROCD=1
+
+# PROCD_DEBUG=1
+
+START=90
+STOP=10
+
+PROG=/opt/gitea/gitea
+GITEA_WORK_DIR=/opt/gitea
+CONF_FILE=$GITEA_WORK_DIR/app.ini
+
+start_service(){
+ procd_open_instance gitea
+ procd_set_param env GITEA_WORK_DIR=$GITEA_WORK_DIR
+ procd_set_param env HOME=$GITEA_WORK_DIR
+ procd_set_param command $PROG web -c $CONF_FILE
+ procd_set_param file $CONF_FILE
+ procd_set_param user git
+ procd_set_param respawn ${respawn_threshold:-3600} ${respawn_timeout:-5} ${respawn_retry:-5} # respawn automatically if something died, be careful if you have an alternative process supervisor
+ procd_close_instance
+}
+
+start(){
+ service_start $PROG
+}
+
+stop(){
+ service_stop $PROG
+}
+
+reload(){
+ service_reload $PROG
+}
diff --git a/contrib/init/sunos/gitea.xml b/contrib/init/sunos/gitea.xml
new file mode 100644
index 0000000..4b8cc3a
--- /dev/null
+++ b/contrib/init/sunos/gitea.xml
@@ -0,0 +1,46 @@
+<?xml version="1.0"?>
+<!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1">
+<service_bundle type="manifest" name="export">
+ <service name="gitea" type="service" version="1">
+ <create_default_instance enabled="false"/>
+
+ <dependency name="network" grouping="require_all" restart_on="refresh" type="service">
+ <service_fmri value="svc:/milestone/network:default"/>
+ </dependency>
+
+ <dependency name="filesystem" grouping="require_all" restart_on="refresh" type="service">
+ <service_fmri value="svc:/system/filesystem/local"/>
+ </dependency>
+
+ <exec_method
+ type="method"
+ name="start"
+ exec="/opt/local/bin/gitea web"
+ timeout_seconds="60">
+ <method_context>
+ <method_credential user="git" group="git" />
+ <method_environment>
+ <envvar name='GITEA_WORK_DIR' value='/opt/local/share/gitea'/>
+ <envvar name='GITEA_CUSTOM' value='/opt/local/etc/gitea'/>
+ <envvar name='HOME' value='/var/db/gitea'/>
+ <envvar name='PATH' value='/opt/local/bin:${PATH}'/>
+ <envvar name='USER' value='git'/>
+ </method_environment>
+ </method_context>
+ </exec_method>
+ <exec_method type="method" name="stop" exec=":kill" timeout_seconds="60"/>
+
+ <property_group name="application" type="application"></property_group>
+ <property_group name="startd" type="framework">
+ <propval name="duration" type="astring" value="child"/>
+ <propval name="ignore_error" type="astring" value="core,signal"/>
+ </property_group>
+
+ <template>
+ <common_name>
+ <loctext xml:lang="C">A painless, self-hosted Git service</loctext>
+ </common_name>
+ </template>
+
+ </service>
+</service_bundle>
diff --git a/contrib/init/suse/gitea b/contrib/init/suse/gitea
new file mode 100644
index 0000000..6391bed
--- /dev/null
+++ b/contrib/init/suse/gitea
@@ -0,0 +1,115 @@
+#!/bin/sh
+#
+# /etc/init.d/gitea
+#
+# Runs the Gitea Git with a cup of tea.
+#
+
+### BEGIN INIT INFO
+# Provides: gitea
+# Required-Start: $remote_fs
+# Required-Stop: $remote_fs
+# Default-Start: 2 3 4 5
+# Default-Stop: 0 1 6
+# Short-Description: Start gitea at boot time.
+# Description: Control gitea.
+### END INIT INFO
+
+# Default values
+
+NAME=gitea
+GITEA_HOME=/var/lib/$NAME
+GITEA_PATH=/usr/local/bin/$NAME
+GITEA_USER=git
+SERVICENAME="Gitea - Git with a cup of tea"
+LOCKFILE=/var/lock/subsys/gitea
+LOGPATH=${GITEA_HOME}/log
+LOGFILE=${LOGPATH}/error.log
+# gitea creates its own gitea.log from stdout
+RETVAL=0
+
+# Read configuration from /etc/sysconfig/gitea to override defaults
+[ -r /etc/sysconfig/$NAME ] && . /etc/sysconfig/$NAME
+
+# Don't do anything if nothing is installed
+test -x ${GITEA_PATH} || { echo "$NAME not installed";
+ 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
+ /sbin/checkproc ${GITEA_PATH}
+ if [ $? -eq 0 ]; then
+ # return skipped as service is already running
+ (exit 5)
+ else
+ su - ${GITEA_USER} -c "USER=${GITEA_USER} GITEA_WORK_DIR=${GITEA_HOME} ${GITEA_PATH} web -c /etc/${NAME}/app.ini 2>&1 >>${LOGFILE} &"
+ 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.
+ /sbin/killproc ${GITEA_PATH}
+
+ # 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 /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.
+ /sbin/checkproc ${GITEA_PATH}
+ # 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
diff --git a/contrib/init/ubuntu/gitea b/contrib/init/ubuntu/gitea
new file mode 100644
index 0000000..da56b6e
--- /dev/null
+++ b/contrib/init/ubuntu/gitea
@@ -0,0 +1,84 @@
+#!/bin/sh
+### BEGIN INIT INFO
+# Provides: gitea
+# Required-Start: $syslog $network
+# Required-Stop: $syslog
+# Default-Start: 2 3 4 5
+# Default-Stop: 0 1 6
+# Short-Description: A self-hosted Git service written in Go.
+# Description: A self-hosted Git service written in Go.
+### END INIT INFO
+
+# Do NOT "set -e"
+
+# PATH should only include /usr/* if it runs after the mountnfs.sh script
+PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin
+DESC="Gitea - Git with a cup of tea"
+NAME=gitea
+SERVICEVERBOSE=yes
+PIDFILE=/run/$NAME.pid
+SCRIPTNAME=/etc/init.d/$NAME
+WORKINGDIR=/var/lib/$NAME
+DAEMON=/usr/local/bin/$NAME
+DAEMON_ARGS="web -c /etc/$NAME/app.ini"
+USER=git
+STOP_SCHEDULE="${STOP_SCHEDULE:-QUIT/5/TERM/1/KILL/5}"
+
+# Read configuration variable file if it is present
+[ -r /etc/default/$NAME ] && . /etc/default/$NAME
+
+# Exit if the package is not installed
+[ -x "$DAEMON" ] || exit 0
+
+do_start()
+{
+ GITEA_ENVS="USER=$USER GITEA_WORK_DIR=$WORKINGDIR HOME=/home/$USER"
+ GITEA_EXEC="$DAEMON -- $DAEMON_ARGS"
+ sh -c "start-stop-daemon --start --quiet --pidfile $PIDFILE --make-pidfile \\
+ --background --chdir $WORKINGDIR --chuid $USER \\
+ --exec /bin/bash -- -c '/usr/bin/env $GITEA_ENVS $GITEA_EXEC'"
+}
+
+do_stop()
+{
+ start-stop-daemon --stop --quiet --retry=$STOP_SCHEDULE --pidfile $PIDFILE --name $NAME --oknodo
+ rm -f $PIDFILE
+}
+
+do_status()
+{
+ if [ -f $PIDFILE ]; then
+ if kill -0 $(cat "$PIDFILE"); then
+ echo "$NAME is running, PID is $(cat $PIDFILE)"
+ else
+ echo "$NAME process is dead, but pidfile exists"
+ fi
+ else
+ echo "$NAME is not running"
+ fi
+}
+
+case "$1" in
+ start)
+ echo "Starting $DESC" "$NAME"
+ do_start
+ ;;
+ stop)
+ echo "Stopping $DESC" "$NAME"
+ do_stop
+ ;;
+ status)
+ do_status
+ ;;
+ restart)
+ echo "Restarting $DESC" "$NAME"
+ do_stop
+ do_start
+ ;;
+ *)
+ echo "Usage: $SCRIPTNAME {start|stop|status|restart}" >&2
+ exit 2
+ ;;
+esac
+
+exit 0