The main Bubble source repository. Contains the Bubble API server, the web UI, documentation and utilities. https://getbubblenow.com
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.
 
 
 
 

70 satır
2.6 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. #
  6. # Usage:
  7. #
  8. # bpatchfull [user@]hostname [norestart]
  9. #
  10. # [user@]hostname : the hostname of the bubble node to update. Optionally, also specify a username.
  11. # Usually you will have an entry in ~/.ssh/config to set the username and ssh key
  12. # norestart : If present, do not restart the API server after updating the jar file
  13. #
  14. # Patch the bubble.jar on a remote node.
  15. # This script updates the entire jar file, and takes a lot longer than bpatch
  16. #
  17. # Environment variables
  18. #
  19. # BUBBLE_SSH_PORT : SSH port, default is 1202
  20. #
  21. SCRIPT="${0}"
  22. SCRIPT_DIR=$(cd $(dirname ${SCRIPT}) && pwd)
  23. . ${SCRIPT_DIR}/bubble_common
  24. HOST=${1:?no host provided}
  25. NO_RESTART=${2}
  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}
  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"
  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"
  46. else
  47. echo "Files changed, rebuilding bubble jar: "
  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..."
  55. ssh -p ${BUBBLE_SSH_PORT} ${HOST} "cat /tmp/bubble.jar > ~bubble/api/bubble.jar"
  56. else
  57. echo "Patching and restarting..."
  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..."
  62. ssh -p ${BUBBLE_SSH_PORT} ${HOST} "cd ~bubble && unzip -o /tmp/bubble.jar 'site/*' && chown -R bubble:bubble site"
  63. fi