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