added generated `pleroma.env`
This commit is contained in:
parent
b48724afcd
commit
20e68b30f0
|
@ -27,6 +27,8 @@ erl_crash.dump
|
||||||
# variables.
|
# variables.
|
||||||
/config/*.secret.exs
|
/config/*.secret.exs
|
||||||
/config/generated_config.exs
|
/config/generated_config.exs
|
||||||
|
/config/*.env
|
||||||
|
|
||||||
|
|
||||||
# Database setup file, some may forget to delete it
|
# Database setup file, some may forget to delete it
|
||||||
/config/setup_db.psql
|
/config/setup_db.psql
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
# Generate release environment file
|
||||||
|
|
||||||
|
```sh tab="OTP"
|
||||||
|
./bin/pleroma_ctl release_env gen
|
||||||
|
```
|
||||||
|
|
||||||
|
```sh tab="From Source"
|
||||||
|
mix pleroma.release_env gen
|
||||||
|
```
|
|
@ -149,6 +149,9 @@ chown -R pleroma /etc/pleroma
|
||||||
# Run the config generator
|
# Run the config generator
|
||||||
su pleroma -s $SHELL -lc "./bin/pleroma_ctl instance gen --output /etc/pleroma/config.exs --output-psql /tmp/setup_db.psql"
|
su pleroma -s $SHELL -lc "./bin/pleroma_ctl instance gen --output /etc/pleroma/config.exs --output-psql /tmp/setup_db.psql"
|
||||||
|
|
||||||
|
# Run the environment file generator.
|
||||||
|
su pleroma -s $SHELL -lc "./bin/pleroma_ctl release_env gen"
|
||||||
|
|
||||||
# Create the postgres database
|
# Create the postgres database
|
||||||
su postgres -s $SHELL -lc "psql -f /tmp/setup_db.psql"
|
su postgres -s $SHELL -lc "psql -f /tmp/setup_db.psql"
|
||||||
|
|
||||||
|
@ -159,7 +162,7 @@ su pleroma -s $SHELL -lc "./bin/pleroma_ctl migrate"
|
||||||
# su pleroma -s $SHELL -lc "./bin/pleroma_ctl migrate --migrations-path priv/repo/optional_migrations/rum_indexing/"
|
# su pleroma -s $SHELL -lc "./bin/pleroma_ctl migrate --migrations-path priv/repo/optional_migrations/rum_indexing/"
|
||||||
|
|
||||||
# Start the instance to verify that everything is working as expected
|
# Start the instance to verify that everything is working as expected
|
||||||
su pleroma -s $SHELL -lc "./bin/pleroma daemon"
|
su pleroma -s $SHELL -lc "export $( cat /opt/pleroma/config/pleroma.env | xargs); ./bin/pleroma daemon"
|
||||||
|
|
||||||
# Wait for about 20 seconds and query the instance endpoint, if it shows your uri, name and email correctly, you are configured correctly
|
# Wait for about 20 seconds and query the instance endpoint, if it shows your uri, name and email correctly, you are configured correctly
|
||||||
sleep 20 && curl http://localhost:4000/api/v1/instance
|
sleep 20 && curl http://localhost:4000/api/v1/instance
|
||||||
|
@ -311,4 +314,3 @@ This will create an account withe the username of 'joeuser' with the email addre
|
||||||
## Questions
|
## Questions
|
||||||
|
|
||||||
Questions about the installation or didn’t it work as it should be, ask in [#pleroma:matrix.org](https://matrix.heldscal.la/#/room/#freenode_#pleroma:matrix.org) or IRC Channel **#pleroma** on **Freenode**.
|
Questions about the installation or didn’t it work as it should be, ask in [#pleroma:matrix.org](https://matrix.heldscal.la/#/room/#freenode_#pleroma:matrix.org) or IRC Channel **#pleroma** on **Freenode**.
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,8 @@ Environment="MIX_ENV=prod"
|
||||||
Environment="HOME=/var/lib/pleroma"
|
Environment="HOME=/var/lib/pleroma"
|
||||||
; Path to the folder containing the Pleroma installation.
|
; Path to the folder containing the Pleroma installation.
|
||||||
WorkingDirectory=/opt/pleroma
|
WorkingDirectory=/opt/pleroma
|
||||||
|
; Path to the environment file. the file contains RELEASE_COOKIE and etc
|
||||||
|
EnvironmentFile=/opt/pleroma/config/pleroma.env
|
||||||
; Path to the Mix binary.
|
; Path to the Mix binary.
|
||||||
ExecStart=/usr/bin/mix phx.server
|
ExecStart=/usr/bin/mix phx.server
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,64 @@
|
||||||
|
# Pleroma: A lightweight social networking server
|
||||||
|
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
||||||
|
# SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
|
defmodule Mix.Tasks.Pleroma.ReleaseEnv do
|
||||||
|
use Mix.Task
|
||||||
|
import Mix.Pleroma
|
||||||
|
|
||||||
|
@shortdoc "Generate Pleroma environment file."
|
||||||
|
@moduledoc File.read!("docs/administration/CLI_tasks/release_environments.md")
|
||||||
|
|
||||||
|
def run(["gen" | rest]) do
|
||||||
|
{options, [], []} =
|
||||||
|
OptionParser.parse(
|
||||||
|
rest,
|
||||||
|
strict: [
|
||||||
|
force: :boolean,
|
||||||
|
path: :string
|
||||||
|
],
|
||||||
|
aliases: [
|
||||||
|
p: :path,
|
||||||
|
f: :force
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
|
env_path =
|
||||||
|
get_option(
|
||||||
|
options,
|
||||||
|
:path,
|
||||||
|
"Environment file path",
|
||||||
|
"config/pleroma.env"
|
||||||
|
)
|
||||||
|
|> Path.expand()
|
||||||
|
|
||||||
|
proceed? =
|
||||||
|
if File.exists?(env_path) do
|
||||||
|
get_option(
|
||||||
|
options,
|
||||||
|
:force,
|
||||||
|
"Environment file is exist. Do you want overwritten the #{env_path} file? (y/n)",
|
||||||
|
"n"
|
||||||
|
) === "y"
|
||||||
|
else
|
||||||
|
true
|
||||||
|
end
|
||||||
|
|
||||||
|
if proceed? do
|
||||||
|
do_generate(env_path)
|
||||||
|
|
||||||
|
shell_info(
|
||||||
|
"The file generated: #{env_path}.\nTo use the enviroment file need to add the line ';EnvironmentFile=#{
|
||||||
|
env_path
|
||||||
|
}' in service file (/installation/pleroma.service)."
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def do_generate(path) do
|
||||||
|
content = "RELEASE_COOKIE=#{Base.encode32(:crypto.strong_rand_bytes(32))}"
|
||||||
|
|
||||||
|
File.mkdir_p!(Path.dirname(path))
|
||||||
|
File.write!(path, content)
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,30 @@
|
||||||
|
# Pleroma: A lightweight social networking server
|
||||||
|
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
||||||
|
# SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
|
defmodule Mix.Tasks.Pleroma.ReleaseEnvTest do
|
||||||
|
use ExUnit.Case
|
||||||
|
import ExUnit.CaptureIO, only: [capture_io: 1]
|
||||||
|
|
||||||
|
@path "config/pleroma.test.env"
|
||||||
|
|
||||||
|
def do_clean do
|
||||||
|
if File.exists?(@path) do
|
||||||
|
File.rm_rf(@path)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
setup do
|
||||||
|
do_clean()
|
||||||
|
on_exit(fn -> do_clean() end)
|
||||||
|
:ok
|
||||||
|
end
|
||||||
|
|
||||||
|
test "generate pleroma.env" do
|
||||||
|
assert capture_io(fn ->
|
||||||
|
Mix.Tasks.Pleroma.ReleaseEnv.run(["gen", "--path", @path, "--force"])
|
||||||
|
end) =~ "The file generated"
|
||||||
|
|
||||||
|
assert File.read!(@path) =~ "RELEASE_COOKIE="
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue