Advertisement
Guest User

Untitled

a guest
Jun 9th, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.51 KB | None | 0 0
  1. DIR="/var/code/WPS"
  2.  
  3. UPDATE=false
  4. DEPLOY=false
  5. RESTART=false
  6. BUILD=true
  7.  
  8. TOMCAT="/etc/init.d/tomcat8"
  9. TOMCAT_USER="admin"
  10. TOMCAT_PASS="admin"
  11. MANAGER="http://localhost:8080/manager/html"
  12.  
  13. # used for renaming of war file
  14. VERSION="3.6.2-SNAPSHOT"
  15.  
  16. WEBAPP_NAME="wps"
  17.  
  18. help() {
  19. echo >&2 "Usage $0 [-dnur] [-p directory] [-w name]"
  20. echo >&2 " -p directory path to the build directory [default: /var/code/WPS]"
  21. echo >&2 " -d deploy the webapp to the local tomcat [default: false]"
  22. echo >&2 " -n do NOT build the webapp (successful build required for deploy) [default: false]"
  23. echo >&2 " -u update the working copy [default: false]"
  24. echo >&2 " -r restart tomcat after deploying (implies -d) [default: false]"
  25. echo >&2 " -w name use \"name\" as the webapp name [default: wps]"
  26. exit 1
  27. }
  28.  
  29. while getopts b:w:uhrd o 2>/dev/null; do
  30. case ${o} in
  31. p)
  32. DIR=${OPTARG}
  33. ;;
  34. d)
  35. DEPLOY=true
  36. ;;
  37. n)
  38. BUILD=false
  39. ;;
  40. u)
  41. UPDATE=true
  42. ;;
  43. w)
  44. WEBAPP_NAME=${OPTARG}
  45. ;;
  46. r)
  47. RESTART=true
  48. DEPLOY=true
  49. ;;
  50. *)
  51. help
  52. ;;
  53. esac
  54. done
  55.  
  56.  
  57. cd $DIR
  58.  
  59. # update
  60. if $UPDATE; then
  61. echo "[SCRIPT] UPDATING REPO ..."
  62. git pull
  63. fi
  64.  
  65. # undeploy
  66. if $DEPLOY; then
  67. echo "[SCRIPT] UNDEPLOYING ..."
  68. curl -vu "$TOMCAT_USER:$TOMCAT_PASS" "$MANAGER/undeploy?path=/$WEBAPP_NAME"
  69. fi
  70.  
  71. # build
  72. if $BUILD; then
  73. echo "[SCRIPT] BUILDING PROJECT ..."
  74. # build w/o geotools
  75. #mvn clean install -DskipTests=true
  76.  
  77. # build with geotools
  78. mvn clean install -DskipTests=true -Pwith-geotools
  79.  
  80. # rename war file
  81. mv -v "52n-wps-webapp/target/52n-wps-webapp-$VERSION.war" "52n-wps-webapp/target/$WEBAPP_NAME.war"
  82. fi
  83.  
  84. #deploy
  85. if $DEPLOY; then
  86. echo "[SCRIPT] DEPLOYING ..."
  87. curl -vu "$TOMCAT_USER:$TOMCAT_PASS" "$MANAGER/deploy?path=/$WEBAPP_NAME&war=`pwd`/52n-wps-webapp/target/$WEBAPP_NAME.war"
  88. # restart tomcat
  89. if $RESTART; then
  90. $TOMCAT restart
  91. fi
  92. fi
  93.  
  94. cd -
  95. exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement