From 1486ad0c6e6af46d59d32b77907d7e6182218daa Mon Sep 17 00:00:00 2001 From: FloatingGhost Date: Tue, 5 Jul 2022 14:45:28 +0100 Subject: [PATCH 1/6] import logger --- lib/pleroma/collections/fetcher.ex | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/pleroma/collections/fetcher.ex b/lib/pleroma/collections/fetcher.ex index 382defff4..0c81f0b56 100644 --- a/lib/pleroma/collections/fetcher.ex +++ b/lib/pleroma/collections/fetcher.ex @@ -9,6 +9,7 @@ defmodule Akkoma.Collections.Fetcher do """ alias Pleroma.Object.Fetcher alias Pleroma.Config + require Logger def fetch_collection_by_ap_id(ap_id) when is_binary(ap_id) do fetch_collection(ap_id) From 3d9dabd9147d2ba001d64de0ea5527bc5727dda6 Mon Sep 17 00:00:00 2001 From: norm Date: Wed, 6 Jul 2022 18:28:41 +0000 Subject: [PATCH 2/6] Fix config path lookup (#51) Reviewed-on: https://akkoma.dev/AkkomaGang/akkoma/pulls/51 Co-authored-by: norm Co-committed-by: norm --- lib/pleroma/config/release_runtime_provider.ex | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/pleroma/config/release_runtime_provider.ex b/lib/pleroma/config/release_runtime_provider.ex index e5e9d3dcd..1e4bddc59 100644 --- a/lib/pleroma/config/release_runtime_provider.ex +++ b/lib/pleroma/config/release_runtime_provider.ex @@ -12,7 +12,13 @@ defmodule Pleroma.Config.ReleaseRuntimeProvider do with_defaults = Config.Reader.merge(config, Pleroma.Config.Holder.release_defaults()) config_path = - opts[:config_path] || System.get_env("PLEROMA_CONFIG_PATH") || "/etc/pleroma/config.exs" + cond do + opts[:config_path] -> opts[:config_path] + System.get_env("PLEROMA_CONFIG_PATH") -> System.get_env("PLEROMA_CONFIG_PATH") + System.get_env("AKKOMA_CONFIG_PATH") -> System.get_env("AKKOMA_CONFIG_PATH") + File.exists?("/etc/akkoma/config.exs") -> "/etc/akkoma/config.exs" + true -> "/etc/pleroma/config.exs" + end with_runtime_config = if File.exists?(config_path) do From c0e6f30e4d17bd69b7ddd26aa0c0f1433184128a Mon Sep 17 00:00:00 2001 From: norm Date: Wed, 6 Jul 2022 18:50:01 +0000 Subject: [PATCH 3/6] Update sample config files (#48) Reviewed-on: https://akkoma.dev/AkkomaGang/akkoma/pulls/48 Co-authored-by: norm Co-committed-by: norm --- docs/configuration/howto_mediaproxy.md | 2 +- docs/installation/alpine_linux_en.md | 2 +- docs/installation/arch_linux_en.md | 2 +- docs/installation/debian_based_en.md | 2 +- docs/installation/debian_based_jp.md | 2 +- docs/installation/freebsd_en.md | 2 +- docs/installation/gentoo_en.md | 2 +- docs/installation/netbsd_en.md | 2 +- docs/installation/otp_en.md | 6 +-- ...a-mongooseim.cfg => akkoma-mongooseim.cfg} | 0 .../{pleroma.service => akkoma.service} | 18 ++++---- installation/akkoma.supervisord | 21 +++++++++ installation/{pleroma.vcl => akkoma.vcl} | 0 .../akkoma-apache.conf} | 14 +++--- .../apache-cache-purge.sh.example | 4 +- installation/caddy/Caddyfile | 17 +++++++ installation/caddyfile-pleroma.example | 38 ---------------- installation/freebsd/rc.d/akkoma | 27 +++++++++++ installation/freebsd/rc.d/pleroma | 27 ----------- installation/init.d/akkoma | 45 +++++++++++++++++++ installation/init.d/pleroma | 45 ------------------- installation/netbsd/rc.d/{pleroma => akkoma} | 10 ++--- .../{pleroma.nginx => nginx/akkoma.nginx} | 6 +-- .../{ => nginx}/nginx-cache-purge.sh.example | 2 +- installation/openbsd/httpd.conf | 2 +- installation/openbsd/rc.d/akkomad | 34 ++++++++++++++ installation/openbsd/rc.d/pleromad | 34 -------------- installation/openbsd/relayd.conf | 12 ++--- installation/pleroma.supervisord | 21 --------- 29 files changed, 189 insertions(+), 210 deletions(-) rename installation/{pleroma-mongooseim.cfg => akkoma-mongooseim.cfg} (100%) rename installation/{pleroma.service => akkoma.service} (65%) create mode 100644 installation/akkoma.supervisord rename installation/{pleroma.vcl => akkoma.vcl} (100%) rename installation/{pleroma-apache.conf => apache/akkoma-apache.conf} (87%) rename installation/{ => apache}/apache-cache-purge.sh.example (89%) create mode 100644 installation/caddy/Caddyfile delete mode 100644 installation/caddyfile-pleroma.example create mode 100755 installation/freebsd/rc.d/akkoma delete mode 100755 installation/freebsd/rc.d/pleroma create mode 100755 installation/init.d/akkoma delete mode 100755 installation/init.d/pleroma rename installation/netbsd/rc.d/{pleroma => akkoma} (82%) rename installation/{pleroma.nginx => nginx/akkoma.nginx} (94%) rename installation/{ => nginx}/nginx-cache-purge.sh.example (95%) create mode 100755 installation/openbsd/rc.d/akkomad delete mode 100755 installation/openbsd/rc.d/pleromad delete mode 100644 installation/pleroma.supervisord diff --git a/docs/configuration/howto_mediaproxy.md b/docs/configuration/howto_mediaproxy.md index d28cf900a..8ad81bdfb 100644 --- a/docs/configuration/howto_mediaproxy.md +++ b/docs/configuration/howto_mediaproxy.md @@ -18,7 +18,7 @@ Also add the following on top of the configuration, outside of the `server` bloc ``` proxy_cache_path /tmp/akkoma-media-cache levels=1:2 keys_zone=akkoma_media_cache:10m max_size=10g inactive=720m use_temp_path=off; ``` -If you came here from one of the installation guides, take a look at the example configuration `/installation/akkoma.nginx`, where this part is already included. +If you came here from one of the installation guides, take a look at the example configuration `/installation/nginx/akkoma.nginx`, where this part is already included. * Append the following to your `prod.secret.exs` or `dev.secret.exs` (depends on which mode your instance is running): ``` diff --git a/docs/installation/alpine_linux_en.md b/docs/installation/alpine_linux_en.md index 2bed976a9..735b89901 100644 --- a/docs/installation/alpine_linux_en.md +++ b/docs/installation/alpine_linux_en.md @@ -161,7 +161,7 @@ If that doesn’t work, make sure, that nginx is not already running. If it stil * Copy the example nginx configuration to the nginx folder ```shell -sudo cp /opt/akkoma/installation/akkoma.nginx /etc/nginx/conf.d/akkoma.conf +sudo cp /opt/akkoma/installation/nginx/akkoma.nginx /etc/nginx/conf.d/akkoma.conf ``` * Before starting nginx edit the configuration and change it to your needs. You must change change `server_name` and the paths to the certificates. You can use `nano` (install with `apk add nano` if missing). diff --git a/docs/installation/arch_linux_en.md b/docs/installation/arch_linux_en.md index dfddfe23c..4c8110b66 100644 --- a/docs/installation/arch_linux_en.md +++ b/docs/installation/arch_linux_en.md @@ -168,7 +168,7 @@ If that doesn’t work, make sure, that nginx is not already running. If it stil * Copy the example nginx configuration and activate it: ```shell -sudo cp /opt/akkoma/installation/akkoma.nginx /etc/nginx/sites-available/akkoma.nginx +sudo cp /opt/akkoma/installation/nginx/akkoma.nginx /etc/nginx/sites-available/akkoma.nginx sudo ln -s /etc/nginx/sites-available/akkoma.nginx /etc/nginx/sites-enabled/akkoma.nginx ``` diff --git a/docs/installation/debian_based_en.md b/docs/installation/debian_based_en.md index b67c1edc2..86d371f1e 100644 --- a/docs/installation/debian_based_en.md +++ b/docs/installation/debian_based_en.md @@ -131,7 +131,7 @@ If that doesn’t work, make sure, that nginx is not already running. If it stil * Copy the example nginx configuration and activate it: ```shell -sudo cp /opt/akkoma/installation/akkoma.nginx /etc/nginx/sites-available/akkoma.nginx +sudo cp /opt/akkoma/installation/nginx/akkoma.nginx /etc/nginx/sites-available/akkoma.nginx sudo ln -s /etc/nginx/sites-available/akkoma.nginx /etc/nginx/sites-enabled/akkoma.nginx ``` diff --git a/docs/installation/debian_based_jp.md b/docs/installation/debian_based_jp.md index 5d38f43cf..51d24a2d7 100644 --- a/docs/installation/debian_based_jp.md +++ b/docs/installation/debian_based_jp.md @@ -143,7 +143,7 @@ sudo certbot certonly --email -d --standalone * nginxの設定ファイルサンプルをnginxフォルダーにコピーします。 ``` -sudo cp /opt/akkoma/installation/akkoma.nginx /etc/nginx/sites-available/akkoma.nginx +sudo cp /opt/akkoma/installation/nginx/akkoma.nginx /etc/nginx/sites-available/akkoma.nginx sudo ln -s /etc/nginx/sites-available/akkoma.nginx /etc/nginx/sites-enabled/akkoma.nginx ``` diff --git a/docs/installation/freebsd_en.md b/docs/installation/freebsd_en.md index 5d6779ed2..2b439a7df 100644 --- a/docs/installation/freebsd_en.md +++ b/docs/installation/freebsd_en.md @@ -163,7 +163,7 @@ http { } ``` -As root, copy `/home/akkoma/akkoma/installation/akkoma.nginx` to +As root, copy `/home/akkoma/akkoma/installation/nginx/akkoma.nginx` to `/usr/local/etc/nginx/sites-available/akkoma.nginx`. Edit the defaults of `/usr/local/etc/nginx/sites-available/akkoma.nginx`: diff --git a/docs/installation/gentoo_en.md b/docs/installation/gentoo_en.md index 176eaab47..6ca029720 100644 --- a/docs/installation/gentoo_en.md +++ b/docs/installation/gentoo_en.md @@ -217,7 +217,7 @@ If you are using any additional subdomains, such as for a media proxy, you can r * Copy the example nginx configuration and activate it: ```shell - # cp /home/akkoma/akkoma/installation/akkoma.nginx /etc/nginx/sites-available/ + # cp /home/akkoma/akkoma/installation/nginx/akkoma.nginx /etc/nginx/sites-available/ # ln -s /etc/nginx/sites-available/akkoma.nginx /etc/nginx/sites-enabled/akkoma.nginx ``` diff --git a/docs/installation/netbsd_en.md b/docs/installation/netbsd_en.md index df05f0e96..164ed6d77 100644 --- a/docs/installation/netbsd_en.md +++ b/docs/installation/netbsd_en.md @@ -101,7 +101,7 @@ $ MIX_ENV=prod mix ecto.migrate ## Configuring nginx Install the example configuration file -`/home/akkoma/akkoma/installation/akkoma.nginx` to +`/home/akkoma/akkoma/installation/nginx/akkoma.nginx` to `/usr/pkg/etc/nginx.conf`. Note that it will need to be wrapped in a `http {}` block. You should add diff --git a/docs/installation/otp_en.md b/docs/installation/otp_en.md index 0d433686e..05aab9a58 100644 --- a/docs/installation/otp_en.md +++ b/docs/installation/otp_en.md @@ -175,18 +175,18 @@ The location of nginx configs is dependent on the distro === "Alpine" ``` - cp /opt/akkoma/installation/akkoma.nginx /etc/nginx/conf.d/akkoma.conf + cp /opt/akkoma/installation/nginx/akkoma.nginx /etc/nginx/conf.d/akkoma.conf ``` === "Debian/Ubuntu" ``` - cp /opt/akkoma/installation/akkoma.nginx /etc/nginx/sites-available/akkoma.conf + cp /opt/akkoma/installation/nginx/akkoma.nginx /etc/nginx/sites-available/akkoma.conf ln -s /etc/nginx/sites-available/akkoma.conf /etc/nginx/sites-enabled/akkoma.conf ``` If your distro does not have either of those you can append `include /etc/nginx/akkoma.conf` to the end of the http section in /etc/nginx/nginx.conf and ```sh -cp /opt/akkoma/installation/akkoma.nginx /etc/nginx/akkoma.conf +cp /opt/akkoma/installation/nginx/akkoma.nginx /etc/nginx/akkoma.conf ``` #### Edit the nginx config diff --git a/installation/pleroma-mongooseim.cfg b/installation/akkoma-mongooseim.cfg similarity index 100% rename from installation/pleroma-mongooseim.cfg rename to installation/akkoma-mongooseim.cfg diff --git a/installation/pleroma.service b/installation/akkoma.service similarity index 65% rename from installation/pleroma.service rename to installation/akkoma.service index 8338228d8..caddf7c4b 100644 --- a/installation/pleroma.service +++ b/installation/akkoma.service @@ -1,5 +1,5 @@ [Unit] -Description=Pleroma social network +Description=Akkoma social network After=network.target postgresql.service [Service] @@ -7,23 +7,23 @@ ExecReload=/bin/kill $MAINPID KillMode=process Restart=on-failure -; Name of the user that runs the Pleroma service. -User=pleroma -; Declares that Pleroma runs in production mode. +; Name of the user that runs the Akkoma service. +User=akkoma +; Declares that Akkoma runs in production mode. Environment="MIX_ENV=prod" ; Make sure that all paths fit your installation. -; Path to the home directory of the user running the Pleroma service. -Environment="HOME=/var/lib/pleroma" -; Path to the folder containing the Pleroma installation. -WorkingDirectory=/opt/pleroma +; Path to the home directory of the user running the Akkoma service. +Environment="HOME=/var/lib/akkoma" +; Path to the folder containing the Akkoma installation. +WorkingDirectory=/opt/akkoma ; Path to the Mix binary. ExecStart=/usr/bin/mix phx.server ; Some security directives. ; Use private /tmp and /var/tmp folders inside a new file system namespace, which are discarded after the process stops. PrivateTmp=true -; The /home, /root, and /run/user folders can not be accessed by this service anymore. If your Pleroma user has its home folder in one of the restricted places, or use one of these folders as its working directory, you have to set this to false. +; The /home, /root, and /run/user folders can not be accessed by this service anymore. If your Akkoma user has its home folder in one of the restricted places, or use one of these folders as its working directory, you have to set this to false. ProtectHome=true ; Mount /usr, /boot, and /etc as read-only for processes invoked by this service. ProtectSystem=full diff --git a/installation/akkoma.supervisord b/installation/akkoma.supervisord new file mode 100644 index 000000000..8fd5e8d42 --- /dev/null +++ b/installation/akkoma.supervisord @@ -0,0 +1,21 @@ +; Assumes akkoma is installed in /home/akkoma/akkoma and running as the akkoma user +; Also assumes mix is in /usr/bin, this might differ on BSDs or niche Linux distros +; Logs into /home/akkoma/logs +[program:akkoma] +command=/usr/bin/mix phx.server +directory=/home/akkoma/akkoma +autostart=true +autorestart=true +user=akkoma +environment = + MIX_ENV=prod, + HOME=/home/akkoma, + USER=akkoma, + PATH="/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/home/akkoma/bin:%(ENV_PATH)s", + PWD=/home/akkoma/akkoma +stdout_logfile=/home/akkoma/logs/stdout.log +stdout_logfile_maxbytes=50MB +stdout_logfile_backups=10 +stderr_logfile=/home/akkoma/logs/stderr.log +stderr_logfile_maxbytes=50MB +stderr_logfile_backups=10 \ No newline at end of file diff --git a/installation/pleroma.vcl b/installation/akkoma.vcl similarity index 100% rename from installation/pleroma.vcl rename to installation/akkoma.vcl diff --git a/installation/pleroma-apache.conf b/installation/apache/akkoma-apache.conf similarity index 87% rename from installation/pleroma-apache.conf rename to installation/apache/akkoma-apache.conf index 139abe9e1..c9f123532 100644 --- a/installation/pleroma-apache.conf +++ b/installation/apache/akkoma-apache.conf @@ -1,14 +1,14 @@ -# Sample Apache config for Pleroma +# Sample Apache config for Akkoma # # Simple installation instructions: # 1. Install your TLS certificate. We recommend using Let's Encrypt via Certbot # 2. Replace 'example.tld' with your instance's domain. # 3. This assumes a Debian-style Apache config. Copy this file to # /etc/apache2/sites-available/ and then activate the site by running -# 'a2ensite pleroma-apache.conf', then restart Apache. +# 'a2ensite akkoma-apache.conf', then restart Apache. # # Optional: enable disk-based caching for the media proxy -# For details, see https://git.pleroma.social/pleroma/pleroma/wikis/How%20to%20activate%20mediaproxy +# For details, see https://docs.akkoma.dev/main/backend/configuration/howto_mediaproxy/ # # 1. Create a directory as shown below for the CacheRoot and make sure # the Apache user can write to it. @@ -42,9 +42,9 @@ Define servername example.tld ServerName ${servername} ServerTokens Prod -# If you want Pleroma-specific logs -#ErrorLog /var/log/httpd-pleroma-error.log -#CustomLog /var/log/httpd-pleroma-access.log combined +# If you want Akkoma-specific logs +#ErrorLog /var/log/httpd-akkoma-error.log +#CustomLog /var/log/httpd-akkoma-access.log combined RewriteEngine on @@ -60,7 +60,7 @@ ServerTokens Prod Include /etc/letsencrypt/options-ssl-apache.conf # Uncomment the following to enable MediaProxy caching on disk - #CacheRoot /tmp/pleroma-media-cache/ + #CacheRoot /tmp/akkoma-media-cache/ #CacheDirLevels 1 #CacheDirLength 2 #CacheEnable disk /proxy diff --git a/installation/apache-cache-purge.sh.example b/installation/apache/apache-cache-purge.sh.example similarity index 89% rename from installation/apache-cache-purge.sh.example rename to installation/apache/apache-cache-purge.sh.example index 7b4262875..65df9cc11 100755 --- a/installation/apache-cache-purge.sh.example +++ b/installation/apache/apache-cache-purge.sh.example @@ -4,7 +4,7 @@ # You will likely need to setup a sudo rule like the following: # # Cmnd_Alias HTCACHECLEAN = /usr/local/sbin/htcacheclean -# pleroma ALL=HTCACHECLEAN, NOPASSWD: HTCACHECLEAN +# akkoma ALL=HTCACHECLEAN, NOPASSWD: HTCACHECLEAN # # Please also ensure you have enabled: # @@ -16,7 +16,7 @@ SCRIPTNAME=${0##*/} # mod_disk_cache directory -CACHE_DIRECTORY="/tmp/pleroma-media-cache" +CACHE_DIRECTORY="/tmp/akkoma-media-cache" ## Removes an item via the htcacheclean utility ## $1 - the filename, can be a pattern . diff --git a/installation/caddy/Caddyfile b/installation/caddy/Caddyfile new file mode 100644 index 000000000..5cc75a1fc --- /dev/null +++ b/installation/caddy/Caddyfile @@ -0,0 +1,17 @@ +# default Caddyfile config for Akkoma +# +# Simple installation instructions: +# 1. Replace 'example.tld' with your instance's domain wherever it appears. +# 2. Copy this section into your Caddyfile and restart Caddy. + +example.tld { + log { + output file /var/log/caddy/akkoma.log + } + + encode gzip + + # this is explicitly IPv4 since Pleroma.Web.Endpoint binds on IPv4 only + # and `localhost.` resolves to [::0] on some systems: see issue #930 + reverse_proxy 127.0.0.1:4000 +} diff --git a/installation/caddyfile-pleroma.example b/installation/caddyfile-pleroma.example deleted file mode 100644 index 7985d9c67..000000000 --- a/installation/caddyfile-pleroma.example +++ /dev/null @@ -1,38 +0,0 @@ -# default Caddyfile config for Pleroma -# -# Simple installation instructions: -# 1. Replace 'example.tld' with your instance's domain wherever it appears. -# 2. Copy this section into your Caddyfile and restart Caddy. - -example.tld { - log /var/log/caddy/pleroma_access.log - errors /var/log/caddy/pleroma_error.log - - gzip - - # this is explicitly IPv4 since Pleroma.Web.Endpoint binds on IPv4 only - # and `localhost.` resolves to [::0] on some systems: see issue #930 - proxy / 127.0.0.1:4000 { - websocket - transparent - } - - tls { - # Remove the rest of the lines in here, if you want to support older devices - key_type p256 - ciphers ECDHE-ECDSA-WITH-CHACHA20-POLY1305 ECDHE-RSA-WITH-CHACHA20-POLY1305 ECDHE-ECDSA-AES256-GCM-SHA384 ECDHE-RSA-AES256-GCM-SHA384 ECDHE-ECDSA-AES128-GCM-SHA256 ECDHE-RSA-AES128-GCM-SHA256 - } - - # If you do not want to use the mediaproxy function, remove these lines. - # To use this directive, you need the http.cache plugin for Caddy. - cache { - match_path /media - default_max_age 720m - } - - cache { - match_path /proxy - default_max_age 720m - } - # Stop removing lines here. -} diff --git a/installation/freebsd/rc.d/akkoma b/installation/freebsd/rc.d/akkoma new file mode 100755 index 000000000..38186522b --- /dev/null +++ b/installation/freebsd/rc.d/akkoma @@ -0,0 +1,27 @@ +#!/bin/sh +# $FreeBSD$ +# PROVIDE: akkoma +# REQUIRE: DAEMON postgresql +# KEYWORD: shutdown + +# sudo -u akkoma MIX_ENV=prod elixir --erl \"-detached\" -S mix phx.server + +. /etc/rc.subr + +name=akkoma +rcvar=akkoma_enable + +desc="Akkoma Social Media Platform" + +load_rc_config ${name} + +: ${akkoma_user:=akkoma} +: ${akkoma_home:=$(getent passwd ${akkoma_user} | awk -F: '{print $6}')} +: ${akkoma_chdir:="${akkoma_home}/akkoma"} +: ${akkoma_env:="HOME=${akkoma_home} MIX_ENV=prod"} + +command=/usr/local/bin/elixir +command_args="--erl \"-detached\" -S /usr/local/bin/mix phx.server" +procname="*beam.smp" + +run_rc_command "$1" diff --git a/installation/freebsd/rc.d/pleroma b/installation/freebsd/rc.d/pleroma deleted file mode 100755 index f62aef18d..000000000 --- a/installation/freebsd/rc.d/pleroma +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/sh -# $FreeBSD$ -# PROVIDE: pleroma -# REQUIRE: DAEMON postgresql -# KEYWORD: shutdown - -# sudo -u pleroma MIX_ENV=prod elixir --erl \"-detached\" -S mix phx.server - -. /etc/rc.subr - -name=pleroma -rcvar=pleroma_enable - -desc="Pleroma Social Media Platform" - -load_rc_config ${name} - -: ${pleroma_user:=pleroma} -: ${pleroma_home:=$(getent passwd ${pleroma_user} | awk -F: '{print $6}')} -: ${pleroma_chdir:="${pleroma_home}/pleroma"} -: ${pleroma_env:="HOME=${pleroma_home} MIX_ENV=prod"} - -command=/usr/local/bin/elixir -command_args="--erl \"-detached\" -S /usr/local/bin/mix phx.server" -procname="*beam.smp" - -run_rc_command "$1" diff --git a/installation/init.d/akkoma b/installation/init.d/akkoma new file mode 100755 index 000000000..bf70c34fb --- /dev/null +++ b/installation/init.d/akkoma @@ -0,0 +1,45 @@ +#!/sbin/openrc-run +supervisor=supervise-daemon +command_user=akkoma:akkoma +command_background=1 +# Ask process to terminate within 30 seconds, otherwise kill it +retry="SIGTERM/30/SIGKILL/5" +pidfile="/var/run/akkoma.pid" +directory=/opt/akkoma +healthcheck_delay=60 +healthcheck_timer=30 + +: ${akkoma_port:-4000} + +# Needs OpenRC >= 0.42 +#respawn_max=0 +#respawn_delay=5 + +# put akkoma_console=YES in /etc/conf.d/akkoma if you want to be able to +# connect to akkoma via an elixir console +if yesno "${akkoma_console}"; then + command=elixir + command_args="--name akkoma@127.0.0.1 --erl '-kernel inet_dist_listen_min 9001 inet_dist_listen_max 9001 inet_dist_use_interface {127,0,0,1}' -S mix phx.server" + + start_post() { + einfo "You can get a console by using this command as akkoma's user:" + einfo "iex --name console@127.0.0.1 --remsh akkoma@127.0.0.1" + } +else + command=/usr/bin/mix + command_args="phx.server" +fi + +export MIX_ENV=prod + +depend() { + need nginx postgresql +} + +healthcheck() { + # put akkoma_health=YES in /etc/conf.d/akkoma if you want healthchecking + # and make sure you have curl installed + yesno "$akkoma_health" || return 0 + + curl -q "localhost:${akkoma_port}/api/akkoma/healthcheck" +} diff --git a/installation/init.d/pleroma b/installation/init.d/pleroma deleted file mode 100755 index 384536f7e..000000000 --- a/installation/init.d/pleroma +++ /dev/null @@ -1,45 +0,0 @@ -#!/sbin/openrc-run -supervisor=supervise-daemon -command_user=pleroma:pleroma -command_background=1 -# Ask process to terminate within 30 seconds, otherwise kill it -retry="SIGTERM/30/SIGKILL/5" -pidfile="/var/run/pleroma.pid" -directory=/opt/pleroma -healthcheck_delay=60 -healthcheck_timer=30 - -: ${pleroma_port:-4000} - -# Needs OpenRC >= 0.42 -#respawn_max=0 -#respawn_delay=5 - -# put pleroma_console=YES in /etc/conf.d/pleroma if you want to be able to -# connect to pleroma via an elixir console -if yesno "${pleroma_console}"; then - command=elixir - command_args="--name pleroma@127.0.0.1 --erl '-kernel inet_dist_listen_min 9001 inet_dist_listen_max 9001 inet_dist_use_interface {127,0,0,1}' -S mix phx.server" - - start_post() { - einfo "You can get a console by using this command as pleroma's user:" - einfo "iex --name console@127.0.0.1 --remsh pleroma@127.0.0.1" - } -else - command=/usr/bin/mix - command_args="phx.server" -fi - -export MIX_ENV=prod - -depend() { - need nginx postgresql -} - -healthcheck() { - # put pleroma_health=YES in /etc/conf.d/pleroma if you want healthchecking - # and make sure you have curl installed - yesno "$pleroma_health" || return 0 - - curl -q "localhost:${pleroma_port}/api/pleroma/healthcheck" -} diff --git a/installation/netbsd/rc.d/pleroma b/installation/netbsd/rc.d/akkoma similarity index 82% rename from installation/netbsd/rc.d/pleroma rename to installation/netbsd/rc.d/akkoma index 1114668ee..7b80bc414 100755 --- a/installation/netbsd/rc.d/pleroma +++ b/installation/netbsd/rc.d/akkoma @@ -1,24 +1,24 @@ #!/bin/sh -# PROVIDE: pleroma +# PROVIDE: akkoma # REQUIRE: DAEMON pgsql if [ -f /etc/rc.subr ]; then . /etc/rc.subr fi -name="pleroma" +name="akkoma" rcvar=${name} command="/usr/pkg/bin/elixir" command_args="--detached -S /usr/pkg/bin/mix phx.server" start_precmd="ulimit -n unlimited" pidfile="/dev/null" -pleroma_chdir="${pleroma_home}/pleroma" -pleroma_env="HOME=${pleroma_home} MIX_ENV=prod" +akkoma_chdir="${akkoma_home}/akkoma" +akkoma_env="HOME=${akkoma_home} MIX_ENV=prod" check_pidfile() { - pid=$(pgrep -U "${pleroma_user}" /bin/beam.smp$) + pid=$(pgrep -U "${akkoma_user}" /bin/beam.smp$) echo -n "${pid}" } diff --git a/installation/pleroma.nginx b/installation/nginx/akkoma.nginx similarity index 94% rename from installation/pleroma.nginx rename to installation/nginx/akkoma.nginx index 9890cb2b1..772716677 100644 --- a/installation/pleroma.nginx +++ b/installation/nginx/akkoma.nginx @@ -1,4 +1,4 @@ -# default nginx site config for Pleroma +# default nginx site config for Akkoma # # Simple installation instructions: # 1. Install your TLS certificate, possibly using Let's Encrypt. @@ -6,7 +6,7 @@ # 3. Copy this file to /etc/nginx/sites-available/ and then add a symlink to it # in /etc/nginx/sites-enabled/ and run 'nginx -s reload' or restart nginx. -proxy_cache_path /tmp/pleroma-media-cache levels=1:2 keys_zone=pleroma_media_cache:10m max_size=10g +proxy_cache_path /tmp/akkoma-media-cache levels=1:2 keys_zone=akkoma_media_cache:10m max_size=10g inactive=720m use_temp_path=off; # this is explicitly IPv4 since Pleroma.Web.Endpoint binds on IPv4 only @@ -82,7 +82,7 @@ server { } location ~ ^/(media|proxy) { - proxy_cache pleroma_media_cache; + proxy_cache akkoma_media_cache; slice 1m; proxy_cache_key $host$uri$is_args$args$slice_range; proxy_set_header Range $slice_range; diff --git a/installation/nginx-cache-purge.sh.example b/installation/nginx/nginx-cache-purge.sh.example similarity index 95% rename from installation/nginx-cache-purge.sh.example rename to installation/nginx/nginx-cache-purge.sh.example index 5f6cbb128..6cd01d1e7 100755 --- a/installation/nginx-cache-purge.sh.example +++ b/installation/nginx/nginx-cache-purge.sh.example @@ -5,7 +5,7 @@ SCRIPTNAME=${0##*/} # NGINX cache directory -CACHE_DIRECTORY="/tmp/pleroma-media-cache" +CACHE_DIRECTORY="/tmp/akkoma-media-cache" ## Return the files where the items are cached. ## $1 - the filename, can be a pattern . diff --git a/installation/openbsd/httpd.conf b/installation/openbsd/httpd.conf index 82f4803fd..ae33d29b7 100644 --- a/installation/openbsd/httpd.conf +++ b/installation/openbsd/httpd.conf @@ -1,5 +1,5 @@ # -# Default httpd.conf file for Pleroma on OpenBSD +# Default httpd.conf file for Akkoma on OpenBSD # Simple installation instructions # 1. Place file in /etc # 2. Replace with your public IP address diff --git a/installation/openbsd/rc.d/akkomad b/installation/openbsd/rc.d/akkomad new file mode 100755 index 000000000..68be46c9a --- /dev/null +++ b/installation/openbsd/rc.d/akkomad @@ -0,0 +1,34 @@ +#!/bin/ksh +# +# Default init file for Akkoma on OpenBSD +# +# Simple installation instructions: +# 1. Install Akkoma per wiki instructions +# 2. Place this akkomad file in /etc/rc.d +# 3. Enable and start Akkoma +# # doas rcctl enable akkomad +# # doas rcctl start akkomad +# + +daemon="/usr/local/bin/elixir" +daemon_flags="--detached -S /usr/local/bin/mix phx.server" +daemon_user="_akkoma" + +. /etc/rc.d/rc.subr + +rc_reload=NO +pexp="phx.server" + +rc_check() { + pgrep -q -U _akkoma -f "phx.server" +} + +rc_start() { + ${rcexec} "cd akkoma; ${daemon} ${daemon_flags}" +} + +rc_stop() { + pkill -q -U _akkoma -f "phx.server" +} + +rc_cmd $1 diff --git a/installation/openbsd/rc.d/pleromad b/installation/openbsd/rc.d/pleromad deleted file mode 100755 index 19ac4bb51..000000000 --- a/installation/openbsd/rc.d/pleromad +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/ksh -# -# Default init file for Pleroma on OpenBSD -# -# Simple installation instructions: -# 1. Install Pleroma per wiki instructions -# 2. Place this pleromad file in /etc/rc.d -# 3. Enable and start Pleroma -# # doas rcctl enable pleromad -# # doas rcctl start pleromad -# - -daemon="/usr/local/bin/elixir" -daemon_flags="--detached -S /usr/local/bin/mix phx.server" -daemon_user="_pleroma" - -. /etc/rc.d/rc.subr - -rc_reload=NO -pexp="phx.server" - -rc_check() { - pgrep -q -U _pleroma -f "phx.server" -} - -rc_start() { - ${rcexec} "cd pleroma; ${daemon} ${daemon_flags}" -} - -rc_stop() { - pkill -q -U _pleroma -f "phx.server" -} - -rc_cmd $1 diff --git a/installation/openbsd/relayd.conf b/installation/openbsd/relayd.conf index 31c2c1129..b035ec69b 100644 --- a/installation/openbsd/relayd.conf +++ b/installation/openbsd/relayd.conf @@ -1,5 +1,5 @@ # -# Default relayd.conf file for Pleroma on OpenBSD +# Default relayd.conf file for Akkoma on OpenBSD # Simple installation instructions: # 1. Place in /etc # 2. Replace with your public IPv4 address @@ -13,19 +13,19 @@ ext_inet="" #ext_inet6="" -table { 127.0.0.1 } +table { 127.0.0.1 } table { 127.0.0.1 } -http protocol plerup { # Protocol for upstream pleroma server +http protocol plerup { # Protocol for upstream akkoma server #tcp { nodelay, sack, socket buffer 65536, backlog 128 } # Uncomment and adjust as you see fit tls ciphers "ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA0-POLY1305" tls ecdhe secp384r1 - # Forward some paths to the local server (as pleroma won't respond to them as you might want) + # Forward some paths to the local server (as akkoma won't respond to them as you might want) pass request quick path "/robots.txt" forward to # Append a bunch of headers - match request header append "X-Forwarded-For" value "$REMOTE_ADDR" # This two header and the next one are not strictl required by pleroma but adding them won't hurt + match request header append "X-Forwarded-For" value "$REMOTE_ADDR" # This two header and the next one are not strictly required by akkoma but adding them won't hurt match request header append "X-Forwarded-By" value "$SERVER_ADDR:$SERVER_PORT" match request header append "Connection" value "upgrade" @@ -38,7 +38,7 @@ relay wwwtls { protocol plerup - forward to port 4000 check http "/" code 200 + forward to port 4000 check http "/" code 200 forward to port 80 check http "/robots.txt" code 200 } diff --git a/installation/pleroma.supervisord b/installation/pleroma.supervisord deleted file mode 100644 index 19efffd6e..000000000 --- a/installation/pleroma.supervisord +++ /dev/null @@ -1,21 +0,0 @@ -; Assumes pleroma is installed in /home/pleroma/pleroma and running as the pleroma user -; Also assumes mix is in /usr/bin, this might differ on BSDs or niche Linux distros -; Logs into /home/pleroma/logs -[program:pleroma] -command=/usr/bin/mix phx.server -directory=/home/pleroma/pleroma -autostart=true -autorestart=true -user=pleroma -environment = - MIX_ENV=prod, - HOME=/home/pleroma, - USER=pleroma, - PATH="/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/home/pleroma/bin:%(ENV_PATH)s", - PWD=/home/pleroma/pleroma -stdout_logfile=/home/pleroma/logs/stdout.log -stdout_logfile_maxbytes=50MB -stdout_logfile_backups=10 -stderr_logfile=/home/pleroma/logs/stderr.log -stderr_logfile_maxbytes=50MB -stderr_logfile_backups=10 \ No newline at end of file From a9c82b62f2b73a79613bb23c3153ccf015733c52 Mon Sep 17 00:00:00 2001 From: floatingghost Date: Wed, 6 Jul 2022 18:57:00 +0000 Subject: [PATCH 4/6] Fixes for elasticsearch 8 (#52) Reviewed-on: https://akkoma.dev/AkkomaGang/akkoma/pulls/52 --- CHANGELOG.md | 3 +++ docs/configuration/search.md | 2 ++ lib/mix/tasks/pleroma/search.ex | 11 +++++++---- mix.exs | 4 ++-- mix.lock | 4 ++-- 5 files changed, 16 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 22d8b0db1..55ae540b6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - SSH frontend, to be potentially re-enabled via a bridge rather than wired into the main system - Gopher frontend, as above +### Fixed +- ES8 support for bulk indexing activities + ## 2.5.2 ### Added diff --git a/docs/configuration/search.md b/docs/configuration/search.md index e1f23b505..3c5611309 100644 --- a/docs/configuration/search.md +++ b/docs/configuration/search.md @@ -124,6 +124,8 @@ depends on the amount of text in posts. ## Elasticsearch +**Note: This requires at least ElasticSearch 7** + As with meilisearch, this can be rather memory-hungry, but it is very good at what it does. To use [elasticsearch](https://www.elastic.co/), set the search module to `Pleroma.Search.Elasticsearch`: diff --git a/lib/mix/tasks/pleroma/search.ex b/lib/mix/tasks/pleroma/search.ex index 102bc5b63..67aba79db 100644 --- a/lib/mix/tasks/pleroma/search.ex +++ b/lib/mix/tasks/pleroma/search.ex @@ -10,11 +10,14 @@ defmodule Mix.Tasks.Pleroma.Search do def run(["import", "activities" | _rest]) do start_pleroma() + IO.inspect(Pleroma.Config.get([Pleroma.Search.Elasticsearch.Cluster, :indexes, :activities])) - Elasticsearch.Index.Bulk.upload( - Pleroma.Search.Elasticsearch.Cluster, - "activities", - Pleroma.Config.get([Pleroma.Search.Elasticsearch.Cluster, :indexes, :activities]) + IO.inspect( + Elasticsearch.Index.Bulk.upload( + Pleroma.Search.Elasticsearch.Cluster, + "activities", + Pleroma.Config.get([Pleroma.Search.Elasticsearch.Cluster, :indexes, :activities]) + ) ) end end diff --git a/mix.exs b/mix.exs index 4259f20b3..cecf83dfd 100644 --- a/mix.exs +++ b/mix.exs @@ -196,14 +196,14 @@ defmodule Pleroma.Mixfile do {:majic, "~> 1.0"}, {:eblurhash, "~> 1.2.2"}, {:open_api_spex, "~> 3.10"}, - {:elastix, ">= 0.0.0"}, {:search_parser, git: "https://github.com/FloatingGhost/pleroma-contrib-search-parser.git", ref: "08971a81e68686f9ac465cfb6661d51c5e4e1e7f"}, {:nimble_parsec, "~> 1.0", override: true}, {:phoenix_live_dashboard, "~> 0.6.2"}, {:ecto_psql_extras, "~> 0.6"}, - {:elasticsearch, "~> 1.0.0"}, + {:elasticsearch, + git: "https://akkoma.dev/AkkomaGang/elasticsearch-elixir.git", ref: "main"}, # indirect dependency version override {:plug, "~> 1.10.4", override: true}, diff --git a/mix.lock b/mix.lock index 6c2a88ef4..efd508194 100644 --- a/mix.lock +++ b/mix.lock @@ -35,7 +35,7 @@ "ecto_psql_extras": {:hex, :ecto_psql_extras, "0.7.4", "5d43fd088d39a158c860b17e8d210669587f63ec89ea122a4654861c8c6e2db4", [:mix], [{:ecto_sql, "~> 3.4", [hex: :ecto_sql, repo: "hexpm", optional: false]}, {:postgrex, ">= 0.15.7", [hex: :postgrex, repo: "hexpm", optional: false]}, {:table_rex, "~> 3.1.1", [hex: :table_rex, repo: "hexpm", optional: false]}], "hexpm", "311db02f1b772e3d0dc7f56a05044b5e1499d78ed6abf38885e1ca70059449e5"}, "ecto_sql": {:hex, :ecto_sql, "3.6.2", "9526b5f691701a5181427634c30655ac33d11e17e4069eff3ae1176c764e0ba3", [:mix], [{:db_connection, "~> 2.2", [hex: :db_connection, repo: "hexpm", optional: false]}, {:ecto, "~> 3.6.2", [hex: :ecto, repo: "hexpm", optional: false]}, {:myxql, "~> 0.4.0 or ~> 0.5.0", [hex: :myxql, repo: "hexpm", optional: true]}, {:postgrex, "~> 0.15.0 or ~> 1.0", [hex: :postgrex, repo: "hexpm", optional: true]}, {:tds, "~> 2.1.1", [hex: :tds, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "5ec9d7e6f742ea39b63aceaea9ac1d1773d574ea40df5a53ef8afbd9242fdb6b"}, "eimp": {:hex, :eimp, "1.0.14", "fc297f0c7e2700457a95a60c7010a5f1dcb768a083b6d53f49cd94ab95a28f22", [:rebar3], [{:p1_utils, "1.0.18", [hex: :p1_utils, repo: "hexpm", optional: false]}], "hexpm", "501133f3112079b92d9e22da8b88bf4f0e13d4d67ae9c15c42c30bd25ceb83b6"}, - "elasticsearch": {:hex, :elasticsearch, "1.0.1", "8339538d90af6b280f10ecd02b1eae372f09373e629b336a13461babf7366495", [:mix], [{:httpoison, ">= 0.0.0", [hex: :httpoison, repo: "hexpm", optional: false]}, {:poison, ">= 0.0.0", [hex: :poison, repo: "hexpm", optional: true]}, {:sigaws, "~> 0.7", [hex: :sigaws, repo: "hexpm", optional: true]}, {:vex, "~> 0.6", [hex: :vex, repo: "hexpm", optional: false]}], "hexpm", "83e7d8b8bee3e7e19a06ab4d357d24845ac1da894e79678227fd52c0b7f71867"}, + "elasticsearch": {:git, "https://akkoma.dev/AkkomaGang/elasticsearch-elixir.git", "6cd946f75f6ab9042521a009d1d32d29a90113ca", [ref: "main"]}, "elastix": {:hex, :elastix, "0.10.0", "7567da885677ba9deffc20063db5f3ca8cd10f23cff1ab3ed9c52b7063b7e340", [:mix], [{:httpoison, "~> 1.4", [hex: :httpoison, repo: "hexpm", optional: false]}, {:poison, "~> 3.0 or ~> 4.0", [hex: :poison, repo: "hexpm", optional: true]}, {:retry, "~> 0.8", [hex: :retry, repo: "hexpm", optional: false]}], "hexpm", "5fb342ce068b20f7845f5dd198c2dc80d967deafaa940a6e51b846db82696d1d"}, "elixir_make": {:hex, :elixir_make, "0.6.2", "7dffacd77dec4c37b39af867cedaabb0b59f6a871f89722c25b28fcd4bd70530", [:mix], [], "hexpm", "03e49eadda22526a7e5279d53321d1cced6552f344ba4e03e619063de75348d9"}, "esshd": {:hex, :esshd, "0.1.1", "d4dd4c46698093a40a56afecce8a46e246eb35463c457c246dacba2e056f31b5", [:mix], [], "hexpm", "d73e341e3009d390aa36387dc8862860bf9f874c94d9fd92ade2926376f49981"}, @@ -64,7 +64,7 @@ "html_entities": {:hex, :html_entities, "0.5.2", "9e47e70598da7de2a9ff6af8758399251db6dbb7eebe2b013f2bbd2515895c3c", [:mix], [], "hexpm", "c53ba390403485615623b9531e97696f076ed415e8d8058b1dbaa28181f4fdcc"}, "html_sanitize_ex": {:hex, :html_sanitize_ex, "1.3.0", "f005ad692b717691203f940c686208aa3d8ffd9dd4bb3699240096a51fa9564e", [:mix], [{:mochiweb, "~> 2.15", [hex: :mochiweb, repo: "hexpm", optional: false]}], "hexpm"}, "http_signatures": {:hex, :http_signatures, "0.1.1", "ca7ebc1b61542b163644c8c3b1f0e0f41037d35f2395940d3c6c7deceab41fd8", [:mix], [], "hexpm", "cc3b8a007322cc7b624c0c15eec49ee58ac977254ff529a3c482f681465942a3"}, - "httpoison": {:hex, :httpoison, "1.8.0", "6b85dea15820b7804ef607ff78406ab449dd78bed923a49c7160e1886e987a3d", [:mix], [{:hackney, "~> 1.17", [hex: :hackney, repo: "hexpm", optional: false]}], "hexpm", "28089eaa98cf90c66265b6b5ad87c59a3729bea2e74e9d08f9b51eb9729b3c3a"}, + "httpoison": {:hex, :httpoison, "1.8.1", "df030d96de89dad2e9983f92b0c506a642d4b1f4a819c96ff77d12796189c63e", [:mix], [{:hackney, "~> 1.17", [hex: :hackney, repo: "hexpm", optional: false]}], "hexpm", "35156a6d678d6d516b9229e208942c405cf21232edd632327ecfaf4fd03e79e0"}, "idna": {:hex, :idna, "6.1.1", "8a63070e9f7d0c62eb9d9fcb360a7de382448200fbbd1b106cc96d3d8099df8d", [:rebar3], [{:unicode_util_compat, "~>0.7.0", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm", "92376eb7894412ed19ac475e4a86f7b413c1b9fbb5bd16dccd57934157944cea"}, "inet_cidr": {:hex, :inet_cidr, "1.0.4", "a05744ab7c221ca8e395c926c3919a821eb512e8f36547c062f62c4ca0cf3d6e", [:mix], [], "hexpm", "64a2d30189704ae41ca7dbdd587f5291db5d1dda1414e0774c29ffc81088c1bc"}, "jason": {:hex, :jason, "1.3.0", "fa6b82a934feb176263ad2df0dbd91bf633d4a46ebfdffea0c8ae82953714946", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "53fc1f51255390e0ec7e50f9cb41e751c260d065dcba2bf0d08dc51a4002c2ac"}, From bc6bfe383f642e74bbf09828181d9c89b1b17f05 Mon Sep 17 00:00:00 2001 From: floatingghost Date: Wed, 6 Jul 2022 20:00:43 +0000 Subject: [PATCH 5/6] Add configurable theme color (#53) Reviewed-on: https://akkoma.dev/AkkomaGang/akkoma/pulls/53 --- CHANGELOG.md | 1 + config/config.exs | 2 + config/description.exs | 15 ++++ docs/configuration/cheatsheet.md | 12 +++ lib/pleroma/application.ex | 1 - lib/pleroma/telemetry/logger.ex | 85 ------------------- lib/pleroma/web/endpoint.ex | 2 - .../web/fallback/redirect_controller.ex | 3 +- lib/pleroma/web/metadata.ex | 20 ++++- lib/pleroma/web/metadata/providers/theme.ex | 16 ++++ .../web/metadata/providers/theme_test.exs | 12 +++ 11 files changed, 79 insertions(+), 90 deletions(-) delete mode 100644 lib/pleroma/telemetry/logger.ex create mode 100644 lib/pleroma/web/metadata/providers/theme.ex create mode 100644 test/pleroma/web/metadata/providers/theme_test.exs diff --git a/CHANGELOG.md b/CHANGELOG.md index 55ae540b6..2a12a0c57 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### Added - Added move account API +- Added ability to set instance accent-color via theme-color ### Removed - SSH frontend, to be potentially re-enabled via a bridge rather than wired into the main system diff --git a/config/config.exs b/config/config.exs index 06c946b2a..908b79d09 100644 --- a/config/config.exs +++ b/config/config.exs @@ -477,6 +477,8 @@ config :pleroma, Pleroma.Web.Metadata, ], unfurl_nsfw: false +config :pleroma, Pleroma.Web.Metadata.Providers.Theme, theme_color: "#593196" + config :pleroma, Pleroma.Web.Preload, providers: [ Pleroma.Web.Preload.Providers.Instance diff --git a/config/description.exs b/config/description.exs index d8eaa34a2..c36e9d2b2 100644 --- a/config/description.exs +++ b/config/description.exs @@ -1979,6 +1979,21 @@ config :pleroma, :config_description, [ } ] }, + %{ + group: :pleroma, + key: Pleroma.Web.Metadata.Providers.Theme, + type: :group, + description: "Specific provider to hand out themes to instances that scrape index.html", + children: [ + %{ + key: :theme_color, + type: :string, + description: + "The 'accent color' of the instance, used in places like misskey's instance ticker", + suggestions: ["#593196"] + } + ] + }, %{ group: :pleroma, key: :rich_media, diff --git a/docs/configuration/cheatsheet.md b/docs/configuration/cheatsheet.md index 11083e831..cef86e806 100644 --- a/docs/configuration/cheatsheet.md +++ b/docs/configuration/cheatsheet.md @@ -1114,6 +1114,18 @@ config :pleroma, :frontends, This would serve the frontend from the the folder at `$instance_static/frontends/pleroma/stable`. You have to copy the frontend into this folder yourself. You can choose the name and ref any way you like, but they will be used by mix tasks to automate installation in the future, the name referring to the project and the ref referring to a commit. +### Theme settings + +Settings to change theme as exposed to the outside world, for software +that scans `index.html` (mainly misskey) + +``` +config :pleroma, Pleroma.Web.Metadata.Providers.Theme, theme_color: "#593196" +``` + +This sets the `theme-color` meta tag on `index.html`, and is basically +a hack to make misskey find the right thing. + ## Ephemeral activities (Pleroma.Workers.PurgeExpiredActivity) Settings to enable and configure expiration for ephemeral activities diff --git a/lib/pleroma/application.ex b/lib/pleroma/application.ex index b55d980e9..0f4f5a358 100644 --- a/lib/pleroma/application.ex +++ b/lib/pleroma/application.ex @@ -47,7 +47,6 @@ defmodule Pleroma.Application do # Disable warnings_as_errors at runtime, it breaks Phoenix live reload # due to protocol consolidation warnings Code.compiler_options(warnings_as_errors: false) - Pleroma.Telemetry.Logger.attach() Config.Holder.save_default() Pleroma.HTML.compile_scrubbers() Pleroma.Config.Oban.warn() diff --git a/lib/pleroma/telemetry/logger.ex b/lib/pleroma/telemetry/logger.ex deleted file mode 100644 index 4c781c504..000000000 --- a/lib/pleroma/telemetry/logger.ex +++ /dev/null @@ -1,85 +0,0 @@ -# Pleroma: A lightweight social networking server -# Copyright © 2017-2021 Pleroma Authors -# SPDX-License-Identifier: AGPL-3.0-only - -defmodule Pleroma.Telemetry.Logger do - @moduledoc "Transforms Pleroma telemetry events to logs" - - require Logger - - @events [ - [:pleroma, :repo, :query] - ] - def attach do - :telemetry.attach_many( - "pleroma-logger", - @events, - &Pleroma.Telemetry.Logger.handle_event/4, - [] - ) - end - - # Passing anonymous functions instead of strings to logger is intentional, - # that way strings won't be concatenated if the message is going to be thrown - # out anyway due to higher log level configured - - def handle_event( - [:pleroma, :repo, :query] = _name, - %{query_time: query_time} = measurements, - %{source: source} = metadata, - config - ) do - logging_config = Pleroma.Config.get([:telemetry, :slow_queries_logging], []) - - if logging_config[:enabled] && - logging_config[:min_duration] && - query_time > logging_config[:min_duration] and - (is_nil(logging_config[:exclude_sources]) or - source not in logging_config[:exclude_sources]) do - log_slow_query(measurements, metadata, config) - else - :ok - end - end - - defp log_slow_query( - %{query_time: query_time} = _measurements, - %{source: _source, query: query, params: query_params, repo: repo} = _metadata, - _config - ) do - sql_explain = - with {:ok, %{rows: explain_result_rows}} <- - repo.query("EXPLAIN " <> query, query_params, log: false) do - Enum.map_join(explain_result_rows, "\n", & &1) - end - - {:current_stacktrace, stacktrace} = Process.info(self(), :current_stacktrace) - - pleroma_stacktrace = - Enum.filter(stacktrace, fn - {__MODULE__, _, _, _} -> - false - - {mod, _, _, _} -> - mod - |> to_string() - |> String.starts_with?("Elixir.Pleroma.") - end) - - Logger.warn(fn -> - """ - Slow query! - - Total time: #{round(query_time / 1_000)} ms - - #{query} - - #{inspect(query_params, limit: :infinity)} - - #{sql_explain} - - #{Exception.format_stacktrace(pleroma_stacktrace)} - """ - end) - end -end diff --git a/lib/pleroma/web/endpoint.ex b/lib/pleroma/web/endpoint.ex index 9d73cf0f8..9ba98d0a8 100644 --- a/lib/pleroma/web/endpoint.ex +++ b/lib/pleroma/web/endpoint.ex @@ -12,8 +12,6 @@ defmodule Pleroma.Web.Endpoint do socket("/socket", Pleroma.Web.UserSocket) socket("/live", Phoenix.LiveView.Socket) - plug(Plug.Telemetry, event_prefix: [:phoenix, :endpoint]) - plug(Pleroma.Web.Plugs.SetLocalePlug) plug(CORSPlug) plug(Pleroma.Web.Plugs.HTTPSecurityPlug) diff --git a/lib/pleroma/web/fallback/redirect_controller.ex b/lib/pleroma/web/fallback/redirect_controller.ex index 5fca290e5..49f659cf0 100644 --- a/lib/pleroma/web/fallback/redirect_controller.ex +++ b/lib/pleroma/web/fallback/redirect_controller.ex @@ -55,11 +55,12 @@ defmodule Pleroma.Web.Fallback.RedirectController do def redirector_with_preload(conn, params) do {:ok, index_content} = File.read(index_file_path()) preloads = preload_data(conn, params) + tags = Metadata.build_static_tags(params) title = "#{Pleroma.Config.get([:instance, :name])}" response = index_content - |> String.replace("", preloads <> title) + |> String.replace("", tags <> preloads <> title) conn |> put_resp_content_type("text/html") diff --git a/lib/pleroma/web/metadata.ex b/lib/pleroma/web/metadata.ex index 46ef00c08..48801b588 100644 --- a/lib/pleroma/web/metadata.ex +++ b/lib/pleroma/web/metadata.ex @@ -5,10 +5,28 @@ defmodule Pleroma.Web.Metadata do alias Phoenix.HTML + def build_static_tags(params) do + providers = [ + Pleroma.Web.Metadata.Providers.Theme + ] + + Enum.reduce(providers, "", fn parser, acc -> + rendered_html = + params + |> parser.build_tags() + |> Enum.map(&to_tag/1) + |> Enum.map(&HTML.safe_to_string/1) + |> Enum.join() + + acc <> rendered_html + end) + end + def build_tags(params) do providers = [ Pleroma.Web.Metadata.Providers.RelMe, - Pleroma.Web.Metadata.Providers.RestrictIndexing + Pleroma.Web.Metadata.Providers.RestrictIndexing, + Pleroma.Web.Metadata.Providers.Theme | activated_providers() ] diff --git a/lib/pleroma/web/metadata/providers/theme.ex b/lib/pleroma/web/metadata/providers/theme.ex new file mode 100644 index 000000000..581ff7624 --- /dev/null +++ b/lib/pleroma/web/metadata/providers/theme.ex @@ -0,0 +1,16 @@ +defmodule Pleroma.Web.Metadata.Providers.Theme do + alias Pleroma.Web.Metadata.Providers.Provider + + @behaviour Provider + + @impl Provider + def build_tags(_) do + [ + {:meta, + [ + name: "theme-color", + content: Pleroma.Config.get([__MODULE__, :theme_color]) + ], []} + ] + end +end diff --git a/test/pleroma/web/metadata/providers/theme_test.exs b/test/pleroma/web/metadata/providers/theme_test.exs new file mode 100644 index 000000000..0c2c1e431 --- /dev/null +++ b/test/pleroma/web/metadata/providers/theme_test.exs @@ -0,0 +1,12 @@ +defmodule Pleroma.Web.Metadata.Providers.ThemeTest do + use Pleroma.DataCase + alias Pleroma.Web.Metadata.Providers.Theme + + setup do: clear_config([Pleroma.Web.Metadata.Providers.Theme, :theme_color], "configured") + + test "it renders the theme-color meta tag" do + result = Theme.build_tags(%{}) + + assert {:meta, [name: "theme-color", content: "configured"], []} in result + end +end From 1e6b280280cb61aaeef7c639bdb9728b87572e7f Mon Sep 17 00:00:00 2001 From: FloatingGhost Date: Wed, 6 Jul 2022 22:47:59 +0100 Subject: [PATCH 6/6] Fix release installation --- mix.exs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/mix.exs b/mix.exs index cecf83dfd..4c5a776e0 100644 --- a/mix.exs +++ b/mix.exs @@ -59,8 +59,8 @@ defmodule Pleroma.Mixfile do def copy_nginx_config(%{path: target_path} = release) do File.cp!( - "./installation/pleroma.nginx", - Path.join([target_path, "installation", "pleroma.nginx"]) + "./installation/nginx/akkoma.nginx", + Path.join([target_path, "installation", "akkoma.nginx"]) ) release @@ -348,6 +348,9 @@ defmodule Pleroma.Mixfile do # Pleroma: A lightweight social networking server # Copyright © 2017-#{year} Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only +# Akkoma: The cooler pleroma +# Copyright © 2022-#{year} Akkoma Authors +# SPDX-License-Identifier: AGPL-3.0-only ] |> String.replace("\n", "\\n")