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.

122 lines
2.8 KiB

13 years ago
13 years ago
13 years ago
13 years ago
13 years ago
13 years ago
13 years ago
13 years ago
13 years ago
13 years ago
13 years ago
13 years ago
13 years ago
13 years ago
13 years ago
13 years ago
13 years ago
  1. ################################################################
  2. # File: /etc/init.d/phpdbg #
  3. # Author: krakjoe #
  4. # Purpose: Daemonize phpdbg automatically on boot #
  5. # chkconfig: 2345 07 09 #
  6. # description: Starts, stops and restarts phpdbg daemon #
  7. ################################################################
  8. LOCKFILE=/var/lock/subsys/phpdbg
  9. PIDFILE=/var/run/phpdbg.pid
  10. STDIN=4000
  11. STDOUT=8000
  12. ################################################################
  13. # Either set path to phpdbg here or rely on phpdbg in ENV/PATH #
  14. ################################################################
  15. if [ "x${PHPDBG}" == "x" ]; then
  16. PHPDBG=$(which phpdbg 2>/dev/null)
  17. fi
  18. ################################################################
  19. # Options to pass to phpdbg upon boot #
  20. ################################################################
  21. OPTIONS=
  22. LOGFILE=/var/log/phpdbg.log
  23. ################################################################
  24. # STOP EDITING STOP EDITING STOP EDITING STOP EDITING #
  25. ################################################################
  26. . /etc/rc.d/init.d/functions
  27. RETVAL=1
  28. ################################################################
  29. insanity()
  30. {
  31. if [ "x${PHPDBG}" == "x" ]; then
  32. PHPDBG=$(which phpdbg 2>>/dev/null)
  33. if [ $? != 0 ]; then
  34. echo -n $"Fatal: cannot find phpdbg ${PHPDBG}"
  35. echo_failure
  36. echo
  37. return 1
  38. fi
  39. else
  40. if [ ! -x ${PHPDBG} ]; then
  41. echo -n $"Fatal: cannot execute phpdbg ${PHPDBG}"
  42. echo_failure
  43. echo
  44. return 1
  45. fi
  46. fi
  47. return 0
  48. }
  49. start()
  50. {
  51. insanity
  52. if [ $? -eq 1 ]; then
  53. return $RETVAL
  54. fi
  55. echo -n $"Starting: phpdbg ${OPTIONS} on ${STDIN}/${STDOUT} "
  56. nohup ${PHPDBG} -l${STDIN}/${STDOUT} ${OPTIONS} 2>>${LOGFILE} 1>/dev/null </dev/null &
  57. PID=$!
  58. RETVAL=$?
  59. if [ $RETVAL -eq 0 ]; then
  60. echo $PID > $PIDFILE
  61. echo_success
  62. else
  63. echo_failure
  64. fi
  65. echo
  66. [ $RETVAL = 0 ] && touch ${LOCKFILE}
  67. return $RETVAL
  68. }
  69. stop()
  70. {
  71. insanity
  72. if [ $? -eq 1 ]; then
  73. return $RETVAL
  74. fi
  75. if [ -f ${LOCKFILE} ] && [ -f ${PIDFILE} ]
  76. then
  77. echo -n $"Stopping: phpdbg ${OPTIONS} on ${STDIN}/${STDOUT} "
  78. kill -s TERM $(cat $PIDFILE)
  79. RETVAL=$?
  80. if [ $RETVAL -eq 0 ]; then
  81. echo_success
  82. else
  83. echo_failure
  84. fi
  85. echo
  86. [ $RETVAL = 0 ] && rm -f ${LOCKFILE} ${PIDFILE}
  87. else
  88. echo -n $"Error: phpdbg not running"
  89. echo_failure
  90. echo
  91. [ $RETVAL = 1 ]
  92. fi
  93. return $RETVAL
  94. }
  95. ##################################################################
  96. case "$1" in
  97. start)
  98. start
  99. ;;
  100. stop)
  101. stop
  102. ;;
  103. status)
  104. status $PHPDBG
  105. ;;
  106. restart)
  107. $0 stop
  108. $0 start
  109. ;;
  110. *)
  111. echo "usage: $0 start|stop|restart|status"
  112. ;;
  113. esac
  114. ###################################################################
  115. exit $RETVAL