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.
 
 
 
 

57 lines
2.0 KiB

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