Releases fixes

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2021-03-11 19:50:54 +01:00
parent 91567ba7d4
commit 239457a219
9 changed files with 59 additions and 15 deletions

View File

@@ -9,6 +9,7 @@ defmodule Mix.Tasks.Mobilizon.Common do
"""
def start_mobilizon do
if mix_task?(), do: Mix.Task.run("app.config")
Application.put_env(:phoenix, :serve_endpoints, false, persistent: true)
{:ok, _} = Application.ensure_all_started(:mobilizon)
@@ -64,6 +65,8 @@ defmodule Mix.Tasks.Mobilizon.Common do
@doc "Performs a safe check whether `Mix.shell/0` is available (does not raise if Mix is not loaded)"
def mix_shell?, do: :erlang.function_exported(Mix, :shell, 0)
def mix_task?, do: :erlang.function_exported(Mix.Task, :run, 1)
def escape_sh_path(path) do
~S(') <> String.replace(path, ~S('), ~S(\')) <> ~S(')
end

View File

@@ -41,6 +41,7 @@ defmodule Mix.Tasks.Mobilizon.Instance do
options,
strict: [
force: :boolean,
source: :boolean,
output: :string,
output_psql: :string,
domain: :string,
@@ -55,7 +56,8 @@ defmodule Mix.Tasks.Mobilizon.Instance do
],
aliases: [
o: :output,
f: :force
f: :force,
s: :source
]
)
@@ -67,6 +69,7 @@ defmodule Mix.Tasks.Mobilizon.Instance do
will_overwrite = Enum.filter(paths, &File.exists?/1)
proceed? = Enum.empty?(will_overwrite) or Keyword.get(options, :force, false)
source_install? = Keyword.get(options, :source, false)
if proceed? do
[domain, port | _] =
@@ -148,7 +151,8 @@ defmodule Mix.Tasks.Mobilizon.Instance do
database_password: dbpass,
instance_secret: instance_secret,
auth_secret: auth_secret,
listen_port: listen_port
listen_port: listen_port,
release: source_install? == false
)
result_psql =
@@ -193,7 +197,7 @@ defmodule Mix.Tasks.Mobilizon.Instance do
{:error, err} ->
shell_error(
"\nERROR: Unable to write config file to #{config_path}. Make sure you have permissions on the destination.\n"
"\nERROR: Unable to write config file to #{config_path}. Make sure you have permissions on the destination and that the parent path exists.\n"
)
{:error, err}
@@ -209,7 +213,7 @@ defmodule Mix.Tasks.Mobilizon.Instance do
{:error, err} ->
shell_error(
"\nERROR: Unable to write psql file to #{psql_path}. Make sure you have permissions on the destination.\n"
"\nERROR: Unable to write psql file to #{psql_path}. Make sure you have permissions on the destination and that the parent path exists.\n"
)
{:error, err}