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.
 
 
 
 

50 lines
1.3 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. LOG=/tmp/bubble.algo_refresh_users_monitor.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. BUBBLE_USER_MARKER=/home/bubble/.algo_refresh_users
  26. ALGO_USER_MARKER=${ALGO_BASE}/.algo_refresh_users
  27. if [[ ! -f ${BUBBLE_USER_MARKER} ]] ; then
  28. touch ${BUBBLE_USER_MARKER} && chown bubble ${BUBBLE_USER_MARKER}
  29. fi
  30. if [[ ! -f ${ALGO_USER_MARKER} ]] ; then
  31. touch ${ALGO_USER_MARKER}
  32. fi
  33. log "Watching marker file..."
  34. while : ; do
  35. if [[ $(stat -c %Y ${BUBBLE_USER_MARKER}) -gt $(stat -c %Y ${ALGO_USER_MARKER}) ]] ; then
  36. touch ${ALGO_USER_MARKER}
  37. sleep 5s
  38. log "Refreshing VPN users..."
  39. /usr/local/bin/algo_refresh_users.sh && log "VPN users successfully refreshed" || log "Error refreshing Algo VPN users"
  40. fi
  41. sleep 10s
  42. done