Move configuration to traditional way
⭐️ This is the way. Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
@@ -58,7 +58,7 @@ defmodule Mix.Tasks.Mobilizon.Instance do
|
||||
|
||||
paths =
|
||||
[config_path, psql_path] = [
|
||||
Keyword.get(options, :output, ".env"),
|
||||
Keyword.get(options, :output, "config/prod.secret.exs"),
|
||||
Keyword.get(options, :output_psql, "setup_db.psql")
|
||||
]
|
||||
|
||||
@@ -113,11 +113,30 @@ defmodule Mix.Tasks.Mobilizon.Instance do
|
||||
"autogenerated"
|
||||
)
|
||||
|
||||
secret = :crypto.strong_rand_bytes(64) |> Base.encode64() |> binary_part(0, 64)
|
||||
listen_port =
|
||||
Common.get_option(
|
||||
options,
|
||||
:listen_port,
|
||||
"What port will the app listen to (leave it if you are using the default setup with nginx)?",
|
||||
4000
|
||||
)
|
||||
|
||||
listen_ip =
|
||||
Common.get_option(
|
||||
options,
|
||||
:listen_ip,
|
||||
"What ip will the app listen to (leave it if you are using the default setup with nginx)?",
|
||||
"127.0.0.1"
|
||||
)
|
||||
|
||||
instance_secret = :crypto.strong_rand_bytes(64) |> Base.encode64() |> binary_part(0, 64)
|
||||
auth_secret = :crypto.strong_rand_bytes(64) |> Base.encode64() |> binary_part(0, 64)
|
||||
|
||||
template_dir = Application.app_dir(:mobilizon, "priv") <> "/templates"
|
||||
|
||||
result_config =
|
||||
EEx.eval_file(
|
||||
".env.sample" |> Path.expand(__DIR__ <> "../../../../../"),
|
||||
"#{template_dir}/config.template.eex",
|
||||
instance_domain: domain,
|
||||
instance_port: port,
|
||||
instance_email: email,
|
||||
@@ -128,12 +147,15 @@ defmodule Mix.Tasks.Mobilizon.Instance do
|
||||
database_username: dbuser,
|
||||
database_password: dbpass,
|
||||
version: Mobilizon.Mixfile.project() |> Keyword.get(:version),
|
||||
instance_secret: secret
|
||||
instance_secret: instance_secret,
|
||||
auth_secret: auth_secret,
|
||||
listen_ip: listen_ip,
|
||||
listen_port: listen_port
|
||||
)
|
||||
|
||||
result_psql =
|
||||
EEx.eval_file(
|
||||
"support/postgresql/setup_db.psql" |> Path.expand(__DIR__ <> "../../../../../"),
|
||||
"#{template_dir}/setup_db.eex",
|
||||
database_name: dbname,
|
||||
database_username: dbuser,
|
||||
database_password: dbpass
|
||||
@@ -155,12 +177,7 @@ defmodule Mix.Tasks.Mobilizon.Instance do
|
||||
2. Run `sudo -u postgres psql -f #{Common.escape_sh_path(psql_path)} && rm #{
|
||||
Common.escape_sh_path(psql_path)
|
||||
}`.
|
||||
""" <>
|
||||
if config_path in [".env.production", ".env.dev", ".env.test"] do
|
||||
""
|
||||
else
|
||||
"3. Run `mv #{Common.escape_sh_path(config_path)} '.env.production'`."
|
||||
end
|
||||
"""
|
||||
)
|
||||
else
|
||||
Mix.shell().error(
|
||||
|
||||
Reference in New Issue
Block a user