run-upgrade-server.sh 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. # Run mvn package
  2. # Goto Dir
  3. echo "---- Script Running -----"
  4. echo "in : "$0
  5. echo "$(realpath $(dirname $0)/..)"
  6. SERVER_PATH=$(realpath $(dirname $0)/..)"/sourcecode/server"
  7. if [ ! -d $SERVER_PATH ] ;
  8. then
  9. echo " Using another server path : "
  10. SERVER_PATH=$(realpath $(dirname $0))"/nursery-be/sourcecode/server"
  11. fi
  12. ORIGIN_PLACE="$SERVER_PATH/target/SZU-*.jar"
  13. CMD1="java -Djava.security.egd=file:/dev/./urandom -jar SZU-*.jar -debug"
  14. DEPLOY_DIR="$SERVER_PATH/deployed"
  15. export JAVA_HOME="/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.191.b12-1.el7_6.x86_64"
  16. if [ "x$1" = "x-skip" -o "x$2" = "x-skip" ]
  17. then
  18. echo "---- skipping build-server.sh "
  19. ls $DEPLOY_DIR
  20. else
  21. echo "---- removing old deployed JAR file "
  22. ls $DEPLOY_DIR
  23. rm -rf $DEPLOY_DIR/*.jar
  24. echo "---- Running build-server.sh"
  25. ./build-server.sh
  26. fi
  27. echo "Killing all Java Processes"
  28. ps -ef|grep 'java'|grep 'SZU' | grep -v grep|cut -c 9-15
  29. ps -ef|grep 'java'|grep 'SZU' | grep -v grep|cut -c 9-15|xargs kill -9 >/dev/null 2>&1
  30. if [ "-$2" != "--show" -a "-$1" != "--show" ]
  31. then
  32. CMD1="nohup $CMD1 &"
  33. fi
  34. which java
  35. if [ $? -ne 0 ]
  36. then
  37. echo "Cannot find java, please run : java -version to check! "
  38. exit 2
  39. fi
  40. # Start copying
  41. mkdir $DEPLOY_DIR
  42. cd $DEPLOY_DIR
  43. echo " ---- copying, from "$(echo $ORIGIN_PLACE)" to "$(echo $DEPLOY_DIR)" ---- "
  44. cp $ORIGIN_PLACE $DEPLOY_DIR
  45. echo " ---- now inside $(pwd) ---- "
  46. echo " ---- running $CMD1 ---- "
  47. $CMD1
  48. echo " ---- running finished with $? ! --- "