Java Web Chat Server
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.

jc.sh 918B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #!/bin/sh
  2. JAVA_HOME=/usr/java/jre1.5.0_01
  3. export JAVA_HOME
  4. JC_HOME=/usr/local/jc
  5. JC_USER=jcdaemon
  6. JC_LOG=/var/log/jc.log
  7. JC_PID=/var/run/jc.pid
  8. startJC() {
  9. su -c "$*" $JC_USER 2>/dev/null > $JC_LOG &
  10. hpid=$!
  11. echo $hpid
  12. /bin/ps h $hpid >/dev/null 2>&1
  13. echo $hpid > $JC_PID
  14. }
  15. start() {
  16. echo -n "Starting JC: "
  17. startJC $JAVA_HOME/bin/java -jar $JC_HOME/jc.jar -b=$JC_HOME
  18. }
  19. stop() {
  20. echo -n "Shutting down JC: "
  21. if [ -f $JC_PID ] ; then
  22. pid=`head -1 $JC_PID`
  23. kill -SIGTERM $pid && echo "KILLED"
  24. else
  25. echo "NOT RUNNING"
  26. fi
  27. rm -f $JC_PID
  28. }
  29. # See how we were called
  30. case "$1" in
  31. start)
  32. start
  33. ;;
  34. stop)
  35. stop
  36. ;;
  37. restart)
  38. stop
  39. sleep 5
  40. start
  41. ;;
  42. *)
  43. echo "Usage: $0 {start|stop|restart}"
  44. esac
  45. exit 0