Java WebChat Bot
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.

jbot.sh 4.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. #!/bin/sh
  2. #* ************************************************************************** */
  3. #* Project : jBot (an advanced WebChat Bot) */
  4. #* */
  5. #* Author : Bernhard Froehlich <decke@bluelife.at> */
  6. #* Homepage: http://www.bluelife.at/ */
  7. #* Copyright (c) 2005 - 2008 Bernhard Froehlich <decke@bluelife.at> */
  8. #* */
  9. #* This program is free software; you can redistribute it and/or modify */
  10. #* it under the terms of the GNU General Public License as published by */
  11. #* the Free Software Foundation; either version 2 of the License, or */
  12. #* (at your option) any later version. */
  13. #* */
  14. #* This program is distributed in the hope that it will be useful, */
  15. #* but WITHOUT ANY WARRANTY; without even the implied warranty of */
  16. #* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
  17. #* GNU General Public License for more details. */
  18. #* */
  19. #* ************************************************************************** */
  20. # $Id: jbot.sh 95 2008-11-23 12:06:17Z decke $
  21. # jBot Home Directory
  22. #
  23. # this could be:
  24. # JBOT_HOME=/root/jbot
  25. # or
  26. # JBOT_HOME=/usr/local/jbot
  27. # or
  28. # wherever you unpacked it to
  29. JBOT_HOME=.
  30. # jBot Configuration File
  31. JBOT_CONF=jbot.conf
  32. # Default File Encoding for the Java VM
  33. ENCODING=ISO-8859-1
  34. # Path to the Libraries
  35. JBOT_LIBS=${JBOT_HOME}/lib
  36. # jBot Logfile
  37. JBOT_LOGFILE=${JBOT_HOME}/jbot.log
  38. # jBot PID file
  39. JBOT_PIDFILE=/tmp/jbot.pid
  40. # Java jar Archives in the Classpath
  41. JARS=".:${JBOT_LIBS}/jbot.jar:${JBOT_LIBS}/jakarta-regexp.jar:${JBOT_LIBS}/log4j.jar"
  42. # HSQLDB Support
  43. JARS="${JARS}:${JBOT_LIBS}/hsqldb.jar"
  44. # MySQL Support
  45. JARS="${JARS}:${JBOT_LIBS}/mysql-connector.jar"
  46. # log4j Properties File
  47. LOG4J_PROP=log4j.properties
  48. # Force a JAVA_HOME path; if you have set JAVA_HOME you won't need it
  49. # FORCE_JAVA_HOME=
  50. # Dont't touch anything below here - you're warned
  51. if [ ! -z "${FORCE_JAVA_HOME}" ] ; then
  52. JAVA_BINARY="${FORCE_JAVA_HOME}/bin/java"
  53. elif [ ! -z "${JAVA_HOME}" ] ; then
  54. JAVA_BINARY="${JAVA_HOME}/bin/java"
  55. elif [ -x `which java` ] ; then
  56. JAVA_BINARY="java"
  57. else
  58. echo "Java not found. Maybe JAVA_HOME is not set correctly?"
  59. echo "You can alternately set FORCE_JAVA_HOME in blueclient.sh"
  60. exit 1
  61. fi
  62. if [ ! -d "${JBOT_HOME}" ] ; then
  63. echo "JBOT_HOME is not set correctly"
  64. exit 1
  65. fi
  66. start() {
  67. if [ -f "${JBOT_PIDFILE}" ]; then
  68. echo "jbot already running"
  69. exit 1
  70. fi
  71. echo "starting jbot ... "
  72. ${JAVA_BINARY} \
  73. -Djbot.logfile=${JBOT_LOGFILE} \
  74. -Dlog4j.configuration=${LOG4J_PROP} \
  75. -Dfile.encoding=${ENCODING} \
  76. -Xms4M \
  77. -Xmx32M \
  78. -cp ${JARS} \
  79. at.bluelife.jbot.BotKernel \
  80. -b=${JBOT_HOME} \
  81. -c=${JBOT_CONF} \
  82. >/dev/null &
  83. echo $! > ${JBOT_PIDFILE}
  84. echo "jbot (pid `cat ${JBOT_PIDFILE}`) started."
  85. }
  86. stop() {
  87. echo "shutting down jbot ..."
  88. if [ -f "${JBOT_PIDFILE}" ]; then
  89. kill -TERM `cat ${JBOT_PIDFILE}` && echo "done"
  90. rm ${JBOT_PIDFILE}
  91. else
  92. echo "failed! No such Process"
  93. fi
  94. }
  95. status() {
  96. if [ -f "${JBOT_PIDFILE}" ]; then
  97. echo "jbot is running (pid `cat ${JBOT_PIDFILE}`)"
  98. else
  99. echo "not running"
  100. fi
  101. }
  102. debug() {
  103. if [ -f "${JBOT_PIDFILE}" ]; then
  104. echo "jbot already running"
  105. exit 1
  106. fi
  107. echo "starting jbot in DEBUG mode... "
  108. ${JAVA_BINARY} \
  109. -Dlog4j.configuration=log4j-debug.properties \
  110. -Dfile.encoding=${ENCODING} \
  111. -Dcom.sun.management.jmxremote \
  112. -Xms4M \
  113. -Xmx4M \
  114. -cp ${JARS} \
  115. at.bluelife.jbot.BotKernel \
  116. -b=${JBOT_HOME} \
  117. -c=${JBOT_CONF}
  118. }
  119. # See how we were called
  120. case "$1" in
  121. start)
  122. start
  123. ;;
  124. stop)
  125. stop
  126. ;;
  127. status)
  128. status
  129. ;;
  130. restart)
  131. stop
  132. sleep 5
  133. start
  134. ;;
  135. debug)
  136. debug
  137. ;;
  138. *)
  139. echo "Usage: $0 {start|stop|status|restart|debug}"
  140. esac
  141. exit 0