mirror of
https://memleak.eu/sn0w/pleroma-docker.git
synced 2024-12-22 01:48:47 -05:00
Add more config options and extend #mod with dialog(1)
This commit is contained in:
parent
8512800838
commit
4584402849
@ -1,42 +1,63 @@
|
||||
use Mix.Config
|
||||
|
||||
###
|
||||
# Tooling for runtime-configuration
|
||||
###
|
||||
defmodule Docker do
|
||||
###
|
||||
# Gets an environment variable and casts it accordingly.
|
||||
###
|
||||
def env(shortname, verbatim \\ false) do
|
||||
# Get var
|
||||
name = ((if verbatim, do: "", else: "pleroma_") <> Atom.to_string(shortname)) |> String.upcase()
|
||||
name = if verbatim, do: "", else: "pleroma_" <> Atom.to_string(shortname) |> String.upcase()
|
||||
raw_var = System.get_env(name)
|
||||
|
||||
if raw_var == nil do
|
||||
raise "Could not find #{name} in environment. Please define it and try again."
|
||||
end
|
||||
|
||||
# Match type and cast if needed
|
||||
if String.contains?(raw_var, ":") do
|
||||
if !String.contains?(raw_var, ":") do
|
||||
raw_var
|
||||
else
|
||||
var_parts = String.split(raw_var, ":", parts: 2)
|
||||
|
||||
type = Enum.at(var_parts, 0)
|
||||
var = Enum.at(var_parts, 1)
|
||||
|
||||
func = case type do
|
||||
noop = fn(x) -> x end
|
||||
|
||||
# Auto-select function and return call
|
||||
(case type do
|
||||
"int" -> fn(x) -> Integer.parse(x) |> elem(0) end
|
||||
"bool" -> fn(x) -> x == "true" end
|
||||
"string" -> fn(x) -> x end
|
||||
_ -> if verbatim do
|
||||
fn(x) -> x end
|
||||
else
|
||||
raise "Unknown type #{type} used in variable #{raw_var}."
|
||||
end
|
||||
end
|
||||
"string" -> noop
|
||||
_ -> if verbatim, do: noop, else: raise "Unknown type #{type} used in variable #{raw_var}."
|
||||
end).(var)
|
||||
end
|
||||
end
|
||||
|
||||
func.(var)
|
||||
###
|
||||
# Gets an environment variable and splits it
|
||||
###
|
||||
def split(shortname, verbatim \\ false) do
|
||||
var = Docker.env(shortname, verbatim)
|
||||
|
||||
if var == nil do
|
||||
[]
|
||||
else
|
||||
raw_var
|
||||
var
|
||||
|> String.split(';')
|
||||
|> Enum.map(&String.trim/1)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
###
|
||||
# Apply config
|
||||
###
|
||||
config :logger, level: String.to_atom(Docker.env(:loglevel) || "info")
|
||||
|
||||
config :pleroma, :emoji, shortcode_globs: Docker.split(:emoji_shortcode_globs)
|
||||
|
||||
config :pleroma, Pleroma.Web.Endpoint,
|
||||
url: [
|
||||
host: Docker.env(:url),
|
||||
@ -46,16 +67,28 @@ config :pleroma, Pleroma.Web.Endpoint,
|
||||
secret_key_base: Docker.env(:secret_key_base)
|
||||
|
||||
config :pleroma, Pleroma.Upload,
|
||||
uploads: Docker.env(:uploads_path)
|
||||
uploads: Docker.env(:uploads_path),
|
||||
strip_exif: Docker.env(:uploads_strip_exif)
|
||||
|
||||
config :pleroma, :chat,
|
||||
enabled: Docker.env(:chat_enabled)
|
||||
|
||||
config :pleroma, :instance,
|
||||
name: Docker.env(:name),
|
||||
description: Docker.env(:description),
|
||||
email: Docker.env(:admin_email),
|
||||
limit: Docker.env(:max_notice_chars),
|
||||
registrations_open: Docker.env(:registrations_open)
|
||||
registrations_open: Docker.env(:registrations_open),
|
||||
federating: Docker.env(:federating),
|
||||
rewrite_policy: Docker.split(:rewrite_policies)
|
||||
|
||||
if Docker.split(:rewrite_policies) |> Enum.any?(fn(x) -> x == "Pleroma.Web.ActivityPub.MRF.SimplePolicy" end) do
|
||||
config :pleroma, :mrf_simple,
|
||||
media_removal: Docker.split(:mrf_media_removal),
|
||||
media_nsfw: Docker.split(:mrf_media_nsfw),
|
||||
reject: Docker.split(:mrf_reject),
|
||||
federated_timeline_removal: Docker.split(:mrf_federated_timeline_removal)
|
||||
end
|
||||
|
||||
config :pleroma, :media_proxy,
|
||||
enabled: Docker.env(:media_proxy_enabled),
|
||||
@ -69,3 +102,15 @@ config :pleroma, Pleroma.Repo,
|
||||
database: Docker.env(:postgres_db, true),
|
||||
hostname: Docker.env(:postgres_ip, true),
|
||||
pool_size: Docker.env(:db_pool_size)
|
||||
|
||||
config :pleroma, :fe,
|
||||
theme: Docker.env(:fe_theme),
|
||||
logo: Docker.env(:fe_logo),
|
||||
background: Docker.env(:fe_background),
|
||||
redirect_root_no_login: Docker.env(:fe_redirect_no_login),
|
||||
redirect_root_login: Docker.env(:fe_redirect_login),
|
||||
show_instance_panel: Docker.env(:fe_show_instance_panel),
|
||||
show_who_to_follow_panel: Docker.env(:fe_show_who_to_follow_panel),
|
||||
who_to_follow_provider: Docker.env(:fe_who_to_follow_provider),
|
||||
who_to_follow_link: Docker.env(:fe_who_to_follow_link),
|
||||
scope_options_enabled: Docker.env(:fe_scope_options_enabled)
|
||||
|
45
pleroma
45
pleroma
@ -115,7 +115,12 @@ action__ps() { action__status; }
|
||||
# To persist the changes, the user still needs to rebuild the container.
|
||||
###
|
||||
action__debug() {
|
||||
debug_mounts="-v $(pwd)/custom.d:/custom.d -v $(pwd)/debug.d/build:/home/pleroma/pleroma/_build -v $(pwd)/debug.d/deps:/home/pleroma/pleroma/deps"
|
||||
debug_mounts="\
|
||||
-v $(pwd)/custom.d:/custom.d \
|
||||
-v $(pwd)/debug.d/build:/home/pleroma/pleroma/_build \
|
||||
-v $(pwd)/debug.d/deps:/home/pleroma/pleroma/deps \
|
||||
-v $(pwd)/docker-config.exs:/docker-config.exs \
|
||||
"
|
||||
|
||||
if [[ ! -d ./debug.d ]]; then
|
||||
mkdir -p ./debug.d/{build,deps}
|
||||
@ -140,9 +145,41 @@ action__debug() {
|
||||
}
|
||||
|
||||
action__mod() {
|
||||
echo "Preparing 'custom.d/$1' for modding..."
|
||||
install -D <(echo '') ./custom.d/$1
|
||||
wget -O ./custom.d/$1 https://git.pleroma.social/pleroma/pleroma/raw/$PLEROMA_VERSION/$1
|
||||
if [[ -z "$(command -v curl)" ]] || [[ -z "$(command -v jq)" ]] || [[ -z "$(command -v dialog)" ]]; then
|
||||
echo "You need curl(1), jq(1), and dialog(1) in your PATH for this subcommand."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ ! -d ./debug.d ]]; then
|
||||
mkdir ./debug.d
|
||||
fi
|
||||
|
||||
if [[ ! -f ./debug.d/mod_files.json ]] || [[ ! -z "$(find ./debug.d/mod_files.json -mmin +5)" ]]; then
|
||||
curl -sSL -# "https://glitch.sh/mirror/pleroma/files/$PLEROMA_VERSION?format=json" > ./debug.d/mod_files.json
|
||||
|
||||
if [[ -f ./debug.d/mod_files.lst ]]; then
|
||||
rm ./debug.d/mod_files.lst
|
||||
fi
|
||||
cat ./debug.d/mod_files.json | jq -r 'map("\(.)\n") | add' > ./debug.d/mod_files.lst
|
||||
fi
|
||||
|
||||
if [[ -f ./debug.d/mod_files.lst ]] && [[ -r ./debug.d/mod_files.lst ]]; then
|
||||
choices=""
|
||||
|
||||
while read -r candidate; do
|
||||
choices="$choices $candidate $(echo $candidate | rev | cut -d/ -f1 | rev)"
|
||||
done <<< $(cat ./debug.d/mod_files.lst | grep -E ".*$1.*")
|
||||
|
||||
res=$(mktemp)
|
||||
dialog --menu "Select the file you want to modify:" 35 80 30 $choices 2>$res
|
||||
choice=$(cat $res)
|
||||
|
||||
install -D <(echo '') ./custom.d/$choice
|
||||
curl -sSL -# "https://git.pleroma.social/pleroma/pleroma/raw/$PLEROMA_VERSION/$choice" > "./custom.d/$choice"
|
||||
else
|
||||
install -D <(echo '') ./custom.d/$1
|
||||
curl -sSL -# "https://git.pleroma.social/pleroma/pleroma/raw/$PLEROMA_VERSION/$1" > "./custom.d/$1"
|
||||
fi
|
||||
}
|
||||
|
||||
# Check if there is any command at all
|
||||
|
Loading…
Reference in New Issue
Block a user