The main Bubble source repository. Contains the Bubble API server, the web UI, documentation and utilities. https://getbubblenow.com
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 

55 行
2.1 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. # Perform one-time setup of a new Ubuntu system. Works with Ubuntu 20.04 and 18.04
  6. #
  7. # It is safe to run this multiple times, it is idempotent.
  8. #
  9. function die {
  10. echo 1>&2 "${1}"
  11. exit 1
  12. }
  13. function db_user_exists {
  14. username="${1}"
  15. num_users="$(echo "select count(*) from pg_user where usename='${username}'" | sudo -u postgres bash -c 'psql -qt' | egrep -v '^$')"
  16. if [[ -z "${num_users}" || ${num_users} -eq 0 ]] ; then
  17. echo "0"
  18. else
  19. echo "1"
  20. fi
  21. }
  22. # Ensure system is current
  23. sudo apt update -y || die "Error running apt update"
  24. sudo apt upgrade -y || die "Error running apt upgrade"
  25. # Install packages
  26. sudo apt install openjdk-11-jdk maven postgresql redis-server jq python3 python3-pip npm webpack curl zip unzip whois -y || die "Error installing apt packages"
  27. sudo pip3 install setuptools psycopg2-binary || die "Error installing pip packages"
  28. # Install packer
  29. BUBBLE_BIN="$(cd "$(dirname "${0}")" && pwd)"
  30. "${BUBBLE_BIN}/install_packer.sh" || die "Error installing packer"
  31. # Create DB user for current user, as superuser
  32. CURRENT_USER="$(whoami)"
  33. if [[ $(db_user_exists ${CURRENT_USER}) == "1" ]] ; then
  34. echo "PostgreSQL user ${CURRENT_USER} already exists, not creating"
  35. else
  36. sudo -u postgres bash -c 'createuser -U postgres --createdb --createrole --superuser '"${CURRENT_USER}"'' || die "Error creating ${CURRENT_USER} DB user"
  37. fi
  38. PG_HBA=$(find /etc/postgresql -mindepth 1 -maxdepth 1 -type d | sort | tail -1)/main/pg_hba.conf
  39. 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}"
  40. sudo bash -c "cat /tmp/pg_hba.conf > ${PG_HBA}" || die "Error rewriting ${PG_HBA}"
  41. sudo service postgresql restart || die "Error restarting pgsql"
  42. # Create DB user 'bubble', with the ability to create databases
  43. if [[ $(db_user_exists 'bubble') == "1" ]] ; then
  44. echo "PostgreSQL user bubble already exists, not creating"
  45. else
  46. createuser --createdb bubble || die "Error creating bubble DB user"
  47. fi