From 4ab3b027c897e840c893408948e754aa7cd79fd1 Mon Sep 17 00:00:00 2001 From: tituspijean Date: Sat, 29 Jul 2023 21:50:44 +0200 Subject: [PATCH] Fix Pict-RS config and include ImageMagick --- conf/lemmy.hjson | 11 ++++++++--- conf/pict-rs.service | 3 ++- conf/pict-rs.toml | 38 +++++++++++++++++++------------------- manifest.toml | 2 +- scripts/install | 9 +++++++++ scripts/upgrade | 9 +++++++++ 6 files changed, 48 insertions(+), 24 deletions(-) diff --git a/conf/lemmy.hjson b/conf/lemmy.hjson index a906075..a3cb693 100644 --- a/conf/lemmy.hjson +++ b/conf/lemmy.hjson @@ -66,6 +66,14 @@ # Can be easy, medium, or hard difficulty: "medium" } + # Settings related to activitypub federation + # Pictrs image server configuration. + pictrs: { + # Address where pictrs is available (for image hosting) + url: "http://127.0.0.1:__PORT_PICTRS__/" + # Set a custom pictrs API key. ( Required for deleting images ) + #api_key: "string" + } # Email sending configuration. All options except login/password are mandatory email: { # Hostname and port of the smtp server @@ -87,9 +95,6 @@ port: __PORT__ # Whether the site is available over TLS. Needs to be true for federation to work. tls_enabled: true - # Address where pictrs is available (for image hosting) - pictrs_url: "http://127.0.0.1:__PORT_PICTRS__/" - slur_filter: "(\bThis\b)|(\bis\b)|(\bsample\b)" # Maximum length of local community and user names actor_name_max_length: 20 # Maximum number of HTTP requests allowed to handle a single incoming activity (or a single object fetch through the search). diff --git a/conf/pict-rs.service b/conf/pict-rs.service index c3c9702..90785ba 100644 --- a/conf/pict-rs.service +++ b/conf/pict-rs.service @@ -7,7 +7,8 @@ Type=simple User=__APP__ Group=__APP__ WorkingDirectory=__INSTALL_DIR__/pict-rs/ -ExecStart=__INSTALL_DIR__/pict-rs/pict-rs run -a 127.0.0.1:__PORT_PICTRS__ filesystem -p __DATA_DIR__/pictrs-data sled -p __DATA_DIR__/sled +Environment=PATH=__PICTRS_PATH__ +ExecStart=__INSTALL_DIR__/pict-rs/pict-rs -c __INSTALL_DIR__/pict-rs/pict-rs.toml run StandardOutput=append:/var/log/__APP__/__APP__-pict-rs.log StandardError=inherit diff --git a/conf/pict-rs.toml b/conf/pict-rs.toml index ab396cd..16a20af 100644 --- a/conf/pict-rs.toml +++ b/conf/pict-rs.toml @@ -59,7 +59,7 @@ targets = 'warn,tracing_actix_web=info,actix_server=info,actix_web=info' ## Console configuration -[tracing.console] +#[tracing.console] ## Optional: console address # default: empty # @@ -87,18 +87,18 @@ targets = 'warn,tracing_actix_web=info,actix_server=info,actix_web=info' # ``` # $ tokio-console http://localhost:6669 # ``` -address = '0.0.0.0:6669' +#address = '0.0.0.0:6669' ## Optional: console buffer capacity # default: 102400 # # This is the number of _events_ to buffer, not the number of bytes. In reality, the amount of # RAM used will be significatnly larger (in bytes) than the buffer capacity (in events) -buffer_capacity = 102400 +#buffer_capacity = 102400 ## OpenTelemetry configuration -[tracing.opentelemetry] +#[tracing.opentelemetry] ## Optional: url for exporting otlp traces # default: empty # @@ -106,24 +106,24 @@ buffer_capacity = 102400 # When set, pict-rs will export OpenTelemetry traces to the provided URL. If the URL is # inaccessible, this can cause performance degredation in pict-rs, so it is best left unset unless # you have an OpenTelemetry collector -url = 'http://localhost:4317/' +#url = 'http://localhost:4317/' ## Optional: name to relate OpenTelemetry traces # default: pict-rs -service_name = 'pict-rs' +#service_name = 'pict-rs' ## Optional: trace level to export # default: info # # Follows the same format as RUST_LOG -targets = 'info' +#targets = 'info' ## Configuration for migrating from pict-rs 0.2 -[old_db] +#[old_db] ## Optional: path to old pict-rs directory # default: /mnt -path = '/mnt' +#path = '/mnt' ## Media Processing Configuration @@ -442,12 +442,12 @@ export_path = "__DATA_DIR__/exports" ## Media storage configuration -[store] +#[store] ## Optional: type of media storage to use # default: filesystem # # available options: filesystem, object_storage -type = 'filesystem' +#type = 'filesystem' ## Required: endpoint at which the object storage exists # default: empty @@ -464,43 +464,43 @@ type = 'filesystem' # When false, objects will be fetched from http{s}://{bucket_name}.{endpoint}:{port}/{object} # # Set to true when using minio -use_path_style = false +#use_path_style = false ## Required: object storage bucket name # default: empty -bucket_name = 'pict-rs' +#bucket_name = 'pict-rs' ## Required: object storage region # default: empty # # When using minio, this can be set to `minio` -region = '' +#region = '' ## Required: object storage access key # default: empty -access_key = '' +#access_key = '' ## Required: object storage secret key # default: empty -secret_key = '' +#secret_key = '' ## Optional: object storage session token # default: empty -session_token = '' +#session_token = '' ## Optional: set how long object storage signatures are valid for (in seconds) # default: 15 # # This can be useful if your object storage might take a while to process requests. It should not be # increased more than needed to prevent replay attacks. -signature_expiration = 15 +#signature_expiration = 15 ## Optional: set how long pict-rs will wait (in seconds) for a response from object storage # default: 30 # # This value is the total wait time, and not additional wait time on top of the # signature_expiration. -client_timeout = 30 +#client_timeout = 30 ## Filesystem media storage example # ## Media storage configuration diff --git a/manifest.toml b/manifest.toml index a028ffb..becd4f4 100644 --- a/manifest.toml +++ b/manifest.toml @@ -82,7 +82,7 @@ ram.runtime = "50M" inbox.protected = true [resources.apt] - packages = "postgresql espeak" + packages = "postgresql espeak libfuse2" extras.yarn.repo = "deb https://dl.yarnpkg.com/debian/ stable main" extras.yarn.key = "https://dl.yarnpkg.com/debian/pubkey.gpg" extras.yarn.packages = "yarn" diff --git a/scripts/install b/scripts/install index 681235f..90b8e56 100755 --- a/scripts/install +++ b/scripts/install @@ -89,6 +89,12 @@ chmod 750 "$install_dir" chmod -R o-rwx "$install_dir" chown -R $app:$app "$install_dir" +# (Dirty) Install ImageMagick +# Requires libfuse2 apt dependency +wget https://imagemagick.org/archive/binaries/magick -o "$install_dir/pict-rs/magick" -q +chmod 750 "$install_dir/pict-rs/magick" +chown $app:$app "$install_dir/pict-rs/magick" + #================================================= # ADD A CONFIGURATION #================================================= @@ -110,6 +116,9 @@ chown $app:$app "$install_dir/pict-rs/pict-rs.toml" #================================================= ynh_script_progression --message="Configuring a systemd service..." --weight=1 +# Prep local path for Pict-RS +pictrs_path="$install_dir/pict-rs:$PATH" + # Create a dedicated systemd config ynh_add_systemd_config --service="$app" --template="lemmy.service" ynh_add_systemd_config --service="$app-ui" --template="lemmy-ui.service" diff --git a/scripts/upgrade b/scripts/upgrade index 2150edb..6defb62 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -128,6 +128,12 @@ then mv -f "$install_dir/build-pict-rs/output/usr/local/bin/pict-rs" "$install_dir/pict-rs/pict-rs" ynh_secure_remove --file="$install_dir/build-pict-rs" + # (Dirty) Install ImageMagick + # Requires libfuse2 apt dependency + wget https://imagemagick.org/archive/binaries/magick -o "$install_dir/pict-rs/magick" -q + chmod 750 "$install_dir/pict-rs/magick" + chown $app:$app "$install_dir/pict-rs/magick" + fi chmod 750 "$install_dir" @@ -162,6 +168,9 @@ ynh_psql_execute_as_root --sql="CREATE EXTENSION IF NOT EXISTS pgcrypto;" --data #================================================= ynh_script_progression --message="Upgrading systemd configuration..." --weight=1 +# Prep local path for Pict-RS +pictrs_path="$install_dir/pict-rs:$PATH" + # Create a dedicated systemd config ynh_add_systemd_config --service="$app" --template="lemmy.service" ynh_add_systemd_config --service="$app-ui" --template="lemmy-ui.service"