configure 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. #!/bin/sh
  2. git_dir=$PWD
  3. while [ ! -d .git ]; do
  4. git_dir=$(dirname "${git_dir}")
  5. done
  6. cd "${git_dir}" || exit
  7. if [ ! -f ./docker/bootstrap/bootstrap.env ]; then
  8. printf "bootstrap.env missing! Please run the bootstrap_certificates script.\n"
  9. exit 1
  10. fi
  11. . ./docker/bootstrap/bootstrap.env
  12. while :; do
  13. printf "DBMS (postgres|mariadb): " && read -r dbms
  14. [ $(echo "${dbms}" | grep -E 'postgres|mariadb') ] && break
  15. done
  16. printf "Social database name: " && read -r db
  17. [ "${dbms}" = 'mariadb' ] && printf "Database user: " && read -r user
  18. printf "Database password: " && read -r password
  19. printf "Sitename: " && read -r sitename
  20. printf "Admin nickname: " && read -r admin_nick
  21. printf "Admin password: " && read -r admin_password
  22. while :; do
  23. printf "Site profile (public|private|community|single_user): " && read -r profile
  24. [ $(echo "${profile}" | grep -E 'public|private|community|single_user') ] && break
  25. done
  26. mkdir -p ./docker/db
  27. if [ "${dbms}" = 'mariadb' ]; then
  28. printf "DB root password: " && read -r db_root_password
  29. cat > ./docker/db/db.env <<EOF
  30. DBMS=${dbms}
  31. MYSQL_ROOT_PASSWORD=${db_root_password}
  32. EOF
  33. database_url="DATABASE_URL=mysql://${user}:${password}@db:3306/${db}"
  34. else
  35. cat > ./docker/db/db.env <<EOF
  36. DBMS=${dbms}
  37. POSTGRES_USER=postgres
  38. POSTGRES_PASSWORD=${password}
  39. EOF
  40. user='postgres'
  41. database_url="DATABASE_URL=postgresql://${user}:${password}@db:5432/${db}"
  42. fi
  43. echo "${database_url}" >> .env.local
  44. printf "Mailer dsn: " && read -r mailer_dsn
  45. mkdir -p ./docker/social
  46. cat > ./docker/social/social.env <<EOF
  47. SOCIAL_DBMS="${dbms}"
  48. SOCIAL_DB="${db}"
  49. SOCIAL_USER="${user}"
  50. SOCIAL_PASSWORD="${password}"
  51. SOCIAL_DOMAIN="${domain}"
  52. SOCIAL_SITENAME="${sitename}"
  53. SOCIAL_ADMIN_NICK="${admin_nick}"
  54. SOCIAL_ADMIN_PASSWORD="${admin_password}"
  55. SOCIAL_ADMIN_EMAIL="${email}"
  56. SOCIAL_SITE_PROFILE="${profile}"
  57. MAILER_DSN="${mailer_dsn}"
  58. EOF