configure 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. . ./docker/bootstrap/bootstrap.env
  8. while :; do
  9. printf "DBMS (postgres|mariadb): " && read -r dbms
  10. [ $(echo "${dbms}" | grep -E 'postgres|mariadb') ] && break
  11. done
  12. printf "Social database name: " && read -r db
  13. [ "${dbms}" = 'mariadb' ] && printf "Database user: " && read -r user
  14. printf "Database password: " && read -r password
  15. printf "Sitename: " && read -r sitename
  16. printf "Admin nickname: " && read -r admin_nick
  17. printf "Admin password: " && read -r admin_password
  18. while :; do
  19. printf "Site profile (public|private|community|single_user): " && read -r profile
  20. [ $(echo "${profile}" | grep -E 'public|private|community|single_user') ] && break
  21. done
  22. mkdir -p ./docker/db
  23. if [ "${dbms}" = 'mariadb' ]; then
  24. printf "DB root password: " && read -r db_root_password
  25. cat > ./docker/db/db.env <<EOF
  26. DBMS=${dbms}
  27. MYSQL_ROOT_PASSWORD=${db_root_password}
  28. EOF
  29. database_url="DATABASE_URL=mysql://${user}:${password}@db:3306/${db}"
  30. else
  31. cat > ./docker/db/db.env <<EOF
  32. DBMS=${dbms}
  33. POSTGRES_USER=postgres
  34. POSTGRES_PASSWORD=${password}
  35. EOF
  36. user='postgres'
  37. database_url="DATABASE_URL=postgresql://${user}:${password}@db:5432/${db}"
  38. fi
  39. echo "${database_url}" > .env.local
  40. mkdir -p ./docker/social
  41. cat > ./docker/social/social.env <<EOF
  42. SOCIAL_DBMS="${dbms}"
  43. SOCIAL_DB="${db}"
  44. SOCIAL_USER="${user}"
  45. SOCIAL_PASSWORD="${password}"
  46. SOCIAL_DOMAIN="${domain}"
  47. SOCIAL_SITENAME="${sitename}"
  48. SOCIAL_ADMIN_NICK="${admin_nick}"
  49. SOCIAL_ADMIN_PASSWORD="${admin_password}"
  50. SOCIAL_ADMIN_EMAIL="${email}"
  51. SOCIAL_SITE_PROFILE="${profile}"
  52. EOF