@@ -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
|
||||
|
||||
@@ -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}
|
||||
|
||||
Reference in New Issue
Block a user