2017-02-18 11:23:37 +01:00
|
|
|
#!/bin/sh
|
2014-09-30 03:52:45 +02:00
|
|
|
### BEGIN INIT INFO
|
2016-11-07 12:54:17 +01:00
|
|
|
# Provides: gitea
|
2014-09-30 03:52:45 +02:00
|
|
|
# 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
|
2017-04-25 19:30:42 +02:00
|
|
|
DESC="Git with a cup of tea"
|
2016-11-07 12:54:17 +01:00
|
|
|
NAME=gitea
|
2014-09-30 03:52:45 +02:00
|
|
|
SERVICEVERBOSE=yes
|
|
|
|
PIDFILE=/var/run/$NAME.pid
|
|
|
|
SCRIPTNAME=/etc/init.d/$NAME
|
2016-11-07 12:54:17 +01:00
|
|
|
WORKINGDIR=/home/git/gitea
|
2014-09-30 03:52:45 +02:00
|
|
|
DAEMON=$WORKINGDIR/$NAME
|
|
|
|
DAEMON_ARGS="web"
|
|
|
|
USER=git
|
2017-02-18 11:23:37 +01:00
|
|
|
USERBIND="setcap cap_net_bind_service=+ep"
|
|
|
|
STOP_SCHEDULE="${STOP_SCHEDULE:-QUIT/5/TERM/1/KILL/5}"
|
2014-09-30 03:52:45 +02:00
|
|
|
|
|
|
|
# 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()
|
|
|
|
{
|
2017-02-18 11:23:37 +01:00
|
|
|
$USERBIND $DAEMON
|
|
|
|
sh -c "USER=$USER start-stop-daemon --start --quiet --pidfile $PIDFILE --make-pidfile \\
|
|
|
|
--background --chdir $WORKINGDIR --chuid $USER \\
|
|
|
|
--exec $DAEMON -- $DAEMON_ARGS"
|
2014-09-30 03:52:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
do_stop()
|
|
|
|
{
|
2017-02-18 11:23:37 +01:00
|
|
|
start-stop-daemon --stop --quiet --retry=$STOP_SCHEDULE --pidfile $PIDFILE --name $NAME --oknodo
|
|
|
|
rm -f $PIDFILE
|
2014-09-30 03:52:45 +02:00
|
|
|
}
|
|
|
|
|
2017-02-18 11:23:37 +01:00
|
|
|
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
|
|
|
|
}
|
2014-09-30 03:52:45 +02:00
|
|
|
|
|
|
|
case "$1" in
|
2017-02-18 11:23:37 +01:00
|
|
|
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
|
|
|
|
;;
|
2014-09-30 03:52:45 +02:00
|
|
|
esac
|
|
|
|
|
2017-02-18 11:23:37 +01:00
|
|
|
exit 0
|