1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Mix.Tasks.Pleroma.ReleaseEnv do
9 @shortdoc "Generate Pleroma environment file."
10 @moduledoc File.read!("docs/administration/CLI_tasks/release_environments.md")
12 def run(["gen" | rest]) do
30 "Environment file path",
31 "./config/pleroma.env"
34 env_path = Path.expand(file_path)
37 if File.exists?(env_path) do
41 "Environment file is exist. Do you want overwritten the #{env_path} file? (y/n)",
49 case do_generate(env_path) do
52 File.Error.message(%{action: "write to file", reason: reason, path: env_path})
56 shell_info("\nThe file generated: #{env_path}.\n")
59 WARNING: before start pleroma app please to made the file read-only and non-modifiable.
61 chmod 0444 #{file_path}
62 chattr +i #{file_path}
66 shell_info("\nThe file is exist. #{env_path}.\n")
70 def do_generate(path) do
71 content = "RELEASE_COOKIE=#{Base.encode32(:crypto.strong_rand_bytes(32))}"
73 File.mkdir_p!(Path.dirname(path))
74 File.write(path, content)