|
- #!/bin/sh
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin
- DESC="Gitea - Git with a cup of tea"
- NAME=gitea
- SERVICEVERBOSE=yes
- PIDFILE=/var/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=""
-
-
-
- STOP_SCHEDULE="${STOP_SCHEDULE:-QUIT/5/TERM/1/KILL/5}"
-
-
- [ -r /etc/default/$NAME ] && . /etc/default/$NAME
-
-
- [ -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
|