You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

gitea 2.0KB

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