2020-05-06 12:57:32 +01:00
|
|
|
#!/bin/sh
|
|
|
|
|
2020-05-16 13:37:06 +01:00
|
|
|
git_dir=$PWD
|
|
|
|
while [ ! -d .git ]; do
|
|
|
|
git_dir=$(dirname "${git_dir}")
|
|
|
|
done
|
|
|
|
|
|
|
|
cd "${git_dir}" || exit
|
|
|
|
|
2020-06-05 00:24:28 +01:00
|
|
|
if [ -e ./docker/bootstrap/bootstrap.env ]; then
|
|
|
|
. ./docker/bootstrap/bootstrap.env
|
|
|
|
fi
|
2020-05-06 12:57:32 +01:00
|
|
|
|
2020-06-05 00:24:28 +01:00
|
|
|
# TODO Add configuration
|
|
|
|
cp docker-compose.yaml.in docker-compose.yaml
|
2020-05-06 12:57:32 +01:00
|
|
|
|
2020-05-16 13:37:06 +01:00
|
|
|
while :; do
|
|
|
|
printf "DBMS (postgres|mariadb): " && read -r dbms
|
2020-06-05 00:24:28 +01:00
|
|
|
echo "${dbms}" | grep -Eq 'postgres|mariadb' && break
|
|
|
|
done
|
|
|
|
|
|
|
|
while :; do
|
|
|
|
printf "Social database name: " && read -r db
|
|
|
|
echo "${db}" | grep -vEq 'postgres' && break
|
2020-05-16 13:37:06 +01:00
|
|
|
done
|
2020-05-06 12:57:32 +01:00
|
|
|
|
2020-05-16 13:37:06 +01:00
|
|
|
[ "${dbms}" = 'mariadb' ] && printf "Database user: " && read -r user
|
|
|
|
printf "Database password: " && read -r password
|
|
|
|
printf "Sitename: " && read -r sitename
|
|
|
|
printf "Admin nickname: " && read -r admin_nick
|
|
|
|
printf "Admin password: " && read -r admin_password
|
|
|
|
|
|
|
|
while :; do
|
2020-05-16 21:42:31 +01:00
|
|
|
printf "Site profile (public|private|community|single_user): " && read -r profile
|
2020-06-05 00:24:28 +01:00
|
|
|
echo "${profile}" | grep -Eq 'public|private|community|single_user' && break
|
2020-05-16 13:37:06 +01:00
|
|
|
done
|
|
|
|
|
|
|
|
mkdir -p ./docker/db
|
2020-05-06 12:57:32 +01:00
|
|
|
|
2020-05-16 13:37:06 +01:00
|
|
|
if [ "${dbms}" = 'mariadb' ]; then
|
|
|
|
printf "DB root password: " && read -r db_root_password
|
2020-05-06 12:57:32 +01:00
|
|
|
cat > ./docker/db/db.env <<EOF
|
|
|
|
DBMS=${dbms}
|
|
|
|
MYSQL_ROOT_PASSWORD=${db_root_password}
|
|
|
|
EOF
|
|
|
|
|
|
|
|
database_url="DATABASE_URL=mysql://${user}:${password}@db:3306/${db}"
|
|
|
|
|
|
|
|
else
|
|
|
|
cat > ./docker/db/db.env <<EOF
|
|
|
|
DBMS=${dbms}
|
|
|
|
POSTGRES_USER=postgres
|
2020-05-16 13:37:06 +01:00
|
|
|
POSTGRES_PASSWORD=${password}
|
2020-05-06 12:57:32 +01:00
|
|
|
EOF
|
|
|
|
|
2020-05-16 13:37:06 +01:00
|
|
|
user='postgres'
|
2020-05-06 12:57:32 +01:00
|
|
|
database_url="DATABASE_URL=postgresql://${user}:${password}@db:5432/${db}"
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
2020-05-16 13:37:06 +01:00
|
|
|
echo "${database_url}" > .env.local
|
2020-05-06 12:57:32 +01:00
|
|
|
|
|
|
|
mkdir -p ./docker/social
|
|
|
|
|
|
|
|
cat > ./docker/social/social.env <<EOF
|
|
|
|
SOCIAL_DBMS=${dbms}
|
|
|
|
SOCIAL_DB=${db}
|
|
|
|
SOCIAL_USER=${user}
|
|
|
|
SOCIAL_PASSWORD=${password}
|
|
|
|
SOCIAL_DOMAIN=${domain}
|
|
|
|
SOCIAL_SITENAME=${sitename}
|
|
|
|
SOCIAL_ADMIN_NICK=${admin_nick}
|
|
|
|
SOCIAL_ADMIN_PASSWORD=${admin_password}
|
|
|
|
SOCIAL_ADMIN_EMAIL=${email}
|
|
|
|
SOCIAL_SITE_PROFILE=${profile}
|
|
|
|
EOF
|