aboutsummaryrefslogtreecommitdiff
path: root/lib/mix/tasks
diff options
context:
space:
mode:
Diffstat (limited to 'lib/mix/tasks')
-rw-r--r--lib/mix/tasks/pleroma/config.ex22
-rw-r--r--lib/mix/tasks/pleroma/ecto/ecto.ex1
-rw-r--r--lib/mix/tasks/pleroma/instance.ex24
-rw-r--r--lib/mix/tasks/pleroma/user.ex4
4 files changed, 25 insertions, 26 deletions
diff --git a/lib/mix/tasks/pleroma/config.ex b/lib/mix/tasks/pleroma/config.ex
index cc5425362..faa605d9b 100644
--- a/lib/mix/tasks/pleroma/config.ex
+++ b/lib/mix/tasks/pleroma/config.ex
@@ -24,7 +24,7 @@ defmodule Mix.Tasks.Pleroma.Config do
|> Enum.reject(fn {k, _v} -> k in [Pleroma.Repo, :env] end)
|> Enum.each(fn {k, v} ->
key = to_string(k) |> String.replace("Elixir.", "")
- {:ok, _} = Config.update_or_create(%{key: key, value: v})
+ {:ok, _} = Config.update_or_create(%{group: "pleroma", key: key, value: v})
Mix.shell().info("#{key} is migrated.")
end)
@@ -36,9 +36,11 @@ defmodule Mix.Tasks.Pleroma.Config do
end
end
- def run(["migrate_from_db", env]) do
+ def run(["migrate_from_db", env, delete?]) do
start_pleroma()
+ delete? = if delete? == "true", do: true, else: false
+
if Pleroma.Config.get([:instance, :dynamic_configuration]) do
config_path = "config/#{env}.exported_from_db.secret.exs"
@@ -47,15 +49,23 @@ defmodule Mix.Tasks.Pleroma.Config do
Repo.all(Config)
|> Enum.each(fn config ->
- mark = if String.starts_with?(config.key, "Pleroma."), do: ",", else: ":"
+ mark =
+ if String.starts_with?(config.key, "Pleroma.") or
+ String.starts_with?(config.key, "Ueberauth"),
+ do: ",",
+ else: ":"
IO.write(
file,
- "config :pleroma, #{config.key}#{mark} #{inspect(Config.from_binary(config.value))}\r\n"
+ "config :#{config.group}, #{config.key}#{mark} #{
+ inspect(Config.from_binary(config.value))
+ }\r\n"
)
- {:ok, _} = Repo.delete(config)
- Mix.shell().info("#{config.key} deleted from DB.")
+ if delete? do
+ {:ok, _} = Repo.delete(config)
+ Mix.shell().info("#{config.key} deleted from DB.")
+ end
end)
File.close(file)
diff --git a/lib/mix/tasks/pleroma/ecto/ecto.ex b/lib/mix/tasks/pleroma/ecto/ecto.ex
index 324f57fdd..b66f63376 100644
--- a/lib/mix/tasks/pleroma/ecto/ecto.ex
+++ b/lib/mix/tasks/pleroma/ecto/ecto.ex
@@ -1,6 +1,7 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2018 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-onl
+
defmodule Mix.Tasks.Pleroma.Ecto do
@doc """
Ensures the given repository's migrations path exists on the file system.
diff --git a/lib/mix/tasks/pleroma/instance.ex b/lib/mix/tasks/pleroma/instance.ex
index 997eabbeb..2ae16adc0 100644
--- a/lib/mix/tasks/pleroma/instance.ex
+++ b/lib/mix/tasks/pleroma/instance.ex
@@ -114,12 +114,12 @@ defmodule Mix.Tasks.Pleroma.Instance do
options,
:db_configurable,
"Do you want to store the configuration in the database (allows controlling it from admin-fe)? (y/n)",
- "y"
+ "n"
) === "y"
dbhost = get_option(options, :dbhost, "What is the hostname of your database?", "localhost")
- dbname = get_option(options, :dbname, "What is the name of your database?", "pleroma_dev")
+ dbname = get_option(options, :dbname, "What is the name of your database?", "pleroma")
dbuser =
get_option(
@@ -149,7 +149,7 @@ defmodule Mix.Tasks.Pleroma.Instance do
uploads_dir =
get_option(
options,
- :upload_dir,
+ :uploads_dir,
"What directory should media uploads go in (when using the local uploader)?",
Pleroma.Config.get([Pleroma.Uploaders.Local, :uploads])
)
@@ -198,28 +198,16 @@ defmodule Mix.Tasks.Pleroma.Instance do
rum_enabled: rum_enabled
)
- shell_info(
- "Writing config to #{config_path}. You should rename it to config/prod.secret.exs or config/dev.secret.exs."
- )
+ shell_info("Writing config to #{config_path}.")
File.write(config_path, result_config)
- shell_info("Writing #{psql_path}.")
+ shell_info("Writing the postgres script to #{psql_path}.")
File.write(psql_path, result_psql)
write_robots_txt(indexable, template_dir)
shell_info(
- "\n" <>
- """
- To get started:
- 1. Verify the contents of the generated files.
- 2. Run `sudo -u postgres psql -f #{escape_sh_path(psql_path)}`.
- """ <>
- if config_path in ["config/dev.secret.exs", "config/prod.secret.exs"] do
- ""
- else
- "3. Run `mv #{escape_sh_path(config_path)} 'config/prod.secret.exs'`."
- end
+ "\n All files successfully written! Refer to the installation instructions for your platform for next steps"
)
else
shell_error(
diff --git a/lib/mix/tasks/pleroma/user.ex b/lib/mix/tasks/pleroma/user.ex
index ab158f57e..8a78b4fe6 100644
--- a/lib/mix/tasks/pleroma/user.ex
+++ b/lib/mix/tasks/pleroma/user.ex
@@ -204,9 +204,9 @@ defmodule Mix.Tasks.Pleroma.User do
IO.puts(
"URL: #{
- Pleroma.Web.Router.Helpers.util_url(
+ Pleroma.Web.Router.Helpers.reset_password_url(
Pleroma.Web.Endpoint,
- :show_password_reset,
+ :reset,
token.token
)
}"