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.

algo_refresh_users.sh 2.1 KiB

4 years ago
4 years ago
4 years ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. LOG=/tmp/bubble.algo_refresh_users.log
  6. function die {
  7. echo 1>&2 "${1}"
  8. log "${1}"
  9. exit 1
  10. }
  11. function log {
  12. echo "$(date): ${1}" >> ${LOG}
  13. }
  14. ALGO_BASE=/root/ansible/roles/algo/algo
  15. if [[ ! -d ${ALGO_BASE} ]] ; then
  16. die "Algo VPN directory ${ALGO_BASE} not found"
  17. fi
  18. CA_PASS_FILE="/home/bubble/.BUBBLE_ALGO_CA_KEY_PASSWORD"
  19. if [[ ! -f "${CA_PASS_FILE}" ]] ; then
  20. die "No CA password file found: ${CA_PASS_FILE}"
  21. fi
  22. if [[ ! -f "${ALGO_BASE}/config.cfg.hbs" ]] ; then
  23. die "No ${ALGO_BASE}/config.cfg.hbs found"
  24. fi
  25. log "Regenerating algo config..."
  26. java -cp /home/bubble/current/bubble.jar bubble.main.BubbleMain generate-algo-conf --algo-config ${ALGO_BASE}/config.cfg.hbs || die "Error writing algo config.cfg"
  27. log "Updating algo VPN users..."
  28. cd ${ALGO_BASE} && \
  29. python3 -m virtualenv --python="$(command -v python3)" .env \
  30. && source .env/bin/activate \
  31. && python3 -m pip install -U pip virtualenv \
  32. && python3 -m pip install -r requirements.txt \
  33. && ansible-playbook users.yml --tags update-users --skip-tags debug \
  34. -e "ca_password=$(cat ${CA_PASS_FILE})
  35. provider=local
  36. server=localhost
  37. store_cakey=true
  38. ondemand_cellular=false
  39. ondemand_wifi=false
  40. store_pki=true
  41. dns_adblocking=false
  42. ssh_tunneling=false
  43. endpoint={{ endpoint }}
  44. server_name={{ server_name }}" 2>&1 | tee -a ${LOG} || die "Error running algo users.yml"
  45. # Archive configs in a place that the BackupService can pick them up
  46. log "Sync'ing algo VPN users to bubble..."
  47. CONFIGS_BACKUP=/home/bubble/.BUBBLE_ALGO_CONFIGS.tgz
  48. cd ${ALGO_BASE} && tar czf ${CONFIGS_BACKUP} configs && chgrp bubble ${CONFIGS_BACKUP} && chmod 660 ${CONFIGS_BACKUP} || die "Error backing up algo configs"
  49. cd /home/bubble && rm -rf configs/* && tar xzf ${CONFIGS_BACKUP} && chgrp -R bubble configs && chown -R bubble configs && chmod 500 configs || die "Error unpacking algo configs to bubble home"
  50. log "VPN users successfully sync'd to bubble"