The main Bubble source repository. Contains the Bubble API server, the web UI, documentation and utilities. https://getbubblenow.com
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 
 

69 řádky
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. # bpatch [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. #
  15. # Environment variables
  16. #
  17. # BUBBLE_SSH_PORT : SSH port, default is 1202
  18. #
  19. SCRIPT="${0}"
  20. SCRIPT_DIR="$(cd "$(dirname "${SCRIPT}")" && pwd)"
  21. . "${SCRIPT_DIR}"/bubble_common
  22. HOST="${1:?no host provided}"
  23. NO_RESTART=${2}
  24. validate_user_at_host "${HOST}"
  25. if [[ -z "${BUBBLE_SSH_PORT}" ]] ; then
  26. BUBBLE_SSH_PORT="1202"
  27. fi
  28. BUBBLE_SERVER_DIR="${SCRIPT_DIR}/../bubble-server"
  29. if [[ ! -d "${BUBBLE_SERVER_DIR}" ]] ; then
  30. die "bubble-server dir not found: ${BUBBLE_SERVER_DIR}"
  31. fi
  32. cd "${BUBBLE_SERVER_DIR}" || die "Error changing to ${BUBBLE_SERVER_DIR} directory"
  33. ANY_JAR=$(find "./target" -type f -name "bubble*.jar" | grep -v full | head -1 | wc -l | tr -d ' ')
  34. if [[ ${ANY_JAR} -eq 0 ]] ; then
  35. ANY_CHANGES=1
  36. else
  37. ANY_CHANGES=$(find "./src/main" -type f -newer "$(find "./target" -type f -name "bubble*.jar" | grep -v full | head -1)" | wc -l | tr -d ' ')
  38. fi
  39. if [[ ${ANY_CHANGES} -eq 0 ]] ; then
  40. echo "No changes, not repackaging jar, copying to ${HOST} ..."
  41. scp -P ${BUBBLE_SSH_PORT} "$(find "./target" -type f -name "bubble*.jar" | grep -v full | head -1)" ${HOST}:/tmp/bubble.jar || die "Error copying file to remote host ${HOST}"
  42. else
  43. if [[ ${ANY_JAR} -eq 0 ]] ; then
  44. echo "No bubble jar file found, rebuilding, then copying to ${HOST} ..."
  45. else
  46. echo "Files changed (rebuilding jar, then copying to ${HOST}) ..."
  47. find "./src/main" -type f -newer "$(find "./target" -type f -name "bubble*.jar" | head -1)"
  48. fi
  49. BUBBLE_PRODUCTION=1 mvn -DskipTests=true -Dcheckstyle.skip=true -Pproduction clean package || die "Error packaging jar"
  50. scp -P ${BUBBLE_SSH_PORT} "$(find "./target" -type f -name "bubble*.jar" | grep -v full | head -1)" ${HOST}:/tmp/bubble.jar || die "Error copying file to remote host ${HOST}"
  51. fi
  52. if [[ -n "${NO_RESTART}" && "${NO_RESTART}" == "norestart" ]] ; then
  53. echo "Patching but not restarting: ${HOST} ..."
  54. ssh -p ${BUBBLE_SSH_PORT} ${HOST} "cat /tmp/bubble.jar > ~bubble/api/bubble.jar"
  55. else
  56. echo "Patching and restarting: ${HOST} ..."
  57. ssh -p ${BUBBLE_SSH_PORT} ${HOST} "cat /tmp/bubble.jar > ~bubble/api/bubble.jar && supervisorctl restart bubble"
  58. fi
  59. if unzip -Z -1 ./target/bubble*.jar | grep -q "^site/$" ; then
  60. echo "Deploying new web: ${HOST} ..."
  61. ssh -p ${BUBBLE_SSH_PORT} ${HOST} "cd ~bubble && unzip -q -o /tmp/bubble.jar 'site/*' && chown -R bubble:bubble site"
  62. fi