The main Bubble source repository. Contains the Bubble API server, the web UI, documentation and utilities. https://getbubblenow.com
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 
 
 
 

47 rindas
1.8 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. function die {
  6. echo 1>&2 "${1}"
  7. exit 1
  8. }
  9. function db_user_exists {
  10. username="${1}"
  11. num_users="$(echo "select count(*) from pg_user where usename='${username}'" | su - postgres psql -qt | egrep -v '^$')"
  12. if [[ -z "${num_users}" || ${num_users} -eq 0 ]] ; then
  13. echo "0"
  14. else
  15. echo "1"
  16. fi
  17. }
  18. # Ensure system is current
  19. sudo apt update -y || die "Error running apt update"
  20. sudo apt upgrade -y || die "Error running apt upgrade"
  21. # Install packages
  22. sudo apt install openjdk-11-jdk maven postgresql redis-server jq python3 python3-pip npm webpack curl unzip -y || die "Error installing apt packages"
  23. sudo pip3 install setuptools psycopg2-binary || die "Error installing pip packages"
  24. # Install packer
  25. BUBBLE_BIN="$(cd "$(dirname "${0}")" && pwd)"
  26. "${BUBBLE_BIN}/install_packer.sh" || die "Error installing packer"
  27. # Create DB user for current user, as superuser
  28. CURRENT_USER="$(whoami)"
  29. if [[ $(db_user_exists ${CURRENT_USER}) ]] ; then
  30. echo "PostgreSQL user ${CURRENT_USER} already exists, not creating"
  31. else
  32. sudo su - postgres bash -c 'createuser -U postgres --createdb --createrole --superuser '"${CURRENT_USER}"'' || die "Error creating ${CURRENT_USER} DB user"
  33. fi
  34. PG_HBA=$(find /etc/postgresql -mindepth 1 -maxdepth 1 -type d | sort | tail -1)/main/pg_hba.conf
  35. sudo cat ${PG_HBA} | sed -e 's/ peer/ trust/g' | sed -e 's/ md5/ trust/g' > /tmp/pg_hba.conf || die "Error filtering ${PG_HBA}"
  36. sudo bash -c "cat /tmp/pg_hba.conf > ${PG_HBA}" || die "Error rewriting ${PG_HBA}"
  37. sudo service postgresql restart || die "Error restarting pgsql"
  38. # Create DB user 'bubble', with the ability to create databases
  39. createuser --createdb bubble || die "Error creating bubble DB user"