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_monitor.sh 1.2 KiB

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