本站源代码
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.

90 line
2.1KB

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