Very old webserver program that used to host the vertesine site
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.

forumtest.sh 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. #!/bin/sh
  2. ### BEGIN INIT INFO
  3. # Provides:
  4. # Required-Start: $remote_fs $syslog
  5. # Required-Stop: $remote_fs $syslog
  6. # Default-Start: 2 3 4 5
  7. # Default-Stop: 0 1 6
  8. # Short-Description: Start daemon at boot time
  9. # Description: Enable service provided by daemon.
  10. ### END INIT INFO
  11. dir="/home/vertesine/webserver/webforums"
  12. cmd="./forumtest"
  13. user="root"
  14. name=`basename $0`
  15. pid_file="/var/run/$name.pid"
  16. stdout_log="/var/log/$name.log"
  17. stderr_log="/var/log/$name.err"
  18. get_pid() {
  19. cat "$pid_file"
  20. }
  21. is_running() {
  22. [ -f "$pid_file" ] && ps -p `get_pid` > /dev/null 2>&1
  23. }
  24. case "$1" in
  25. start)
  26. if is_running; then
  27. echo "Already started"
  28. else
  29. echo "Starting $name"
  30. cd "$dir"
  31. if [ -z "$user" ]; then
  32. sudo $cmd >> "$stdout_log" 2>> "$stderr_log" &
  33. else
  34. sudo -u "$user" $cmd >> "$stdout_log" 2>> "$stderr_log" &
  35. fi
  36. echo $! > "$pid_file"
  37. if ! is_running; then
  38. echo "Unable to start, see $stdout_log and $stderr_log"
  39. exit 1
  40. fi
  41. fi
  42. ;;
  43. stop)
  44. if is_running; then
  45. echo -n "Stopping $name.."
  46. kill `get_pid`
  47. for i in 1 2 3 4 5 6 7 8 9 10
  48. # for i in `seq 10`
  49. do
  50. if ! is_running; then
  51. break
  52. fi
  53. echo -n "."
  54. sleep 1
  55. done
  56. echo
  57. if is_running; then
  58. echo "Not stopped; may still be shutting down or shutdown may have failed"
  59. exit 1
  60. else
  61. echo "Stopped"
  62. if [ -f "$pid_file" ]; then
  63. rm "$pid_file"
  64. fi
  65. fi
  66. else
  67. echo "Not running"
  68. fi
  69. ;;
  70. restart)
  71. $0 stop
  72. if is_running; then
  73. echo "Unable to stop, will not attempt to start"
  74. exit 1
  75. fi
  76. $0 start
  77. ;;
  78. status)
  79. if is_running; then
  80. echo "Running"
  81. else
  82. echo "Stopped"
  83. exit 1
  84. fi
  85. ;;
  86. *)
  87. echo "Usage: $0 {start|stop|restart|status}"
  88. exit 1
  89. ;;
  90. esac
  91. exit 0