Guest User

Untitled

a guest
Feb 20th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.75 KB | None | 0 0
  1. #!/bin/bash
  2. #
  3. # Init file for Gitorious GIT-Daemon daemon
  4. #
  5. # chkconfig: 2345 55 25
  6. # description: GIT-Daemon server daemon
  7. #
  8. # processname: git-daemon
  9. # pidfile: /var/www/gitorious/log/git-daemon.pid
  10.  
  11. # source function library
  12. . /etc/rc.d/init.d/functions
  13.  
  14. RETVAL=0
  15. GIT_DAEMON="/opt/ruby-enterprise/bin/ruby /var/www/gitorious/script/git-daemon -d"
  16. LOCK_FILE=/var/lock/git-daemon
  17. PID_FILE=/var/www/gitorious/log/git-daemon.pid
  18.  
  19. do_check_pid() {
  20. if [ -f $PID_FILE ]; then
  21. PID=`cat $PID_FILE`
  22. RUNNING=`ps --pid $PID | wc -l`
  23. else
  24. PID=0
  25. RUNNING=0
  26. fi
  27. }
  28.  
  29. runlevel=$(set -- $(runlevel); eval "echo \$$#" )
  30.  
  31. start()
  32. {
  33. do_check_pid
  34. if [ $RUNNING != 2 ] ; then
  35. echo -n $"Starting $PROG: "
  36. /bin/su - git -c "$GIT_DAEMON"
  37. sleep 1
  38. if [ -f $PID_FILE ] ; then
  39. success
  40. else
  41. failure
  42. fi
  43. RETVAL=$?
  44. else
  45. echo -n $"$PROG already running"
  46. failure
  47. fi
  48. [ "$RETVAL" = 0 ] && touch $LOCK_FILE
  49. echo
  50. }
  51.  
  52. stop()
  53. {
  54. do_check_pid
  55. echo -n $"Stopping $PROG: "
  56. if [ $RUNNING != 2 ] ; then
  57. failure $"Stopping $PROG"
  58. else
  59. killproc -p $PID_FILE
  60. fi
  61. RETVAL=$?
  62. # if we are in halt or reboot runlevel kill all running sessions
  63. # so the TCP connections are closed cleanly
  64. if [ "x$runlevel" = x0 -o "x$runlevel" = x6 ] ; then
  65. killproc -p $PID 2>/dev/null
  66. fi
  67. [ "$RETVAL" = 0 ] && rm -f $LOCK_FILE
  68. echo
  69. }
  70.  
  71. case "$1" in
  72. start)
  73. start
  74. ;;
  75. stop)
  76. stop
  77. ;;
  78. restart)
  79. stop
  80. start
  81. ;;
  82. condrestart)
  83. if [ -f $LOCK_FILE ] ; then
  84. if [ "$RETVAL" = 0 ] ; then
  85. stop
  86. # avoid race
  87. sleep 5
  88. start
  89. fi
  90. fi
  91. ;;
  92. *)
  93. echo $"Usage: $0 {start|stop|restart|condrestart}"
  94. RETVAL=1
  95. esac
  96. exit $RETVAL
Add Comment
Please, Sign In to add comment