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.

proxy 1.3 KiB

4 years ago
4 years ago
123456789101112131415161718192021222324252627282930313233343536373839
  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. # Request a URL via the reverse proxy
  7. #
  8. # Usage: proxy url outfile
  9. #
  10. # Environment variables
  11. #
  12. # BUBBLE_API : which API to use. Default is local (http://127.0.0.1:PORT, where PORT is found in .bubble.env)
  13. # BUBBLE_USER : account to use. Default is root
  14. # BUBBLE_PASS : password for account. Default is root
  15. # BUBBLE_SCRIPTS : location of run.sh script. Default is to assume it is in the same directory containing this script
  16. #
  17. SCRIPT="${0}"
  18. SCRIPT_DIR=$(cd $(dirname ${SCRIPT}) && pwd)
  19. . ${SCRIPT_DIR}/bubble_common
  20. URL="${1:?no URL provided}"
  21. OUTFILE="${2:?no outfile provided}"
  22. RAW=${3:-true}
  23. if [[ "${URL}" =~ http:// ]] ; then
  24. URL="http/$(echo -n ${URL} | cut -d/ -f3-)"
  25. elif [[ "${URL}" =~ https:// ]] ; then
  26. URL="https/$(echo -n ${URL} | cut -d/ -f3-)"
  27. else
  28. URL="http/$(echo -n ${URL} | cut -d/ -f3-)"
  29. fi
  30. PROXY_SCRIPT="${SCRIPT_DIR}/../scripts/proxy.json"
  31. if [[ ! -f "${PROXY_SCRIPT}" ]] ; then
  32. die "proxy API script not found: ${PROXY_SCRIPT}"
  33. fi
  34. echo '{"URL": "'"${URL}"'", "OUTFILE": "'"${OUTFILE}"'", "RAW": "'"${RAW}"'"}' \
  35. | ${SCRIPT_DIR}/bscript ${PROXY_SCRIPT} --vars -