summaryrefslogtreecommitdiffstats
path: root/contrib/init/ubuntu
diff options
context:
space:
mode:
authorDaniel Baumann <daniel@debian.org>2024-10-18 20:33:49 +0200
committerDaniel Baumann <daniel@debian.org>2024-12-12 23:57:56 +0100
commite68b9d00a6e05b3a941f63ffb696f91e554ac5ec (patch)
tree97775d6c13b0f416af55314eb6a89ef792474615 /contrib/init/ubuntu
parentInitial commit. (diff)
downloadforgejo-e68b9d00a6e05b3a941f63ffb696f91e554ac5ec.tar.xz
forgejo-e68b9d00a6e05b3a941f63ffb696f91e554ac5ec.zip
Adding upstream version 9.0.3.
Signed-off-by: Daniel Baumann <daniel@debian.org>
Diffstat (limited to '')
-rw-r--r--contrib/init/ubuntu/gitea84
1 files changed, 84 insertions, 0 deletions
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