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.
 
 
 
 

73 regels
2.7 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. if [[ -z "$(echo "${HOST}" | tr -cd '[:alnum:].-')" ]] ; then
  26. die "invalid host: ${HOST}"
  27. fi
  28. if [[ -z "${BUBBLE_SSH_PORT}" ]] ; then
  29. BUBBLE_SSH_PORT="1202"
  30. fi
  31. BUBBLE_SERVER_DIR="${SCRIPT_DIR}/../bubble-server"
  32. if [[ ! -d "${BUBBLE_SERVER_DIR}" ]] ; then
  33. die "bubble-server dir not found: ${BUBBLE_SERVER_DIR}"
  34. fi
  35. cd ${BUBBLE_SERVER_DIR}
  36. ANY_JAR=$(find "./target" -type f -name "bubble*.jar" | head -1 | wc -l | tr -d ' ')
  37. if [[ ${ANY_JAR} -eq 0 ]] ; then
  38. ANY_CHANGES=1
  39. else
  40. ANY_CHANGES=$(find "./src/main" -type f -newer "$(find "./target" -type f -name "bubble*.jar" | head -1)" | wc -l | tr -d ' ')
  41. fi
  42. if [[ ${ANY_CHANGES} -eq 0 ]] ; then
  43. echo "No changes, not repackaging jar"
  44. scp -P ${BUBBLE_SSH_PORT} ./target/bubble*.jar ${HOST}:/tmp/bubble.jar || die "Error copying file to remote host ${HOST}"
  45. else
  46. if [[ ${ANY_JAR} -eq 0 ]] ; then
  47. echo "No bubble jar file found, rebuilding"
  48. else
  49. echo "Files changed, rebuilding bubble jar: "
  50. find "./src/main" -type f -newer "$(find "./target" -type f -name "bubble*.jar" | head -1)"
  51. fi
  52. BUBBLE_PRODUCTION=1 mvn -DskipTests=true -Dcheckstyle.skip=true clean package || die "Error packaging jar"
  53. scp -P ${BUBBLE_SSH_PORT} ./target/bubble*.jar ${HOST}:/tmp/bubble.jar || die "Error copying file to remote host ${HOST}"
  54. fi
  55. if [[ ! -z "${NO_RESTART}" && "${NO_RESTART}" == "norestart" ]] ; then
  56. echo "Patching but not restarting: ${HOST} ..."
  57. ssh -p ${BUBBLE_SSH_PORT} ${HOST} "cat /tmp/bubble.jar > ~bubble/api/bubble.jar"
  58. else
  59. echo "Patching and restarting: ${HOST} ..."
  60. ssh -p ${BUBBLE_SSH_PORT} ${HOST} "cat /tmp/bubble.jar > ~bubble/api/bubble.jar && supervisorctl restart bubble"
  61. fi
  62. if unzip -Z -1 ./target/bubble*.jar | grep -q "^site/$" ; then
  63. echo "Deploying new web: ${HOST} ..."
  64. ssh -p ${BUBBLE_SSH_PORT} ${HOST} "cd ~bubble && unzip -o /tmp/bubble.jar 'site/*' && chown -R bubble:bubble site"
  65. fi