Skip to content

Commit 79af6e3

Browse files
authored
Add init file for Ubuntu (#23362)
Created an init file for Ubuntu that will be useful when running it on WSL.
1 parent e6df743 commit 79af6e3

File tree

1 file changed

+84
-0
lines changed

1 file changed

+84
-0
lines changed

contrib/init/ubuntu/gitea

+84
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
#!/bin/sh
2+
### BEGIN INIT INFO
3+
# Provides: gitea
4+
# Required-Start: $syslog $network
5+
# Required-Stop: $syslog
6+
# Default-Start: 2 3 4 5
7+
# Default-Stop: 0 1 6
8+
# Short-Description: A self-hosted Git service written in Go.
9+
# Description: A self-hosted Git service written in Go.
10+
### END INIT INFO
11+
12+
# Do NOT "set -e"
13+
14+
# PATH should only include /usr/* if it runs after the mountnfs.sh script
15+
PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin
16+
DESC="Gitea - Git with a cup of tea"
17+
NAME=gitea
18+
SERVICEVERBOSE=yes
19+
PIDFILE=/run/$NAME.pid
20+
SCRIPTNAME=/etc/init.d/$NAME
21+
WORKINGDIR=/var/lib/$NAME
22+
DAEMON=/usr/local/bin/$NAME
23+
DAEMON_ARGS="web -c /etc/$NAME/app.ini"
24+
USER=git
25+
STOP_SCHEDULE="${STOP_SCHEDULE:-QUIT/5/TERM/1/KILL/5}"
26+
27+
# Read configuration variable file if it is present
28+
[ -r /etc/default/$NAME ] && . /etc/default/$NAME
29+
30+
# Exit if the package is not installed
31+
[ -x "$DAEMON" ] || exit 0
32+
33+
do_start()
34+
{
35+
GITEA_ENVS="USER=$USER GITEA_WORK_DIR=$WORKINGDIR HOME=/home/$USER"
36+
GITEA_EXEC="$DAEMON -- $DAEMON_ARGS"
37+
sh -c "start-stop-daemon --start --quiet --pidfile $PIDFILE --make-pidfile \\
38+
--background --chdir $WORKINGDIR --chuid $USER \\
39+
--exec /bin/bash -- -c '/usr/bin/env $GITEA_ENVS $GITEA_EXEC'"
40+
}
41+
42+
do_stop()
43+
{
44+
start-stop-daemon --stop --quiet --retry=$STOP_SCHEDULE --pidfile $PIDFILE --name $NAME --oknodo
45+
rm -f $PIDFILE
46+
}
47+
48+
do_status()
49+
{
50+
if [ -f $PIDFILE ]; then
51+
if kill -0 $(cat "$PIDFILE"); then
52+
echo "$NAME is running, PID is $(cat $PIDFILE)"
53+
else
54+
echo "$NAME process is dead, but pidfile exists"
55+
fi
56+
else
57+
echo "$NAME is not running"
58+
fi
59+
}
60+
61+
case "$1" in
62+
start)
63+
echo "Starting $DESC" "$NAME"
64+
do_start
65+
;;
66+
stop)
67+
echo "Stopping $DESC" "$NAME"
68+
do_stop
69+
;;
70+
status)
71+
do_status
72+
;;
73+
restart)
74+
echo "Restarting $DESC" "$NAME"
75+
do_stop
76+
do_start
77+
;;
78+
*)
79+
echo "Usage: $SCRIPTNAME {start|stop|status|restart}" >&2
80+
exit 2
81+
;;
82+
esac
83+
84+
exit 0

0 commit comments

Comments
 (0)