The main Bubble source repository. Contains the Bubble API server, the web UI, documentation and utilities. https://getbubblenow.com
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.
 
 
 
 

70 line
2.8 KiB

  1. #!/bin/bash
  2. #
  3. # Copyright (c) 2020 Bubble, Inc. All rights reserved. For personal (non-commercial) use, see license: https://getbubblenow.com/bubble-license/
  4. #
  5. # Usage:
  6. #
  7. # bpatchfull [user@]hostname [norestart]
  8. #
  9. # [user@]hostname : the hostname of the bubble node to update. Optionally, also specify a username.
  10. # Usually you will have an entry in ~/.ssh/config to set the username and ssh key
  11. # norestart : If present, do not restart the API server after updating the jar file
  12. #
  13. # Patch the bubble.jar on a remote node.
  14. # This script updates the entire jar file, and takes a lot longer than bpatch
  15. #
  16. # Environment variables
  17. #
  18. # BUBBLE_SSH_PORT : SSH port, default is 1202
  19. #
  20. SCRIPT="${0}"
  21. SCRIPT_DIR="$(cd "$(dirname "${SCRIPT}")" && pwd)"
  22. . "${SCRIPT_DIR}"/bubble_common
  23. HOST="${1:?no host provided}"
  24. NO_RESTART=${2}
  25. validate_user_at_host "${HOST}"
  26. if [[ -z "${BUBBLE_SSH_PORT}" ]] ; then
  27. BUBBLE_SSH_PORT="1202"
  28. fi
  29. BUBBLE_SERVER_DIR="${SCRIPT_DIR}/../bubble-server"
  30. if [[ ! -d "${BUBBLE_SERVER_DIR}" ]] ; then
  31. die "bubble-server dir not found: ${BUBBLE_SERVER_DIR}"
  32. fi
  33. cd "${BUBBLE_SERVER_DIR}" || die "Error changing to ${BUBBLE_SERVER_DIR} directory"
  34. ANY_JAR=$(find "./target" -type f -name "bubble*.jar" | head -1 | wc -l | tr -d ' ')
  35. if [[ ${ANY_JAR} -eq 0 ]] ; then
  36. ANY_CHANGES=1
  37. else
  38. ANY_CHANGES=$(find "./src/main" -type f -newer "$(find "./target" -type f -name "bubble*.jar" | head -1)" | wc -l | tr -d ' ')
  39. fi
  40. if [[ ${ANY_CHANGES} -eq 0 ]] ; then
  41. echo "No changes, not repackaging jar, copying to ${HOST} ..."
  42. scp -P ${BUBBLE_SSH_PORT} ./target/bubble*.jar ${HOST}:/tmp/bubble.jar || die "Error copying file to remote host ${HOST}"
  43. else
  44. if [[ ${ANY_JAR} -eq 0 ]] ; then
  45. echo "No bubble jar file found, rebuilding, then copying to ${HOST} ..."
  46. else
  47. echo "Files changed (rebuilding jar, then copying to ${HOST}) ..."
  48. find "./src/main" -type f -newer "$(find "./target" -type f -name "bubble*.jar" | head -1)"
  49. fi
  50. BUBBLE_PRODUCTION=1 mvn -DskipTests=true -Dcheckstyle.skip=true clean package || die "Error packaging jar"
  51. scp -P ${BUBBLE_SSH_PORT} ./target/bubble*.jar ${HOST}:/tmp/bubble.jar || die "Error copying file to remote host ${HOST}"
  52. fi
  53. if [[ ! -z "${NO_RESTART}" && "${NO_RESTART}" == "norestart" ]] ; then
  54. echo "Patching but not restarting: ${HOST} ..."
  55. ssh -p ${BUBBLE_SSH_PORT} ${HOST} "cat /tmp/bubble.jar > ~bubble/api/bubble.jar"
  56. else
  57. echo "Patching and restarting: ${HOST} ..."
  58. ssh -p ${BUBBLE_SSH_PORT} ${HOST} "cat /tmp/bubble.jar > ~bubble/api/bubble.jar && supervisorctl restart bubble"
  59. fi
  60. if unzip -Z -1 ./target/bubble*.jar | grep -q "^site/$" ; then
  61. echo "Deploying new web: ${HOST} ..."
  62. ssh -p ${BUBBLE_SSH_PORT} ${HOST} "cd ~bubble && unzip -q -o /tmp/bubble.jar 'site/*' && chown -R bubble:bubble site"
  63. fi