code.gitea.io/gitea@v1.21.7/contrib/init/debian/gitea (about) 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 # Author: Danny Boisvert 13 14 # Do NOT "set -e" 15 16 # PATH should only include /usr/* if it runs after the mountnfs.sh script 17 PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin 18 DESC="Gitea - Git with a cup of tea" 19 NAME=gitea 20 SERVICEVERBOSE=yes 21 PIDFILE=/run/$NAME.pid 22 SCRIPTNAME=/etc/init.d/$NAME 23 WORKINGDIR=/var/lib/$NAME 24 DAEMON=/usr/local/bin/$NAME 25 DAEMON_ARGS="web -c /etc/$NAME/app.ini" 26 USER=git 27 USERBIND="" 28 # If you want to bind Gitea to a port below 1024 uncomment 29 # the line below 30 #USERBIND="setcap cap_net_bind_service=+ep" 31 STOP_SCHEDULE="${STOP_SCHEDULE:-QUIT/5/TERM/1/KILL/5}" 32 33 # Read configuration variable file if it is present 34 [ -r /etc/default/$NAME ] && . /etc/default/$NAME 35 36 # Exit if the package is not installed 37 [ -x "$DAEMON" ] || exit 0 38 39 do_start() 40 { 41 $USERBIND $DAEMON 42 sh -c "USER=$USER HOME=/home/$USER GITEA_WORK_DIR=$WORKINGDIR start-stop-daemon --start --quiet --pidfile $PIDFILE --make-pidfile \\ 43 --background --chdir $WORKINGDIR --chuid $USER \\ 44 --exec $DAEMON -- $DAEMON_ARGS" 45 } 46 47 do_stop() 48 { 49 start-stop-daemon --stop --quiet --retry=$STOP_SCHEDULE --pidfile $PIDFILE --name $NAME --oknodo 50 rm -f $PIDFILE 51 } 52 53 do_status() 54 { 55 if [ -f $PIDFILE ]; then 56 if kill -0 $(cat "$PIDFILE"); then 57 echo "$NAME is running, PID is $(cat $PIDFILE)" 58 else 59 echo "$NAME process is dead, but pidfile exists" 60 fi 61 else 62 echo "$NAME is not running" 63 fi 64 } 65 66 case "$1" in 67 start) 68 echo "Starting $DESC" "$NAME" 69 do_start 70 ;; 71 stop) 72 echo "Stopping $DESC" "$NAME" 73 do_stop 74 ;; 75 status) 76 do_status 77 ;; 78 restart) 79 echo "Restarting $DESC" "$NAME" 80 do_stop 81 do_start 82 ;; 83 *) 84 echo "Usage: $SCRIPTNAME {start|stop|status|restart}" >&2 85 exit 2 86 ;; 87 esac 88 89 exit 0