From ac64ac86c31efdfbd2f932d6233df649077f4e09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=CC=81ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Thu, 16 May 2024 09:08:13 +0200 Subject: [PATCH 01/21] Upgrade discourse to v3 --- manifest.toml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/manifest.toml b/manifest.toml index d65d87c..137823d 100644 --- a/manifest.toml +++ b/manifest.toml @@ -7,7 +7,7 @@ name = "Discourse" description.en = "Discussion platform" description.fr = "Plateforme de discussion" -version = "2.8.14~ynh5" +version = "3.3.1~ynh1" maintainers = ["JimboJoe"] @@ -19,7 +19,7 @@ code = "https://github.com/discourse/discourse" cpe = "cpe:2.3:a:discourse:discourse" [integration] -yunohost = ">=11.2.20" +yunohost = ">=11.2.27" architectures = "all" multi_instance = true ldap = true @@ -47,8 +47,8 @@ ram.runtime = "1G" [resources] [resources.sources] [resources.sources.main] - url = "https://github.com/discourse/discourse/archive/v2.8.14.tar.gz" - sha256 = "b4b9a2857515ab79b2bc71cc0bdd09f9bf749d506c095b76d86846c9adf62623" + url = "https://github.com/discourse/discourse/archive/refs/tags/v3.3.1.tar.gz" + sha256 = "910efab3a8e0508507f1cd32e512390272e029f9a8c689a23d52444fc6f1f666" autoupdate.strategy = "latest_github_tag" From 4f7f2a5ef12db4b6784026a2c73427add64edfa5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Mon, 1 Jul 2024 10:38:12 +0200 Subject: [PATCH 02/21] Bump ruby to 3.2 for bookworm ? --- scripts/_common.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 06ebbfb..ed08d67 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -4,7 +4,7 @@ # COMMON VARIABLES #================================================= -ruby_version="3.0.0" +ruby_version="3.2" nodejs_version="18" From 1c68c4a6e04fc005435af312947f89ecfc1bd0af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=CC=81ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Thu, 16 May 2024 09:06:32 +0200 Subject: [PATCH 03/21] Upgrade nodejs to v20 --- scripts/_common.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index ed08d67..bf759a0 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -6,7 +6,7 @@ ruby_version="3.2" -nodejs_version="18" +nodejs_version="20" libjemalloc="$(ldconfig -p | grep libjemalloc | awk 'END {print $NF}')" From 3b82840d88d69947beb759bd9d8442de754f97cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Fri, 26 Jul 2024 14:21:38 +0200 Subject: [PATCH 04/21] Fix patches for v3 --- .../patches/main-1-use-latest_uglify-js.patch | 34 +++++++++----- .../main-4-fix-missing-git-repository.patch | 47 ++++++++++++------- .../main-6-fix-download-calendar.patch | 20 ++++++-- 3 files changed, 69 insertions(+), 32 deletions(-) diff --git a/sources/patches/main-1-use-latest_uglify-js.patch b/sources/patches/main-1-use-latest_uglify-js.patch index 415ec9e..ad1af53 100644 --- a/sources/patches/main-1-use-latest_uglify-js.patch +++ b/sources/patches/main-1-use-latest_uglify-js.patch @@ -1,14 +1,26 @@ +From 0d5cfdaf5d1b65cff5b2c1bde026dbb9b3351d4f Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= +Date: Fri, 26 Jul 2024 14:15:56 +0200 +Subject: [PATCH 1/3] Use latest uglify-js + +--- + lib/tasks/assets.rake | 3 +++ + 1 file changed, 3 insertions(+) + diff --git a/lib/tasks/assets.rake b/lib/tasks/assets.rake -index 4a02d5f1b1..7b47f21658 100644 +index 96082977..ce59ce85 100644 --- a/lib/tasks/assets.rake +++ b/lib/tasks/assets.rake -@@ -126,6 +126,9 @@ - data = File.read("#{assets_path}/#{from}") - - uglified, map = Uglifier.new(comments: :none, -+ harmony: true, -+ mangle: false, -+ compress: false, - source_map: { - filename: File.basename(from), - output_filename: File.basename(to) +@@ -181,6 +181,9 @@ def compress_ruby(from, to) + uglified, map = + Uglifier.new( + comments: :none, ++ harmony: true, ++ mangle: false, ++ compress: false, + source_map: { + filename: File.basename(from), + output_filename: File.basename(to), +-- +2.45.2 + diff --git a/sources/patches/main-4-fix-missing-git-repository.patch b/sources/patches/main-4-fix-missing-git-repository.patch index a98afb6..6e117d0 100644 --- a/sources/patches/main-4-fix-missing-git-repository.patch +++ b/sources/patches/main-4-fix-missing-git-repository.patch @@ -1,22 +1,35 @@ +From 2319de5a4759f17c11a6000779d1c8840c342771 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= +Date: Fri, 26 Jul 2024 14:19:22 +0200 +Subject: [PATCH 2/3] Fix missing git commands in repository + +--- + lib/discourse.rb | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + diff --git a/lib/discourse.rb b/lib/discourse.rb -index 2b53a91eb3..eec55647d5 100644 +index 1af04378..6207c8f5 100644 --- a/lib/discourse.rb +++ b/lib/discourse.rb -@@ -439,7 +439,7 @@ module Discourse - def self.full_version - @full_version ||= begin - git_cmd = 'git describe --dirty --match "v[0-9]*" 2> /dev/null' -- self.try_git(git_cmd, 'unknown') -+ self.try_git(git_cmd, Discourse::VERSION::STRING) - end +@@ -842,7 +842,7 @@ module Discourse + @full_version ||= + begin + git_cmd = 'git describe --dirty --match "v[0-9]*" 2> /dev/null' +- self.try_git(git_cmd, "unknown") ++ self.try_git(git_cmd, Discourse::VERSION::STRING) + end end + +@@ -850,7 +850,8 @@ module Discourse + @last_commit_date ||= + begin + git_cmd = 'git log -1 --format="%ct"' +- seconds = self.try_git(git_cmd, nil) ++ # Note(decentral1se): Output from actual command in the v3.2.4 branch ++ seconds = self.try_git(git_cmd, '1721046633') + seconds.nil? ? nil : DateTime.strptime(seconds, "%s") + end + end +-- +2.45.2 -@@ -448,7 +448,7 @@ module Discourse - def self.last_commit_date - @last_commit_date ||= begin - git_cmd = 'git log -1 --format="%ct"' -- seconds = self.try_git(git_cmd, nil) -+ seconds = '1563199245' # Note(decentral1se): Output from actual command in the v2.3.2 branch - seconds.nil? ? nil : DateTime.strptime(seconds, '%s') - end - end diff --git a/sources/patches/main-6-fix-download-calendar.patch b/sources/patches/main-6-fix-download-calendar.patch index 580e10d..132ca9c 100644 --- a/sources/patches/main-6-fix-download-calendar.patch +++ b/sources/patches/main-6-fix-download-calendar.patch @@ -1,13 +1,25 @@ +From e515c68e1011d42f5fd817a799f4694fb469eea2 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= +Date: Fri, 26 Jul 2024 14:20:17 +0200 +Subject: [PATCH 3/3] Fix download calendar + +--- + app/assets/javascripts/discourse/app/lib/download-calendar.js | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + diff --git a/app/assets/javascripts/discourse/app/lib/download-calendar.js b/app/assets/javascripts/discourse/app/lib/download-calendar.js -index 2b53a91eb3..eec55647d5 100644 +index 238a8cf0..541b6b1b 100644 --- a/app/assets/javascripts/discourse/app/lib/download-calendar.js +++ b/app/assets/javascripts/discourse/app/lib/download-calendar.js -@@ -22,7 +22,7 @@ +@@ -23,7 +23,7 @@ export function downloadCalendar(title, dates, recurrenceRule = null) { } - export function downloadIcs(title, dates) { + export function downloadIcs(title, dates, recurrenceRule) { - const REMOVE_FILE_AFTER = 20_000; + const REMOVE_FILE_AFTER = 20000; - const file = new File([generateIcsData(title, dates)], { + const file = new File([generateIcsData(title, dates, recurrenceRule)], { type: "text/plain", }); +-- +2.45.2 + From e7cdd615f3ea6f150c1813a08dd6acd7b3487195 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Fri, 26 Jul 2024 15:17:42 +0200 Subject: [PATCH 05/21] Try to yarn add patch-package --- scripts/install | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/install b/scripts/install index 941613f..84e8b14 100644 --- a/scripts/install +++ b/scripts/install @@ -141,6 +141,7 @@ pushd "$install_dir" ynh_use_nodejs ynh_npm install --location=global terser ynh_npm install --location=global uglify-js + ynh_exec_warn_less ynh_exec_as "$app" "$ynh_node_load_PATH" yarn add patch-package ynh_exec_warn_less ynh_exec_as "$app" "$ynh_node_load_PATH" yarn install --production --frozen-lockfile ynh_exec_warn_less ynh_exec_as "$app" "$ynh_node_load_PATH" yarn cache clean popd From 7bbf6a582025e4de4c3498d8a309b89c3ee67f18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Fri, 26 Jul 2024 15:40:31 +0200 Subject: [PATCH 06/21] Fix install --- scripts/install | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/scripts/install b/scripts/install index 84e8b14..afcf2ed 100644 --- a/scripts/install +++ b/scripts/install @@ -108,25 +108,6 @@ echo "svgo: false" | ynh_exec_as "$app" tee "$install_dir/.image_optim.yml" >/de #================================================= ynh_script_progression --message="Setting up Unicorn..." -pushd "$install_dir" - # Install bundler, a gems installer - ynh_gem install bundler - # Install without documentation - echo "gem: --no-ri --no-rdoc" | ynh_exec_as "$app" tee "$install_dir/.gemrc" >/dev/null -popd - -# Specific actions on ARM architecture -if dpkg --print-architecture | grep -q "arm"; then - # Define the platform specifically to retrieve binaries - # for libv8 because it currently doesn't compile on ARM devices - ynh_exec_as "$app" --login bin/bundle config specific_platform arm-linux -fi - -# Install dependencies -ynh_exec_as "$app" --login bin/bundle config set path 'vendor/bundle' -ynh_exec_as "$app" --login bin/bundle config set with 'development' -ynh_exec_as "$app" --login MAKEFLAGS=-j2 bin/bundle install --jobs 2 - # On ARM architecture, replace bundled libpsl by system native libpsl # because the provided binary isn't compatible if dpkg --print-architecture | grep -q "arm"; then @@ -137,12 +118,31 @@ if dpkg --print-architecture | grep -q "arm"; then ) fi +pushd "$install_dir" + # Install bundler, a gems installer + ynh_gem install bundler + # Install without documentation + echo "gem: --no-ri --no-rdoc" | ynh_exec_as "$app" tee "$install_dir/.gemrc" >/dev/null + + # Specific actions on ARM architecture + if dpkg --print-architecture | grep -q "arm"; then + # Define the platform specifically to retrieve binaries + # for libv8 because it currently doesn't compile on ARM devices + ynh_exec_as "$app" --login bin/bundle config specific_platform arm-linux + fi + + # Install dependencies + ynh_exec_as "$app" --login bin/bundle config set path 'vendor/bundle' + ynh_exec_as "$app" --login bin/bundle config set without test development + ynh_exec_as "$app" --login MAKEFLAGS=-j2 bin/bundle install --jobs 2 +popd + pushd "$install_dir" ynh_use_nodejs ynh_npm install --location=global terser ynh_npm install --location=global uglify-js - ynh_exec_warn_less ynh_exec_as "$app" "$ynh_node_load_PATH" yarn add patch-package - ynh_exec_warn_less ynh_exec_as "$app" "$ynh_node_load_PATH" yarn install --production --frozen-lockfile + ynh_exec_warn_less ynh_exec_as "$app" "$ynh_node_load_PATH" yarn add patch-package --cwd "$install_dir/app/assets/javascripts/" + ynh_exec_warn_less ynh_exec_as "$app" "$ynh_node_load_PATH" yarn install --frozen-lockfile ynh_exec_warn_less ynh_exec_as "$app" "$ynh_node_load_PATH" yarn cache clean popd From ee07d43d8792b6939e4289ef77be0d75f14c22f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Fri, 26 Jul 2024 15:41:07 +0200 Subject: [PATCH 07/21] Remove yarn add patch-package for tests --- scripts/install | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/install b/scripts/install index afcf2ed..6543db8 100644 --- a/scripts/install +++ b/scripts/install @@ -141,7 +141,6 @@ pushd "$install_dir" ynh_use_nodejs ynh_npm install --location=global terser ynh_npm install --location=global uglify-js - ynh_exec_warn_less ynh_exec_as "$app" "$ynh_node_load_PATH" yarn add patch-package --cwd "$install_dir/app/assets/javascripts/" ynh_exec_warn_less ynh_exec_as "$app" "$ynh_node_load_PATH" yarn install --frozen-lockfile ynh_exec_warn_less ynh_exec_as "$app" "$ynh_node_load_PATH" yarn cache clean popd From d3f0451113a9f6b3beec943600708d935a942ad8 Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Thu, 29 Aug 2024 10:39:04 +0000 Subject: [PATCH 08/21] Auto-update READMEs --- README.md | 2 +- README_es.md | 2 +- README_eu.md | 2 +- README_fr.md | 2 +- README_gl.md | 2 +- README_id.md | 2 +- README_ru.md | 2 +- README_zh_Hans.md | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 50a5b30..38cfc1c 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ It shall NOT be edited by hand. To learn more about the philosophy and goals of the project, [visit **discourse.org**](http://www.discourse.org). -**Shipped version:** 2.8.14~ynh5 +**Shipped version:** 3.3.1~ynh1 **Demo:** diff --git a/README_es.md b/README_es.md index bd7dd51..736451c 100644 --- a/README_es.md +++ b/README_es.md @@ -25,7 +25,7 @@ No se debe editar a mano. To learn more about the philosophy and goals of the project, [visit **discourse.org**](http://www.discourse.org). -**Versión actual:** 2.8.14~ynh5 +**Versión actual:** 3.3.1~ynh1 **Demo:** diff --git a/README_eu.md b/README_eu.md index e7a2ba5..dbcad00 100644 --- a/README_eu.md +++ b/README_eu.md @@ -25,7 +25,7 @@ EZ editatu eskuz. To learn more about the philosophy and goals of the project, [visit **discourse.org**](http://www.discourse.org). -**Paketatutako bertsioa:** 2.8.14~ynh5 +**Paketatutako bertsioa:** 3.3.1~ynh1 **Demoa:** diff --git a/README_fr.md b/README_fr.md index 2bfcf6f..97ca4bd 100644 --- a/README_fr.md +++ b/README_fr.md @@ -25,7 +25,7 @@ Il NE doit PAS être modifié à la main. Pour en savoir plus sur la philosophie et les objectifs du projet, [visitez **discourse.org**](http://www.discourse.org). -**Version incluse :** 2.8.14~ynh5 +**Version incluse :** 3.3.1~ynh1 **Démo :** diff --git a/README_gl.md b/README_gl.md index 4d07579..cd96e1b 100644 --- a/README_gl.md +++ b/README_gl.md @@ -25,7 +25,7 @@ NON debe editarse manualmente. To learn more about the philosophy and goals of the project, [visit **discourse.org**](http://www.discourse.org). -**Versión proporcionada:** 2.8.14~ynh5 +**Versión proporcionada:** 3.3.1~ynh1 **Demo:** diff --git a/README_id.md b/README_id.md index d843ac3..edd787f 100644 --- a/README_id.md +++ b/README_id.md @@ -25,7 +25,7 @@ Ini TIDAK boleh diedit dengan tangan. To learn more about the philosophy and goals of the project, [visit **discourse.org**](http://www.discourse.org). -**Versi terkirim:** 2.8.14~ynh5 +**Versi terkirim:** 3.3.1~ynh1 **Demo:** diff --git a/README_ru.md b/README_ru.md index 75081ea..d01326c 100644 --- a/README_ru.md +++ b/README_ru.md @@ -25,7 +25,7 @@ To learn more about the philosophy and goals of the project, [visit **discourse.org**](http://www.discourse.org). -**Поставляемая версия:** 2.8.14~ynh5 +**Поставляемая версия:** 3.3.1~ynh1 **Демо-версия:** diff --git a/README_zh_Hans.md b/README_zh_Hans.md index 60c0ea9..753f59a 100644 --- a/README_zh_Hans.md +++ b/README_zh_Hans.md @@ -25,7 +25,7 @@ To learn more about the philosophy and goals of the project, [visit **discourse.org**](http://www.discourse.org). -**分发版本:** 2.8.14~ynh5 +**分发版本:** 3.3.1~ynh1 **演示:** From 5dc2e9f19c22a91c2d189ddf094dedb488b162a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Thu, 29 Aug 2024 12:47:51 +0200 Subject: [PATCH 09/21] Move sources into the discourse subdirectory --- conf/nginx.conf | 22 ++++++------- conf/systemd.service | 10 +++--- doc/ADMIN.md | 2 +- doc/ADMIN_fr.md | 2 +- scripts/change_url | 16 +++++----- scripts/install | 58 ++++++++++++++++++---------------- scripts/restore | 6 ++-- scripts/upgrade | 75 +++++++++++++++++++++++++------------------- 8 files changed, 103 insertions(+), 88 deletions(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index 13682be..20ccd61 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -8,7 +8,7 @@ send_timeout 600; # path to discourse's public directory - set $public __INSTALL_DIR__/public/; + set $public __INSTALL_DIR__/discourse/public/; # without weak etags we get zero benefit from etags on dynamically compressed content # further more etags are based on the file in nginx not sha of data @@ -29,7 +29,7 @@ #sub_path_only rewrite ^__PATH__$ __PATH__/ permanent; location __PATH__/ { - alias __INSTALL_DIR__/public/ ; + alias __INSTALL_DIR__/discourse/public/ ; proxy_hide_header ETag; # auth_basic on; @@ -53,7 +53,7 @@ proxy_set_header X-Request-Start "t=${msec}"; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto https; - proxy_pass http://unix:__INSTALL_DIR__/tmp/sockets/unicorn.sock; + proxy_pass http://unix:__INSTALL_DIR__/discourse/tmp/sockets/unicorn.sock; break; } @@ -99,7 +99,7 @@ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto https; proxy_set_header X-Sendfile-Type X-Accel-Redirect; - proxy_set_header X-Accel-Mapping __INSTALL_DIR__/public/=/downloads/; + proxy_set_header X-Accel-Mapping __INSTALL_DIR__/discourse/public/=/downloads/; expires 1y; more_set_headers "Cache-Control : public,immutable"; @@ -120,7 +120,7 @@ try_files $uri =404; } - proxy_pass http://unix:__INSTALL_DIR__/tmp/sockets/unicorn.sock; + proxy_pass http://unix:__INSTALL_DIR__/discourse/tmp/sockets/unicorn.sock; break; } @@ -131,8 +131,8 @@ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto https; proxy_set_header X-Sendfile-Type X-Accel-Redirect; - proxy_set_header X-Accel-Mapping __INSTALL_DIR__/public/=/downloads/; - proxy_pass http://unix:__INSTALL_DIR__/tmp/sockets/unicorn.sock; + proxy_set_header X-Accel-Mapping __INSTALL_DIR__/discourse/public/=/downloads/; + proxy_pass http://unix:__INSTALL_DIR__/discourse/tmp/sockets/unicorn.sock; break; } @@ -155,7 +155,7 @@ # proxy_cache one; proxy_cache_valid 200 301 302 7d; proxy_cache_valid any 1m; - proxy_pass http://unix:__INSTALL_DIR__/tmp/sockets/unicorn.sock; + proxy_pass http://unix:__INSTALL_DIR__/discourse/tmp/sockets/unicorn.sock; break; } @@ -189,7 +189,7 @@ proxy_set_header X-Forwarded-Proto https; proxy_http_version 1.1; proxy_buffering off; - proxy_pass http://unix:__INSTALL_DIR__/tmp/sockets/unicorn.sock; + proxy_pass http://unix:__INSTALL_DIR__/discourse/tmp/sockets/unicorn.sock; break; } @@ -199,7 +199,7 @@ location __PATH__/downloads/ { internal; - alias __INSTALL_DIR__/public/ ; + alias __INSTALL_DIR__/discourse/public/ ; } location @__NAME__ { @@ -209,5 +209,5 @@ proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto https; - proxy_pass http://unix:__INSTALL_DIR__/tmp/sockets/unicorn.sock; + proxy_pass http://unix:__INSTALL_DIR__/discourse/tmp/sockets/unicorn.sock; } diff --git a/conf/systemd.service b/conf/systemd.service index d233091..d4aa3b3 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -8,19 +8,19 @@ After=postgresql.service [Service] User=__APP__ Group=__APP__ -WorkingDirectory=__INSTALL_DIR__ +WorkingDirectory=__INSTALL_DIR__/discourse Environment=__ADDITIONAL_ENV__ Environment=RAILS_ENV=production Environment=UNICORN_SIDEKIQS=1 Environment=LD_PRELOAD=__LIBJEMALLOC__ -Environment=UNICORN_LISTENER=__INSTALL_DIR__/tmp/sockets/unicorn.sock +Environment=UNICORN_LISTENER=__INSTALL_DIR__/discourse/tmp/sockets/unicorn.sock Environment="__YNH_RUBY_LOAD_PATH__" -ExecStart=__INSTALL_DIR__/bin/bundle exec unicorn --config config/unicorn.conf.rb -E production +ExecStart=__INSTALL_DIR__/discourse/bin/bundle exec unicorn --config config/unicorn.conf.rb -E production Restart=always RestartSec=10 # Sandboxing options to harden security -# Depending on specificities of your service/app, you may need to tweak these +# Depending on specificities of your service/app, you may need to tweak these # .. but this should be a good baseline # Details for these options: https://www.freedesktop.org/software/systemd/man/systemd.exec.html NoNewPrivileges=yes @@ -47,7 +47,7 @@ CapabilityBoundingSet=~CAP_BLOCK_SUSPEND CAP_WAKE_ALARM CapabilityBoundingSet=~CAP_SYS_TTY_CONFIG CapabilityBoundingSet=~CAP_MAC_ADMIN CAP_MAC_OVERRIDE CapabilityBoundingSet=~CAP_NET_ADMIN CAP_NET_BROADCAST CAP_NET_RAW -CapabilityBoundingSet=~CAP_SYS_ADMIN CAP_SYS_PTRACE CAP_SYSLOG +CapabilityBoundingSet=~CAP_SYS_ADMIN CAP_SYS_PTRACE CAP_SYSLOG [Install] WantedBy=multi-user.target diff --git a/doc/ADMIN.md b/doc/ADMIN.md index f4e0cea..abe9312 100644 --- a/doc/ADMIN.md +++ b/doc/ADMIN.md @@ -66,7 +66,7 @@ When disabling Local Login and other authentication services, clicking the `Logi ### Installing plugins ```bash -cd /var/www/discourse +cd /var/www/discourse/discourse sudo -i -u discourse RAILS_ENV=production bin/rake --trace plugin:install repo=https://github.com/discourse/discourse-solved (for example) sudo -i -u discourse RAILS_ENV=production bin/rake --trace assets:precompile systemctl restart discourse diff --git a/doc/ADMIN_fr.md b/doc/ADMIN_fr.md index fdd59af..b4d88d4 100644 --- a/doc/ADMIN_fr.md +++ b/doc/ADMIN_fr.md @@ -65,7 +65,7 @@ Lors de la désactivation de la connexion locale et d'autres services d'authenti ### Installer des plugins ```bash -cd /var/www/discourse +cd /var/www/discourse/discourse sudo -i -u discourse RAILS_ENV=production bin/rake --trace plugin:install repo=https://github.com/discourse/discourse-solved (for example) sudo -i -u discourse RAILS_ENV=production bin/rake --trace assets:precompile systemctl restart discourse diff --git a/scripts/change_url b/scripts/change_url index f693d23..6cd948b 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -26,7 +26,7 @@ ynh_change_url_nginx_config #================================================= ynh_script_progression --message="Updating a config file..." -discourse_config_file="$install_dir/config/discourse.conf" +discourse_config_file="$install_dir/discourse/config/discourse.conf" old_relative_url_root="${old_path%/}" new_relative_url_root="${new_path%/}" @@ -46,14 +46,16 @@ UPDATE site_settings SET value = '${new_path}' WHERE name='long_polling_base_url ynh_use_ruby # Remap URLs in forum posts -ynh_exec_as "$app" --login RAILS_ENV=production bin/bundle exec script/discourse remap "$old_relative_url_root/uploads" "$new_relative_url_root/uploads" <<< "YES +ynh_exec_as "$app" --login RAILS_ENV=production "$install_dir/discourse/bin/bundle" exec script/discourse remap "$old_relative_url_root/uploads" "$new_relative_url_root/uploads" <<< "YES # " -# Regenerate assets -ynh_exec_warn_less ynh_exec_as "$app" --login RAILS_ENV=production bin/rake assets:precompile +pushd "$install_dir/discourse" + # Regenerate assets + ynh_exec_warn_less ynh_exec_as "$app" --login RAILS_ENV=production bin/rake assets:precompile -# Regenerate all forum posts -ynh_exec_warn_less ynh_exec_as "$app" --login RAILS_ENV=production bin/rake posts:rebake + # Regenerate all forum posts + ynh_exec_warn_less ynh_exec_as "$app" --login RAILS_ENV=production bin/rake posts:rebake +popd #================================================= # START SYSTEMD SERVICE @@ -61,7 +63,7 @@ ynh_exec_warn_less ynh_exec_as "$app" --login RAILS_ENV=production bin/rake post ynh_script_progression --message="Starting $app's systemd service..." # Start a systemd service -ynh_systemd_action --service_name="$app" --action="start" --log_path="$install_dir/log/unicorn.stderr.log" --line_match="INFO -- : worker=$((unicorn_workers-1)) ready" +ynh_systemd_action --service_name="$app" --action="start" --log_path="$install_dir/discourse/log/unicorn.stderr.log" --line_match="INFO -- : worker=$((unicorn_workers-1)) ready" #================================================= # END OF SCRIPT diff --git a/scripts/install b/scripts/install index 6543db8..f6628ff 100644 --- a/scripts/install +++ b/scripts/install @@ -73,20 +73,20 @@ if dpkg --print-architecture | grep -q "arm"; then fi # Download, check integrity, uncompress and patch the source from app.src -ynh_setup_source --dest_dir="$install_dir" +ynh_setup_source --dest_dir="$install_dir/discourse" # Install LDAP plugin -ynh_setup_source --source_id=ldap-auth --dest_dir="$install_dir/plugins/discourse-ldap-auth" +ynh_setup_source --source_id=ldap-auth --dest_dir="$install_dir/discourse/plugins/discourse-ldap-auth" # Add a pids and socket directory for the systemd script. -mkdir -p "$install_dir/tmp/pids" -mkdir -p "$install_dir/tmp/sockets" -mkdir -p "$install_dir/public/forum" +mkdir -p "$install_dir/discourse/tmp/pids" +mkdir -p "$install_dir/discourse/tmp/sockets" +mkdir -p "$install_dir/discourse/public/forum" # Create specific folders and links for subfolder compatibility # (see: https://meta.discourse.org/t/subfolder-support-with-docker/30507) -ln -s "$install_dir/public/uploads" "$install_dir/public/forum/uploads" -ln -s "$install_dir/public/backups" "$install_dir/public/forum/backups" +ln -s "$install_dir/discourse/public/uploads" "$install_dir/discourse/public/forum/uploads" +ln -s "$install_dir/discourse/public/backups" "$install_dir/discourse/public/forum/backups" chmod -R o-rwx "$install_dir" chown -R "$app:www-data" "$install_dir" @@ -96,12 +96,12 @@ chown -R "$app:www-data" "$install_dir" #================================================= ynh_script_progression --message="Adding $app's configuration file..." -ynh_add_config --template="discourse_defaults.conf" --destination="$install_dir/config/discourse.conf" -ynh_add_config --template="secrets.yml" --destination="$install_dir/config/secrets.yml" -ynh_add_config --template="settings.yml" --destination="$install_dir/plugins/discourse-ldap-auth/config/settings.yml" +ynh_add_config --template="discourse_defaults.conf" --destination="$install_dir/discourse/config/discourse.conf" +ynh_add_config --template="secrets.yml" --destination="$install_dir/discourse/config/secrets.yml" +ynh_add_config --template="settings.yml" --destination="$install_dir/discourse/plugins/discourse-ldap-auth/config/settings.yml" # Disable svgo worker -echo "svgo: false" | ynh_exec_as "$app" tee "$install_dir/.image_optim.yml" >/dev/null +echo "svgo: false" | ynh_exec_as "$app" tee "$install_dir/discourse/.image_optim.yml" >/dev/null #================================================= # SETUP UNICORN, A RUBY SERVER @@ -112,13 +112,13 @@ ynh_script_progression --message="Setting up Unicorn..." # because the provided binary isn't compatible if dpkg --print-architecture | grep -q "arm"; then ( - cd "$install_dir/vendor/bundle/ruby"/*/"gems/mini_suffix-*/vendor" + cd "$install_dir/discourse/vendor/bundle/ruby"/*/"gems/mini_suffix-*/vendor" rm libpsl.so ln -s "$(ldconfig -p | grep libpsl | awk 'END {print $NF}')" libpsl.so ) fi -pushd "$install_dir" +pushd "$install_dir/discourse" # Install bundler, a gems installer ynh_gem install bundler # Install without documentation @@ -128,16 +128,16 @@ pushd "$install_dir" if dpkg --print-architecture | grep -q "arm"; then # Define the platform specifically to retrieve binaries # for libv8 because it currently doesn't compile on ARM devices - ynh_exec_as "$app" --login bin/bundle config specific_platform arm-linux + ynh_exec_as "$app" --login "$install_dir/discourse/bin/bundle" config specific_platform arm-linux fi # Install dependencies - ynh_exec_as "$app" --login bin/bundle config set path 'vendor/bundle' - ynh_exec_as "$app" --login bin/bundle config set without test development - ynh_exec_as "$app" --login MAKEFLAGS=-j2 bin/bundle install --jobs 2 + ynh_exec_as "$app" --login "$install_dir/discourse/bin/bundle" config set path 'vendor/bundle' + ynh_exec_as "$app" --login "$install_dir/discourse/bin/bundle" config set without test development + ynh_exec_as "$app" --login MAKEFLAGS=-j2 "$install_dir/discourse/bin/bundle" install --jobs 2 popd -pushd "$install_dir" +pushd "$install_dir/discourse" ynh_use_nodejs ynh_npm install --location=global terser ynh_npm install --location=global uglify-js @@ -150,8 +150,10 @@ popd #================================================= ynh_script_progression --message="Preparing the database..." -ynh_exec_warn_less ynh_exec_as "$app" --login RAILS_ENV=production bin/bundle exec rake db:migrate -ynh_exec_warn_less ynh_exec_as "$app" --login RAILS_ENV=production bin/bundle exec rake themes:update assets:precompile +pushd "$install_dir/discourse" + ynh_exec_warn_less ynh_exec_as "$app" --login RAILS_ENV=production "$install_dir/discourse/bin/bundle" exec rake db:migrate + ynh_exec_warn_less ynh_exec_as "$app" --login RAILS_ENV=production "$install_dir/discourse/bin/bundle" exec rake themes:update assets:precompile +popd # Set default data (especially to have correct image URLs for subfolder install) ynh_add_config --template="provisioning.sql" --destination="$install_dir/provisioning.sql" @@ -163,11 +165,13 @@ ynh_secure_remove --file="$install_dir/provisioning.sql" #================================================= ynh_script_progression --message="Creating Discourse admin user..." -ynh_exec_as "$app" --login RAILS_ENV=production bin/rake admin:create <<< "$admin_mail +pushd "$install_dir/discourse" + ynh_exec_as "$app" --login RAILS_ENV=production bin/rake admin:create <<< "$admin_mail $admin_pwd $admin_pwd y " +popd #================================================= # CONFIGURE PLUGINS @@ -177,7 +181,7 @@ ynh_script_progression --message="Configuring plugins..." # Patch ldap-auth plugin dependency (omniauth-ldap) to fix it when using domain subfolder # (Can only do that now because we are patching dependencies which have just been downloaded) # Patch applied: https://github.com/omniauth/omniauth-ldap/pull/16 -patch -p1 -d "$install_dir/plugins/discourse-ldap-auth/gems/$ruby_version/gems/omniauth-ldap"*/ \ +patch -p1 -d "$install_dir/discourse/plugins/discourse-ldap-auth/gems/$ruby_version/gems/omniauth-ldap"*/ \ < "../conf/ldap-auth-fix-subfolder.patch" #================================================= @@ -197,13 +201,13 @@ ynh_store_file_checksum --file="/etc/nginx/conf.d/$domain.d/$app.conf" additional_env="UNICORN_WORKERS=$unicorn_workers" ynh_add_systemd_config -yunohost service add "$app" --log "$install_dir/log/unicorn.stderr.log" "$install_dir/log/unicorn.stdout.log" "$install_dir/log/production.log" +yunohost service add "$app" --log "$install_dir/discourse/log/unicorn.stderr.log" "$install_dir/discourse/log/unicorn.stdout.log" "$install_dir/discourse/log/production.log" # Use logrotate to manage application logfile(s) -ynh_use_logrotate --logfile="$install_dir/log/unicorn.stderr.log" -ynh_use_logrotate --logfile="$install_dir/log/unicorn.stdout.log" -ynh_use_logrotate --logfile="$install_dir/log/production.log" +ynh_use_logrotate --logfile="$install_dir/discourse/log/unicorn.stderr.log" +ynh_use_logrotate --logfile="$install_dir/discourse/log/unicorn.stdout.log" +ynh_use_logrotate --logfile="$install_dir/discourse/log/production.log" #================================================= # START SYSTEMD SERVICE @@ -211,7 +215,7 @@ ynh_use_logrotate --logfile="$install_dir/log/production.log" ynh_script_progression --message="Starting $app's systemd service..." # Start a systemd service -ynh_systemd_action --service_name="$app" --action="start" --log_path="$install_dir/log/unicorn.stderr.log" --line_match="INFO -- : worker=$((unicorn_workers-1)) ready" +ynh_systemd_action --service_name="$app" --action="start" --log_path="$install_dir/discourse/log/unicorn.stderr.log" --line_match="INFO -- : worker=$((unicorn_workers-1)) ready" #================================================= # END OF SCRIPT diff --git a/scripts/restore b/scripts/restore index aa3ffee..fda5870 100644 --- a/scripts/restore +++ b/scripts/restore @@ -48,7 +48,7 @@ ynh_psql_connect_as --user="$db_user" --password="$db_pwd" --database="$db_name" #================================================= ynh_script_progression --message="Reinstall Bundle Gem..." -pushd "$install_dir" +pushd "$install_dir/discourse" ynh_gem install bundler popd @@ -61,7 +61,7 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_restore_file --origin_path="/etc/systemd/system/$app.service" systemctl enable "$app.service" --quiet -yunohost service add "$app" --log "$install_dir/log/unicorn.stderr.log" "$install_dir/log/unicorn.stdout.log" "$install_dir/log/production.log" +yunohost service add "$app" --log "$install_dir/discourse/log/unicorn.stderr.log" "$install_dir/discourse/log/unicorn.stdout.log" "$install_dir/discourse/log/production.log" ynh_restore_file --origin_path="/etc/logrotate.d/$app" @@ -70,7 +70,7 @@ ynh_restore_file --origin_path="/etc/logrotate.d/$app" #================================================= ynh_script_progression --message="Reloading NGINX web server and $app's service..." --weight=1 -ynh_systemd_action --service_name="$app" --action="start" --log_path="$install_dir/log/unicorn.stderr.log" --line_match="INFO -- : worker=$((unicorn_workers-1)) ready" +ynh_systemd_action --service_name="$app" --action="start" --log_path="$install_dir/discourse/log/unicorn.stderr.log" --line_match="INFO -- : worker=$((unicorn_workers-1)) ready" ynh_systemd_action --service_name=nginx --action=reload diff --git a/scripts/upgrade b/scripts/upgrade index 0cb4d02..dc5f8ac 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -32,7 +32,7 @@ ynh_maintenance_mode_ON #================================================= ynh_script_progression --message="Stopping a systemd service..." -ynh_systemd_action --service_name="$app" --action="stop" --log_path="$install_dir/log/unicorn.stderr.log" +ynh_systemd_action --service_name="$app" --action="stop" --log_path="$install_dir/discourse/log/unicorn.stderr.log" #================================================= # ENSURE DOWNWARD COMPATIBILITY @@ -51,6 +51,13 @@ if [ -z "$unicorn_workers" ]; then ynh_app_setting_set --app="$app" --key="unicorn_workers" --value="$unicorn_workers" fi +if [ -f "$install_dir/tmp/sockets/unicorn.sock" ]; then + # Move sources into the discourse subdir. + mkdir -p "$install_dir/__new__" + find "$install_dir" -mindepth 1 -maxdepth 1 -not -name "__new__" -print0 | xargs -0 mv -t "$install_dir/__new__" + mv "$install_dir/__new__" "$install_dir/discourse" +fi + #================================================= # UPGRADING DEPENDENCIES #================================================= @@ -75,35 +82,35 @@ if dpkg --print-architecture | grep -q "arm"; then fi # Small trick to backup non-core plugins -mv "$install_dir/plugins" "$install_dir/plugins_old" +mv "$install_dir/discourse/plugins" "$install_dir/discourse/plugins_old" # Download, check integrity, uncompress and patch the source from app.src -ynh_setup_source --dest_dir="$install_dir" --full_replace=1 \ +ynh_setup_source --dest_dir="$install_dir/discourse" --full_replace=1 \ --keep="config/discourse.conf plugins_old public/uploads public/backups log" # Restore all non-core plugins -for plugin_dir in "$install_dir/plugins_old"/*; do +for plugin_dir in "$install_dir/discourse/plugins_old"/*; do plugin_name=$(basename "$plugin_dir") - if [ ! -d "$install_dir/plugins/$plugin_name" ]; then - mv "$plugin_dir" "$install_dir/plugins/$plugin_name" + if [ ! -d "$install_dir/discourse/plugins/$plugin_name" ]; then + mv "$plugin_dir" "$install_dir/discourse/plugins/$plugin_name" fi done -ynh_secure_remove --file="$install_dir/plugins_old" +ynh_secure_remove --file="$install_dir/discourse/plugins_old" # Install LDAP plugin -ynh_setup_source --source_id=ldap-auth --dest_dir="$install_dir/plugins/discourse-ldap-auth" --full_replace=1 \ +ynh_setup_source --source_id=ldap-auth --dest_dir="$install_dir/discourse/plugins/discourse-ldap-auth" --full_replace=1 \ --keep="config/settings.yml" # Add a pids and socket directory for the systemd script. -mkdir -p "$install_dir/tmp/pids" -mkdir -p "$install_dir/tmp/sockets" -mkdir -p "$install_dir/public/forum" +mkdir -p "$install_dir/discourse/tmp/pids" +mkdir -p "$install_dir/discourse/tmp/sockets" +mkdir -p "$install_dir/discourse/public/forum" # Create specific folders and links for subfolder compatibility # (see: https://meta.discourse.org/t/subfolder-support-with-docker/30507) -ln -s "$install_dir/public/uploads" "$install_dir/public/forum/uploads" -ln -s "$install_dir/public/backups" "$install_dir/public/forum/backups" +ln -s "$install_dir/discourse/public/uploads" "$install_dir/discourse/public/forum/uploads" +ln -s "$install_dir/discourse/public/backups" "$install_dir/discourse/public/forum/backups" # Set permissions to app files chmod -R o-rwx "$install_dir" @@ -114,12 +121,12 @@ chown -R "$app:www-data" "$install_dir" #================================================= ynh_script_progression --message="Updating $app's config file..." -ynh_add_config --template="discourse_defaults.conf" --destination="$install_dir/config/discourse.conf" -ynh_add_config --template="secrets.yml" --destination="$install_dir/config/secrets.yml" -ynh_add_config --template="settings.yml" --destination="$install_dir/plugins/discourse-ldap-auth/config/settings.yml" +ynh_add_config --template="discourse_defaults.conf" --destination="$install_dir/discourse/config/discourse.conf" +ynh_add_config --template="secrets.yml" --destination="$install_dir/discourse/config/secrets.yml" +ynh_add_config --template="settings.yml" --destination="$install_dir/discourse/plugins/discourse-ldap-auth/config/settings.yml" # Disable svgo worker -echo "svgo: false" | ynh_exec_as "$app" tee "$install_dir/.image_optim.yml" >/dev/null +echo "svgo: false" | ynh_exec_as "$app" tee "$install_dir/discourse/.image_optim.yml" >/dev/null #================================================= # SETUP UNICORN, A RUBY SERVER @@ -130,11 +137,11 @@ ynh_script_progression --message="Setting up Unicorn..." ynh_use_ruby # Make a backup of the original config file if modified -unicorn_config_file="$install_dir/config/unicorn.conf.rb" +unicorn_config_file="$install_dir/discourse/config/unicorn.conf.rb" ynh_backup_if_checksum_is_different "$unicorn_config_file" ynh_store_file_checksum --file="$unicorn_config_file" -pushd "$install_dir" +pushd "$install_dir/discourse" # Install bundler, a gems installer ynh_gem install bundler # Install without documentation @@ -145,25 +152,25 @@ popd if dpkg --print-architecture | grep -q "arm"; then # Define the platform specifically to retrieve binaries # for libv8 because it currently doesn't compile on ARM devices - ynh_exec_as "$app" --login bin/bundle config specific_platform arm-linux + ynh_exec_as "$app" --login "$install_dir/discourse/bin/bundle" config specific_platform arm-linux fi # Install dependencies -ynh_exec_as "$app" --login bin/bundle config set path 'vendor/bundle' -ynh_exec_as "$app" --login bin/bundle config set with 'development' -ynh_exec_as "$app" --login MAKEFLAGS=-j2 bin/bundle install --jobs 2 +ynh_exec_as "$app" --login "$install_dir/discourse/bin/bundle" config set path 'vendor/bundle' +ynh_exec_as "$app" --login "$install_dir/discourse/bin/bundle" config set with 'development' +ynh_exec_as "$app" --login MAKEFLAGS=-j2 "$install_dir/discourse/bin/bundle" install --jobs 2 # On ARM architecture, replace bundled libpsl by system native libpsl # because the provided binary isn't compatible if dpkg --print-architecture | grep -q "arm"; then ( - cd "$install_dir/vendor/bundle/ruby"/*/"gems/mini_suffix-*/vendor" + cd "$install_dir/discourse/vendor/bundle/ruby"/*/"gems/mini_suffix-*/vendor" rm libpsl.so ln -s "$(ldconfig -p | grep libpsl | awk 'END {print $NF}')" libpsl.so ) fi -pushd "$install_dir" +pushd "$install_dir/discourse" ynh_use_nodejs ynh_npm install --location=global terser ynh_npm install --location=global uglify-js @@ -177,8 +184,10 @@ popd ynh_script_progression --message="Preparing the database..." -ynh_exec_warn_less ynh_exec_as "$app" --login RAILS_ENV=production bin/bundle exec rake db:migrate -ynh_exec_warn_less ynh_exec_as "$app" --login RAILS_ENV=production bin/bundle exec rake themes:update assets:precompile +pushd "$install_dir/discourse" + ynh_exec_warn_less ynh_exec_as "$app" --login RAILS_ENV=production "$install_dir/discourse/bin/bundle" exec rake db:migrate + ynh_exec_warn_less ynh_exec_as "$app" --login RAILS_ENV=production "$install_dir/discourse/bin/bundle" exec rake themes:update assets:precompile +popd #================================================= # CONFIGURE PLUGINS @@ -188,7 +197,7 @@ ynh_script_progression --message="Configuring plugins..." # Patch ldap-auth plugin dependency (omniauth-ldap) to fix it when using domain subfolder # (Can only do that now because we are patching dependencies which have just been downloaded) # Patch applied: https://github.com/omniauth/omniauth-ldap/pull/16 -patch -p1 -d "$install_dir/plugins/discourse-ldap-auth/gems/$ruby_version/gems/omniauth-ldap"*/ \ +patch -p1 -d "$install_dir/discourse/plugins/discourse-ldap-auth/gems/$ruby_version/gems/omniauth-ldap"*/ \ < "../conf/ldap-auth-fix-subfolder.patch" #================================================= @@ -208,19 +217,19 @@ ynh_store_file_checksum --file="/etc/nginx/conf.d/$domain.d/$app.conf" additional_env="UNICORN_WORKERS=$unicorn_workers" ynh_add_systemd_config -yunohost service add "$app" --log "$install_dir/log/unicorn.stderr.log" "$install_dir/log/unicorn.stdout.log" "$install_dir/log/production.log" +yunohost service add "$app" --log "$install_dir/discourse/log/unicorn.stderr.log" "$install_dir/discourse/log/unicorn.stdout.log" "$install_dir/discourse/log/production.log" # Use logrotate to manage app-specific logfile(s) -ynh_use_logrotate --logfile="$install_dir/log/unicorn.stderr.log" -ynh_use_logrotate --logfile="$install_dir/log/unicorn.stdout.log" -ynh_use_logrotate --logfile="$install_dir/log/production.log" +ynh_use_logrotate --logfile="$install_dir/discourse/log/unicorn.stderr.log" +ynh_use_logrotate --logfile="$install_dir/discourse/log/unicorn.stdout.log" +ynh_use_logrotate --logfile="$install_dir/discourse/log/production.log" #================================================= # START SYSTEMD SERVICE #================================================= ynh_script_progression --message="Starting $app's systemd service..." -ynh_systemd_action --service_name="$app" --action="start" --log_path="$install_dir/log/unicorn.stderr.log" --line_match="INFO -- : worker=$((unicorn_workers-1)) ready" +ynh_systemd_action --service_name="$app" --action="start" --log_path="$install_dir/discourse/log/unicorn.stderr.log" --line_match="INFO -- : worker=$((unicorn_workers-1)) ready" #================================================= # DISABLE MAINTENANCE MODE From 19ad49c184628262705e3bd160a7b5357645c272 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Thu, 29 Aug 2024 12:52:07 +0200 Subject: [PATCH 10/21] Tabs to spaces --- scripts/_common.sh | 82 +++++++++++++++++++++++----------------------- 1 file changed, 41 insertions(+), 41 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index bf759a0..ef6a49a 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -17,56 +17,56 @@ libjemalloc="$(ldconfig -p | grep libjemalloc | awk 'END {print $NF}')" # Returns true if a swap partition is enabled, false otherwise # usage: is_swap_present is_swap_present() { - [ $(awk '/^SwapTotal:/{print $2}' /proc/meminfo) -gt 0 ] + [ $(awk '/^SwapTotal:/{print $2}' /proc/meminfo) -gt 0 ] } # Returns true if swappiness higher than 10 # usage: is_swappiness_sufficient is_swappiness_sufficient() { - [ $(cat /proc/sys/vm/swappiness) -gt 10 ] + [ $(cat /proc/sys/vm/swappiness) -gt 10 ] } # Returns true if specified free memory is available (RAM + swap) # usage: is_memory_available MEMORY (in bytes) is_memory_available() { - local needed_memory=$1 - local freemem="$(awk '/^MemAvailable:/{print $2}' /proc/meminfo)" - local freeswap="$(awk '/^SwapFree:/{print $2}' /proc/meminfo)" - [ $(($freemem+$freeswap)) -gt $needed_memory ] + local needed_memory=$1 + local freemem="$(awk '/^MemAvailable:/{print $2}' /proc/meminfo)" + local freeswap="$(awk '/^SwapFree:/{print $2}' /proc/meminfo)" + [ $(($freemem+$freeswap)) -gt $needed_memory ] } # Checks discourse install memory requirements # terminates installation if requirements not met check_memory_requirements() { - if ! is_swap_present ; then - ynh_print_warn --message="You must have a swap partition in order to install and use this application" - elif ! is_swappiness_sufficient ; then - ynh_print_warn --message="Your swappiness must be higher than 10; please see https://en.wikipedia.org/wiki/Swappiness" - elif ! is_memory_available 1000000 ; then - ynh_print_warn --message="You must have a minimum of 1Gb available memory (RAM+swap) for the installation" - fi + if ! is_swap_present ; then + ynh_print_warn --message="You must have a swap partition in order to install and use this application" + elif ! is_swappiness_sufficient ; then + ynh_print_warn --message="Your swappiness must be higher than 10; please see https://en.wikipedia.org/wiki/Swappiness" + elif ! is_memory_available 1000000 ; then + ynh_print_warn --message="You must have a minimum of 1Gb available memory (RAM+swap) for the installation" + fi } # Checks discourse upgrade memory requirements # Less requirements as the software is already installed and running # terminates upgrade if requirements not met check_memory_requirements_upgrade() { - if ! is_memory_available 400000 ; then - ynh_die --message="You must have a minimum of 400Mb available memory (RAM+swap) for the upgrade" - fi + if ! is_memory_available 400000 ; then + ynh_die --message="You must have a minimum of 400Mb available memory (RAM+swap) for the upgrade" + fi } ynh_maintenance_mode_ON () { - # Create an html to serve as maintenance notice - echo " + # Create an html to serve as maintenance notice + echo " Your app $app is currently under maintenance! @@ -77,8 +77,8 @@ ynh_maintenance_mode_ON () { " > "/var/www/html/maintenance.$app.html" - # Create a new nginx config file to redirect all access to the app to the maintenance notice instead. - echo "# All request to the app will be redirected to ${path}_maintenance and fall on the maintenance notice + # Create a new nginx config file to redirect all access to the app to the maintenance notice instead. + echo "# All request to the app will be redirected to ${path}_maintenance and fall on the maintenance notice rewrite ^${path}/(.*)$ ${path}_maintenance/? redirect; # Use another location, to not be in conflict with the original config file location ${path}_maintenance/ { @@ -90,30 +90,30 @@ try_files maintenance.$app.html =503; include conf.d/yunohost_panel.conf.inc; }" > "/etc/nginx/conf.d/$domain.d/maintenance.$app.conf" - # The current config file will redirect all requests to the root of the app. - # To keep the full path, we can use the following rewrite rule: - # rewrite ^${path}/(.*)$ ${path}_maintenance/\$1? redirect; - # The difference will be in the $1 at the end, which keep the following queries. - # But, if it works perfectly for a html request, there's an issue with any php files. - # This files are treated as simple files, and will be downloaded by the browser. - # Would be really be nice to be able to fix that issue. So that, when the page is reloaded after the maintenance, the user will be redirected to the real page he was. + # The current config file will redirect all requests to the root of the app. + # To keep the full path, we can use the following rewrite rule: + # rewrite ^${path}/(.*)$ ${path}_maintenance/\$1? redirect; + # The difference will be in the $1 at the end, which keep the following queries. + # But, if it works perfectly for a html request, there's an issue with any php files. + # This files are treated as simple files, and will be downloaded by the browser. + # Would be really be nice to be able to fix that issue. So that, when the page is reloaded after the maintenance, the user will be redirected to the real page he was. - systemctl reload nginx + systemctl reload nginx } ynh_maintenance_mode_OFF () { - # Rewrite the nginx config file to redirect from ${path}_maintenance to the real url of the app. - echo "rewrite ^${path}_maintenance/(.*)$ ${path}/\$1 redirect;" > "/etc/nginx/conf.d/$domain.d/maintenance.$app.conf" - systemctl reload nginx + # Rewrite the nginx config file to redirect from ${path}_maintenance to the real url of the app. + echo "rewrite ^${path}_maintenance/(.*)$ ${path}/\$1 redirect;" > "/etc/nginx/conf.d/$domain.d/maintenance.$app.conf" + systemctl reload nginx - # Sleep 4 seconds to let the browser reload the pages and redirect the user to the app. - sleep 4 + # Sleep 4 seconds to let the browser reload the pages and redirect the user to the app. + sleep 4 - # Then remove the temporary files used for the maintenance. - rm "/var/www/html/maintenance.$app.html" - rm "/etc/nginx/conf.d/$domain.d/maintenance.$app.conf" + # Then remove the temporary files used for the maintenance. + rm "/var/www/html/maintenance.$app.html" + rm "/etc/nginx/conf.d/$domain.d/maintenance.$app.conf" - systemctl reload nginx + systemctl reload nginx } #================================================= From 846bb31d43dbcf3a719b9a63f0f2058c14b63f83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Thu, 29 Aug 2024 13:56:11 +0200 Subject: [PATCH 11/21] Install imagemagick v7 --- conf/systemd.service | 2 +- manifest.toml | 7 +++++++ scripts/_common.sh | 36 ++++++++++++++++++++++++++++++++++++ scripts/install | 3 +++ 4 files changed, 47 insertions(+), 1 deletion(-) diff --git a/conf/systemd.service b/conf/systemd.service index d4aa3b3..1a57b4b 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -14,7 +14,7 @@ Environment=RAILS_ENV=production Environment=UNICORN_SIDEKIQS=1 Environment=LD_PRELOAD=__LIBJEMALLOC__ Environment=UNICORN_LISTENER=__INSTALL_DIR__/discourse/tmp/sockets/unicorn.sock -Environment="__YNH_RUBY_LOAD_PATH__" +Environment="__YNH_RUBY_LOAD_PATH__:__MAGICK_PREFIX__/bin" ExecStart=__INSTALL_DIR__/discourse/bin/bundle exec unicorn --config config/unicorn.conf.rb -E production Restart=always RestartSec=10 diff --git a/manifest.toml b/manifest.toml index 137823d..00be1c9 100644 --- a/manifest.toml +++ b/manifest.toml @@ -59,6 +59,13 @@ ram.runtime = "1G" autoupdate.strategy = "latest_github_tag" autoupdate.upstream = "https://github.com/jonmbake/discourse-ldap-auth" + [resources.sources.imagemagickv7] + url = "https://github.com/ImageMagick/ImageMagick/archive/7.1.0-62.tar.gz" + sha256 = "d282117bc6d0e91ad1ad685d096623b96ed8e229f911c891d83277b350ef884a" + + autoupdate.strategy = "latest_github_tag" + autoupdate.upstream = "https://github.com/ImageMagick/ImageMagick" + [resources.system_user] [resources.install_dir] diff --git a/scripts/_common.sh b/scripts/_common.sh index ef6a49a..41f92a5 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -55,6 +55,42 @@ check_memory_requirements_upgrade() { fi } +magick_prefix="$install_dir/imagemagick" +# See https://github.com/discourse/discourse_docker/blob/main/image/base/install-imagemagick +install_imagemagick() { + ynh_setup_source --source_id="imagemagickv7" --dest_dir="$install_dir/imagemagick_source" + mkdir -p "$magick_prefix" + chown -R "$app:$app" "$install_dir/imagemagick_source" "$magick_prefix" + + pushd "$install_dir/imagemagick_source" + ynh_exec_as "$app" CFLAGS="-O2 -I$magick_prefix/include -Wno-deprecated-declarations" \ + ./configure \ + --prefix="$magick_prefix" \ + --enable-static \ + --enable-bounds-checking \ + --enable-hdri \ + --enable-hugepages \ + --with-threads \ + --with-modules \ + --with-quantum-depth=16 \ + --without-magick-plus-plus \ + --with-bzlib \ + --with-zlib \ + --without-autotrace \ + --with-freetype \ + --with-jpeg \ + --without-lcms \ + --with-lzma \ + --with-png \ + --with-tiff \ + --with-heic \ + --with-rsvg \ + --with-webp + ynh_exec_as "$app" make all -j"$(nproc)" + ynh_exec_as "$app" LIBTOOLFLAGS=-Wnone make install + popd +} + ynh_maintenance_mode_ON () { # Create an html to serve as maintenance notice echo " diff --git a/scripts/install b/scripts/install index f6628ff..d1f97f2 100644 --- a/scripts/install +++ b/scripts/install @@ -49,6 +49,9 @@ ynh_script_progression --message="Installing NodeJS..." ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version +ynh_script_progression --message="Building and installing ImageMagick v7..." +install_imagemagick + #================================================= # CONFIGURE A POSTGRESQL DATABASE #================================================= From fe962a81c8108c811e9b58b126098755f4cb4642 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Thu, 29 Aug 2024 15:07:36 +0200 Subject: [PATCH 12/21] Add dependencies for imagemagick --- manifest.toml | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/manifest.toml b/manifest.toml index 00be1c9..09666cb 100644 --- a/manifest.toml +++ b/manifest.toml @@ -80,7 +80,7 @@ ram.runtime = "1G" "cmake", "g++", "gifsicle", - "imagemagick", + # "imagemagick", "jhead", "jpegoptim", "libapr1-dev", @@ -103,6 +103,17 @@ ram.runtime = "1G" "redis-server", "zlib1g-dev", + # Dependencies of imagemagick + "make", + "libltdl-dev", + "libbz2-dev", "zlib1g-dev", "libfreetype6-dev", "libjpeg-dev", "liblzma-dev", + "libwebp-dev", "libtiff-dev", "librsvg2-dev", + "libpng16-16", "libpng-dev", + "libjpeg62-turbo", "libjpeg62-turbo-dev", + "libheif1", "libheif-dev", + "libde265-0", "libde265-dev", + # ${LIBWEBP} + "postgresql", "postgresql-client", "postgresql-contrib", From 8b79775e15f83fa302f271615c8a94d2056db377 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Fri, 30 Aug 2024 11:01:26 +0200 Subject: [PATCH 13/21] Use sudo -E instead of --login --- scripts/install | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/scripts/install b/scripts/install index d1f97f2..f705ef3 100644 --- a/scripts/install +++ b/scripts/install @@ -131,13 +131,13 @@ pushd "$install_dir/discourse" if dpkg --print-architecture | grep -q "arm"; then # Define the platform specifically to retrieve binaries # for libv8 because it currently doesn't compile on ARM devices - ynh_exec_as "$app" --login "$install_dir/discourse/bin/bundle" config specific_platform arm-linux + ynh_exec_as "$app" -E "$install_dir/discourse/bin/bundle" config specific_platform arm-linux fi # Install dependencies - ynh_exec_as "$app" --login "$install_dir/discourse/bin/bundle" config set path 'vendor/bundle' - ynh_exec_as "$app" --login "$install_dir/discourse/bin/bundle" config set without test development - ynh_exec_as "$app" --login MAKEFLAGS=-j2 "$install_dir/discourse/bin/bundle" install --jobs 2 + ynh_exec_as "$app" -E "$install_dir/discourse/bin/bundle" config set path 'vendor/bundle' + ynh_exec_as "$app" -E "$install_dir/discourse/bin/bundle" config set without test development + ynh_exec_as "$app" -E MAKEFLAGS=-j2 "$install_dir/discourse/bin/bundle" install --jobs 2 popd pushd "$install_dir/discourse" @@ -154,8 +154,8 @@ popd ynh_script_progression --message="Preparing the database..." pushd "$install_dir/discourse" - ynh_exec_warn_less ynh_exec_as "$app" --login RAILS_ENV=production "$install_dir/discourse/bin/bundle" exec rake db:migrate - ynh_exec_warn_less ynh_exec_as "$app" --login RAILS_ENV=production "$install_dir/discourse/bin/bundle" exec rake themes:update assets:precompile + ynh_exec_warn_less ynh_exec_as "$app" -E RAILS_ENV=production "$install_dir/discourse/bin/bundle" exec rake db:migrate + ynh_exec_warn_less ynh_exec_as "$app" -E RAILS_ENV=production "$install_dir/discourse/bin/bundle" exec rake themes:update assets:precompile popd # Set default data (especially to have correct image URLs for subfolder install) @@ -169,7 +169,7 @@ ynh_secure_remove --file="$install_dir/provisioning.sql" ynh_script_progression --message="Creating Discourse admin user..." pushd "$install_dir/discourse" - ynh_exec_as "$app" --login RAILS_ENV=production bin/rake admin:create <<< "$admin_mail + ynh_exec_as "$app" -E RAILS_ENV=production bin/rake admin:create <<< "$admin_mail $admin_pwd $admin_pwd y From 74f05908e4115f553bc87c95d1825ed54b5e5a68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Fri, 30 Aug 2024 11:22:21 +0200 Subject: [PATCH 14/21] Wrapper to exec_as with ruby and node in env --- scripts/_common.sh | 4 ++++ scripts/change_url | 6 +++--- scripts/install | 18 +++++++++--------- scripts/upgrade | 16 ++++++++-------- 4 files changed, 24 insertions(+), 20 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 41f92a5..66f538b 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -14,6 +14,10 @@ libjemalloc="$(ldconfig -p | grep libjemalloc | awk 'END {print $NF}')" # PERSONAL HELPERS #================================================= +_exec_as_app_with_ruby_node() { + ynh_exec_as "$app" -E env PATH="$nodejs_path:$ruby_path:$PATH" "$@" +} + # Returns true if a swap partition is enabled, false otherwise # usage: is_swap_present is_swap_present() { diff --git a/scripts/change_url b/scripts/change_url index 6cd948b..9b2800f 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -46,15 +46,15 @@ UPDATE site_settings SET value = '${new_path}' WHERE name='long_polling_base_url ynh_use_ruby # Remap URLs in forum posts -ynh_exec_as "$app" --login RAILS_ENV=production "$install_dir/discourse/bin/bundle" exec script/discourse remap "$old_relative_url_root/uploads" "$new_relative_url_root/uploads" <<< "YES +_exec_as_app_with_ruby_node RAILS_ENV=production "$install_dir/discourse/bin/bundle" exec script/discourse remap "$old_relative_url_root/uploads" "$new_relative_url_root/uploads" <<< "YES # " pushd "$install_dir/discourse" # Regenerate assets - ynh_exec_warn_less ynh_exec_as "$app" --login RAILS_ENV=production bin/rake assets:precompile + ynh_exec_warn_less _exec_as_app_with_ruby_node RAILS_ENV=production bin/rake assets:precompile # Regenerate all forum posts - ynh_exec_warn_less ynh_exec_as "$app" --login RAILS_ENV=production bin/rake posts:rebake + ynh_exec_warn_less _exec_as_app_with_ruby_node RAILS_ENV=production bin/rake posts:rebake popd #================================================= diff --git a/scripts/install b/scripts/install index f705ef3..7c17a94 100644 --- a/scripts/install +++ b/scripts/install @@ -131,21 +131,21 @@ pushd "$install_dir/discourse" if dpkg --print-architecture | grep -q "arm"; then # Define the platform specifically to retrieve binaries # for libv8 because it currently doesn't compile on ARM devices - ynh_exec_as "$app" -E "$install_dir/discourse/bin/bundle" config specific_platform arm-linux + _exec_as_app_with_ruby_node "$install_dir/discourse/bin/bundle" config specific_platform arm-linux fi # Install dependencies - ynh_exec_as "$app" -E "$install_dir/discourse/bin/bundle" config set path 'vendor/bundle' - ynh_exec_as "$app" -E "$install_dir/discourse/bin/bundle" config set without test development - ynh_exec_as "$app" -E MAKEFLAGS=-j2 "$install_dir/discourse/bin/bundle" install --jobs 2 + _exec_as_app_with_ruby_node "$install_dir/discourse/bin/bundle" config set path 'vendor/bundle' + _exec_as_app_with_ruby_node "$install_dir/discourse/bin/bundle" config set without test development + _exec_as_app_with_ruby_node MAKEFLAGS=-j2 "$install_dir/discourse/bin/bundle" install --jobs 2 popd pushd "$install_dir/discourse" ynh_use_nodejs ynh_npm install --location=global terser ynh_npm install --location=global uglify-js - ynh_exec_warn_less ynh_exec_as "$app" "$ynh_node_load_PATH" yarn install --frozen-lockfile - ynh_exec_warn_less ynh_exec_as "$app" "$ynh_node_load_PATH" yarn cache clean + ynh_exec_warn_less _exec_as_app_with_ruby_node yarn install --frozen-lockfile + ynh_exec_warn_less _exec_as_app_with_ruby_node yarn cache clean popd #================================================= @@ -154,8 +154,8 @@ popd ynh_script_progression --message="Preparing the database..." pushd "$install_dir/discourse" - ynh_exec_warn_less ynh_exec_as "$app" -E RAILS_ENV=production "$install_dir/discourse/bin/bundle" exec rake db:migrate - ynh_exec_warn_less ynh_exec_as "$app" -E RAILS_ENV=production "$install_dir/discourse/bin/bundle" exec rake themes:update assets:precompile + ynh_exec_warn_less _exec_as_app_with_ruby_node RAILS_ENV=production "$install_dir/discourse/bin/bundle" exec rake db:migrate + ynh_exec_warn_less _exec_as_app_with_ruby_node RAILS_ENV=production "$install_dir/discourse/bin/bundle" exec rake themes:update assets:precompile popd # Set default data (especially to have correct image URLs for subfolder install) @@ -169,7 +169,7 @@ ynh_secure_remove --file="$install_dir/provisioning.sql" ynh_script_progression --message="Creating Discourse admin user..." pushd "$install_dir/discourse" - ynh_exec_as "$app" -E RAILS_ENV=production bin/rake admin:create <<< "$admin_mail + _exec_as_app_with_ruby_node RAILS_ENV=production bin/rake admin:create <<< "$admin_mail $admin_pwd $admin_pwd y diff --git a/scripts/upgrade b/scripts/upgrade index dc5f8ac..14a5645 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -152,13 +152,13 @@ popd if dpkg --print-architecture | grep -q "arm"; then # Define the platform specifically to retrieve binaries # for libv8 because it currently doesn't compile on ARM devices - ynh_exec_as "$app" --login "$install_dir/discourse/bin/bundle" config specific_platform arm-linux + _exec_as_app_with_ruby_node "$install_dir/discourse/bin/bundle" config specific_platform arm-linux fi # Install dependencies -ynh_exec_as "$app" --login "$install_dir/discourse/bin/bundle" config set path 'vendor/bundle' -ynh_exec_as "$app" --login "$install_dir/discourse/bin/bundle" config set with 'development' -ynh_exec_as "$app" --login MAKEFLAGS=-j2 "$install_dir/discourse/bin/bundle" install --jobs 2 +_exec_as_app_with_ruby_node "$install_dir/discourse/bin/bundle" config set path 'vendor/bundle' +_exec_as_app_with_ruby_node "$install_dir/discourse/bin/bundle" config set with 'development' +_exec_as_app_with_ruby_node MAKEFLAGS=-j2 "$install_dir/discourse/bin/bundle" install --jobs 2 # On ARM architecture, replace bundled libpsl by system native libpsl # because the provided binary isn't compatible @@ -174,8 +174,8 @@ pushd "$install_dir/discourse" ynh_use_nodejs ynh_npm install --location=global terser ynh_npm install --location=global uglify-js - ynh_exec_warn_less ynh_exec_as "$app" "$ynh_node_load_PATH" yarn install --production --frozen-lockfile - ynh_exec_warn_less ynh_exec_as "$app" "$ynh_node_load_PATH" yarn cache clean + ynh_exec_warn_less _exec_as_app_with_ruby_node yarn install --production --frozen-lockfile + ynh_exec_warn_less _exec_as_app_with_ruby_node yarn cache clean popd #================================================= @@ -185,8 +185,8 @@ popd ynh_script_progression --message="Preparing the database..." pushd "$install_dir/discourse" - ynh_exec_warn_less ynh_exec_as "$app" --login RAILS_ENV=production "$install_dir/discourse/bin/bundle" exec rake db:migrate - ynh_exec_warn_less ynh_exec_as "$app" --login RAILS_ENV=production "$install_dir/discourse/bin/bundle" exec rake themes:update assets:precompile + ynh_exec_warn_less _exec_as_app_with_ruby_node RAILS_ENV=production "$install_dir/discourse/bin/bundle" exec rake db:migrate + ynh_exec_warn_less _exec_as_app_with_ruby_node RAILS_ENV=production "$install_dir/discourse/bin/bundle" exec rake themes:update assets:precompile popd #================================================= From bd1620cd9edf6e1c43bd732fe461945203017f4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Fri, 30 Aug 2024 11:44:58 +0200 Subject: [PATCH 15/21] Remove support for <1.0 versions of brotli --- ...support-for-older-versions-of-brotli.patch | 29 ------------------- 1 file changed, 29 deletions(-) delete mode 100644 sources/patches/main-3-Re-add-support-for-older-versions-of-brotli.patch diff --git a/sources/patches/main-3-Re-add-support-for-older-versions-of-brotli.patch b/sources/patches/main-3-Re-add-support-for-older-versions-of-brotli.patch deleted file mode 100644 index 728758a..0000000 --- a/sources/patches/main-3-Re-add-support-for-older-versions-of-brotli.patch +++ /dev/null @@ -1,29 +0,0 @@ -diff --git a/lib/tasks/assets.rake b/lib/tasks/assets.rake -index 7b47f21658..ea6d0da2c4 100644 ---- a/lib/tasks/assets.rake -+++ b/lib/tasks/assets.rake -@@ -116,9 +116,21 @@ def gzip(path) - end - - # different brotli versions use different parameters --def brotli_command(path, max_compress) -- compression_quality = max_compress ? "11" : "6" -- "brotli -f --quality=#{compression_quality} #{path} --output=#{path}.br" -+ver_out, _ver_err, ver_status = Open3.capture3('brotli --version') -+if !ver_status.success? -+ # old versions of brotli don't respond to --version -+ def brotli_command(path, max_compress) -+ compression_quality = max_compress ? "11" : "6" -+ "brotli --quality 11 --input #{path} --output #{path}.br" -+ end -+elsif ver_out >= "brotli 1.0.0" -+ def brotli_command(path, max_compress) -+ compression_quality = max_compress ? "11" : "6" -+ "brotli -f --quality=11 #{path} --output=#{path}.br" -+ end -+else -+ # not sure what to do here, not expecting this -+ raise "cannot determine brotli version" - end - - def brotli(path, max_compress) From 19d4227e70a434185bf7f94f20fa13543abd402c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Fri, 30 Aug 2024 11:55:29 +0200 Subject: [PATCH 16/21] Update patches --- .../main-4-fix-missing-git-repository.patch | 48 +++++++++---------- ...ain-5-fix-admin-watched-words-action.patch | 18 +++++-- .../main-6-fix-download-calendar.patch | 18 +++---- sources/patches/main-7-fix-uppy-upload.patch | 24 +++++++--- 4 files changed, 63 insertions(+), 45 deletions(-) diff --git a/sources/patches/main-4-fix-missing-git-repository.patch b/sources/patches/main-4-fix-missing-git-repository.patch index 6e117d0..3cab00a 100644 --- a/sources/patches/main-4-fix-missing-git-repository.patch +++ b/sources/patches/main-4-fix-missing-git-repository.patch @@ -1,35 +1,31 @@ -From 2319de5a4759f17c11a6000779d1c8840c342771 Mon Sep 17 00:00:00 2001 +From 17a2d3241889c117ac5bb15d0609837592b16cb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= -Date: Fri, 26 Jul 2024 14:19:22 +0200 -Subject: [PATCH 2/3] Fix missing git commands in repository +Date: Fri, 30 Aug 2024 11:50:04 +0200 +Subject: [PATCH] Fix missing git commands in repository --- - lib/discourse.rb | 5 +++-- + lib/git_utils.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) -diff --git a/lib/discourse.rb b/lib/discourse.rb -index 1af04378..6207c8f5 100644 ---- a/lib/discourse.rb -+++ b/lib/discourse.rb -@@ -842,7 +842,7 @@ module Discourse - @full_version ||= - begin - git_cmd = 'git describe --dirty --match "v[0-9]*" 2> /dev/null' -- self.try_git(git_cmd, "unknown") -+ self.try_git(git_cmd, Discourse::VERSION::STRING) - end +diff --git a/lib/git_utils.rb b/lib/git_utils.rb +index fb664fe2..aa81fd2d 100644 +--- a/lib/git_utils.rb ++++ b/lib/git_utils.rb +@@ -11,12 +11,13 @@ class GitUtils end -@@ -850,7 +850,8 @@ module Discourse - @last_commit_date ||= - begin - git_cmd = 'git log -1 --format="%ct"' -- seconds = self.try_git(git_cmd, nil) -+ # Note(decentral1se): Output from actual command in the v3.2.4 branch -+ seconds = self.try_git(git_cmd, '1721046633') - seconds.nil? ? nil : DateTime.strptime(seconds, "%s") - end + def self.full_version +- self.try_git('git describe --dirty --match "v[0-9]*" 2> /dev/null', "unknown") ++ self.try_git('git describe --dirty --match "v[0-9]*" 2> /dev/null', Discourse::VERSION::STRING) end + + def self.last_commit_date + git_cmd = 'git log -1 --format="%ct"' +- seconds = self.try_git(git_cmd, nil) ++ # Note(decentral1se): Output from actual command in the v3.2.4 branch ++ seconds = self.try_git(git_cmd, '1721046633') + seconds.nil? ? nil : DateTime.strptime(seconds, "%s") + end + -- -2.45.2 - +2.43.0 diff --git a/sources/patches/main-5-fix-admin-watched-words-action.patch b/sources/patches/main-5-fix-admin-watched-words-action.patch index a431d71..36125b3 100644 --- a/sources/patches/main-5-fix-admin-watched-words-action.patch +++ b/sources/patches/main-5-fix-admin-watched-words-action.patch @@ -1,8 +1,17 @@ +From 714ba4449257b3770dfe991b1a19bda0b147d56e Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= +Date: Fri, 30 Aug 2024 11:52:09 +0200 +Subject: [PATCH] Fix admin-watched-words-action.js + +--- + .../admin/addon/controllers/admin-watched-words-action.js | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + diff --git a/app/assets/javascripts/admin/addon/controllers/admin-watched-words-action.js b/app/assets/javascripts/admin/addon/controllers/admin-watched-words-action.js -index 2b53a91eb3..eec55647d5 100644 +index d5ad0c49..faeb04ab 100644 --- a/app/assets/javascripts/admin/addon/controllers/admin-watched-words-action.js +++ b/app/assets/javascripts/admin/addon/controllers/admin-watched-words-action.js -@@ -32,9 +32,9 @@ +@@ -37,7 +37,7 @@ export default class AdminWatchedWordsActionController extends Controller { for (const { regexp, word } of words) { try { RegExp(regexp); @@ -11,5 +20,6 @@ index 2b53a91eb3..eec55647d5 100644 return I18n.t("admin.watched_words.invalid_regex", { word }); } } - }, - +-- +2.43.0 + diff --git a/sources/patches/main-6-fix-download-calendar.patch b/sources/patches/main-6-fix-download-calendar.patch index 132ca9c..0f34f43 100644 --- a/sources/patches/main-6-fix-download-calendar.patch +++ b/sources/patches/main-6-fix-download-calendar.patch @@ -1,25 +1,25 @@ -From e515c68e1011d42f5fd817a799f4694fb469eea2 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= -Date: Fri, 26 Jul 2024 14:20:17 +0200 -Subject: [PATCH 3/3] Fix download calendar +From c4f4fb51b0b12c520bf78870842c4c0034296323 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= +Date: Fri, 30 Aug 2024 11:53:46 +0200 +Subject: [PATCH] Fix download-calendar.js --- app/assets/javascripts/discourse/app/lib/download-calendar.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/assets/javascripts/discourse/app/lib/download-calendar.js b/app/assets/javascripts/discourse/app/lib/download-calendar.js -index 238a8cf0..541b6b1b 100644 +index 3fd2951a..b71e4e09 100644 --- a/app/assets/javascripts/discourse/app/lib/download-calendar.js +++ b/app/assets/javascripts/discourse/app/lib/download-calendar.js -@@ -23,7 +23,7 @@ export function downloadCalendar(title, dates, recurrenceRule = null) { +@@ -23,7 +23,7 @@ export function downloadCalendar(title, dates, options = {}) { } - export function downloadIcs(title, dates, recurrenceRule) { + export function downloadIcs(title, dates, options = {}) { - const REMOVE_FILE_AFTER = 20_000; + const REMOVE_FILE_AFTER = 20000; - const file = new File([generateIcsData(title, dates, recurrenceRule)], { + const file = new File([generateIcsData(title, dates, options)], { type: "text/plain", }); -- -2.45.2 +2.43.0 diff --git a/sources/patches/main-7-fix-uppy-upload.patch b/sources/patches/main-7-fix-uppy-upload.patch index 6af3580..9b19083 100644 --- a/sources/patches/main-7-fix-uppy-upload.patch +++ b/sources/patches/main-7-fix-uppy-upload.patch @@ -1,13 +1,25 @@ +From c1dc85c042033cd689346d0bf6e747a97f4c4e7e Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= +Date: Fri, 30 Aug 2024 11:55:03 +0200 +Subject: [PATCH] Fix uppy-upload.js + +--- + app/assets/javascripts/discourse/app/mixins/uppy-upload.js | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + diff --git a/app/assets/javascripts/discourse/app/mixins/uppy-upload.js b/app/assets/javascripts/discourse/app/mixins/uppy-upload.js -index 2b53a91eb3..eec55647d5 100644 +index ff2a0e95..50be945e 100644 --- a/app/assets/javascripts/discourse/app/mixins/uppy-upload.js +++ b/app/assets/javascripts/discourse/app/mixins/uppy-upload.js -@@ -21,7 +21,7 @@ - import { warn } from "@ember/debug"; - import bootbox from "bootbox"; +@@ -23,7 +23,7 @@ import { deepMerge } from "discourse-common/lib/object"; + import { bind, on } from "discourse-common/utils/decorators"; + import I18n from "discourse-i18n"; -export const HUGE_FILE_THRESHOLD_BYTES = 104_857_600; // 100MB +export const HUGE_FILE_THRESHOLD_BYTES = "104_857_600"; // 100MB - export default Mixin.create(UppyS3Multipart, { - uploading: false, + export default Mixin.create(UppyS3Multipart, ExtendableUploader, { + dialog: service(), +-- +2.43.0 + From f82973aebda6fb8e6890b178b8d254c4c3bab2b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Fri, 30 Aug 2024 13:28:43 +0200 Subject: [PATCH 17/21] Ensure Discourse v3 is only available on bookworm --- manifest.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.toml b/manifest.toml index 09666cb..00e782c 100644 --- a/manifest.toml +++ b/manifest.toml @@ -19,7 +19,7 @@ code = "https://github.com/discourse/discourse" cpe = "cpe:2.3:a:discourse:discourse" [integration] -yunohost = ">=11.2.27" +yunohost = ">=12.0.1" architectures = "all" multi_instance = true ldap = true From c8c6ece943a2d4ce45aa6021dc6342091520667d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Fri, 30 Aug 2024 13:28:50 +0200 Subject: [PATCH 18/21] Fix the install dir of the ldap plugin --- scripts/install | 7 ++++--- scripts/upgrade | 11 ++++++++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/scripts/install b/scripts/install index 7c17a94..6b9ce5e 100644 --- a/scripts/install +++ b/scripts/install @@ -79,7 +79,8 @@ fi ynh_setup_source --dest_dir="$install_dir/discourse" # Install LDAP plugin -ynh_setup_source --source_id=ldap-auth --dest_dir="$install_dir/discourse/plugins/discourse-ldap-auth" +# See https://github.com/jonmbake/discourse-ldap-auth/issues/77 +ynh_setup_source --source_id=ldap-auth --dest_dir="$install_dir/discourse/plugins/ldap" # Add a pids and socket directory for the systemd script. mkdir -p "$install_dir/discourse/tmp/pids" @@ -101,7 +102,7 @@ ynh_script_progression --message="Adding $app's configuration file..." ynh_add_config --template="discourse_defaults.conf" --destination="$install_dir/discourse/config/discourse.conf" ynh_add_config --template="secrets.yml" --destination="$install_dir/discourse/config/secrets.yml" -ynh_add_config --template="settings.yml" --destination="$install_dir/discourse/plugins/discourse-ldap-auth/config/settings.yml" +ynh_add_config --template="settings.yml" --destination="$install_dir/discourse/plugins/ldap/config/settings.yml" # Disable svgo worker echo "svgo: false" | ynh_exec_as "$app" tee "$install_dir/discourse/.image_optim.yml" >/dev/null @@ -184,7 +185,7 @@ ynh_script_progression --message="Configuring plugins..." # Patch ldap-auth plugin dependency (omniauth-ldap) to fix it when using domain subfolder # (Can only do that now because we are patching dependencies which have just been downloaded) # Patch applied: https://github.com/omniauth/omniauth-ldap/pull/16 -patch -p1 -d "$install_dir/discourse/plugins/discourse-ldap-auth/gems/$ruby_version/gems/omniauth-ldap"*/ \ +patch -p1 -d "$install_dir/discourse/plugins/ldap/gems/$ruby_version/gems/omniauth-ldap"*/ \ < "../conf/ldap-auth-fix-subfolder.patch" #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 14a5645..b5c178c 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -58,6 +58,11 @@ if [ -f "$install_dir/tmp/sockets/unicorn.sock" ]; then mv "$install_dir/__new__" "$install_dir/discourse" fi +# See https://github.com/jonmbake/discourse-ldap-auth/issues/77 +if [ -d "$install_dir/discourse/plugins/discourse-ldap-auth" ]; then + mv "$install_dir/discourse/plugins/discourse-ldap-auth" "$install_dir/discourse/plugins/ldap" +fi + #================================================= # UPGRADING DEPENDENCIES #================================================= @@ -99,7 +104,7 @@ done ynh_secure_remove --file="$install_dir/discourse/plugins_old" # Install LDAP plugin -ynh_setup_source --source_id=ldap-auth --dest_dir="$install_dir/discourse/plugins/discourse-ldap-auth" --full_replace=1 \ +ynh_setup_source --source_id=ldap-auth --dest_dir="$install_dir/discourse/plugins/ldap" --full_replace=1 \ --keep="config/settings.yml" # Add a pids and socket directory for the systemd script. @@ -123,7 +128,7 @@ ynh_script_progression --message="Updating $app's config file..." ynh_add_config --template="discourse_defaults.conf" --destination="$install_dir/discourse/config/discourse.conf" ynh_add_config --template="secrets.yml" --destination="$install_dir/discourse/config/secrets.yml" -ynh_add_config --template="settings.yml" --destination="$install_dir/discourse/plugins/discourse-ldap-auth/config/settings.yml" +ynh_add_config --template="settings.yml" --destination="$install_dir/discourse/plugins/ldap/config/settings.yml" # Disable svgo worker echo "svgo: false" | ynh_exec_as "$app" tee "$install_dir/discourse/.image_optim.yml" >/dev/null @@ -197,7 +202,7 @@ ynh_script_progression --message="Configuring plugins..." # Patch ldap-auth plugin dependency (omniauth-ldap) to fix it when using domain subfolder # (Can only do that now because we are patching dependencies which have just been downloaded) # Patch applied: https://github.com/omniauth/omniauth-ldap/pull/16 -patch -p1 -d "$install_dir/discourse/plugins/discourse-ldap-auth/gems/$ruby_version/gems/omniauth-ldap"*/ \ +patch -p1 -d "$install_dir/discourse/plugins/ldap/gems/$ruby_version/gems/omniauth-ldap"*/ \ < "../conf/ldap-auth-fix-subfolder.patch" #================================================= From 411a6be993363823a3b71cd5c6eb6ce4d244bd8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Fri, 30 Aug 2024 13:41:05 +0200 Subject: [PATCH 19/21] Rename magick_prefix tools_prefix --- conf/systemd.service | 2 +- scripts/_common.sh | 13 +++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/conf/systemd.service b/conf/systemd.service index 1a57b4b..6f17727 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -14,7 +14,7 @@ Environment=RAILS_ENV=production Environment=UNICORN_SIDEKIQS=1 Environment=LD_PRELOAD=__LIBJEMALLOC__ Environment=UNICORN_LISTENER=__INSTALL_DIR__/discourse/tmp/sockets/unicorn.sock -Environment="__YNH_RUBY_LOAD_PATH__:__MAGICK_PREFIX__/bin" +Environment="__YNH_RUBY_LOAD_PATH__:__TOOLS_PREFIX__/bin" ExecStart=__INSTALL_DIR__/discourse/bin/bundle exec unicorn --config config/unicorn.conf.rb -E production Restart=always RestartSec=10 diff --git a/scripts/_common.sh b/scripts/_common.sh index 66f538b..b201d92 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -59,17 +59,18 @@ check_memory_requirements_upgrade() { fi } -magick_prefix="$install_dir/imagemagick" -# See https://github.com/discourse/discourse_docker/blob/main/image/base/install-imagemagick +tools_prefix="$install_dir/dependencies" + install_imagemagick() { + # See https://github.com/discourse/discourse_docker/blob/main/image/base/install-imagemagick ynh_setup_source --source_id="imagemagickv7" --dest_dir="$install_dir/imagemagick_source" - mkdir -p "$magick_prefix" - chown -R "$app:$app" "$install_dir/imagemagick_source" "$magick_prefix" + mkdir -p "$tools_prefix" + chown -R "$app:$app" "$install_dir/imagemagick_source" "$tools_prefix" pushd "$install_dir/imagemagick_source" - ynh_exec_as "$app" CFLAGS="-O2 -I$magick_prefix/include -Wno-deprecated-declarations" \ + ynh_exec_as "$app" CFLAGS="-O2 -I$tools_prefix/include -Wno-deprecated-declarations" \ ./configure \ - --prefix="$magick_prefix" \ + --prefix="$tools_prefix" \ --enable-static \ --enable-bounds-checking \ --enable-hdri \ From 255d41a0e7905cf023842fbbc2b74c90ca3370af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Fri, 30 Aug 2024 13:41:34 +0200 Subject: [PATCH 20/21] Install oxipng, cleanup magick after install --- manifest.toml | 12 ++++++++++++ scripts/_common.sh | 8 ++++++++ scripts/install | 5 +++-- scripts/upgrade | 5 +++++ 4 files changed, 28 insertions(+), 2 deletions(-) diff --git a/manifest.toml b/manifest.toml index 00e782c..4e99e5d 100644 --- a/manifest.toml +++ b/manifest.toml @@ -66,6 +66,18 @@ ram.runtime = "1G" autoupdate.strategy = "latest_github_tag" autoupdate.upstream = "https://github.com/ImageMagick/ImageMagick" + [resources.sources.oxipng] + amd64.url = "https://github.com/shssoichiro/oxipng/releases/download/v9.1.2/oxipng-9.1.2-x86_64-unknown-linux-gnu.tar.gz" + amd64.sha256 = "6d47453f623d7d12499e206fe089fe96d76bc6f01a00962b91e4ee3e6845e1a6" + + arm64.url = "https://github.com/shssoichiro/oxipng/releases/download/v9.1.2/oxipng-9.1.2-aarch64-unknown-linux-gnu.tar.gz" + arm64.sha256 = "9716b3aba89e7ed9fa9fa07aef4867a7b65a9dd26516e6b16f8ae5a56006cafa" + + autoupdate.strategy = "latest_github_release" + autoupdate.upstream = "https://github.com/shssoichiro/oxipng" + autoupdate.asset.amd64 = "^oxipng-.*-x86_64-unknown-linux-gnu\\.tar\\.gz$" + autoupdate.asset.arm64 = "^oxipng-.*-aarch64-unknown-linux-gnu\\.tar\\.gz$" + [resources.system_user] [resources.install_dir] diff --git a/scripts/_common.sh b/scripts/_common.sh index b201d92..0ccc74f 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -94,6 +94,14 @@ install_imagemagick() { ynh_exec_as "$app" make all -j"$(nproc)" ynh_exec_as "$app" LIBTOOLFLAGS=-Wnone make install popd + ynh_secure_remove --file="$install_dir/imagemagick_source" +} + +install_oxipng() { + ynh_setup_source --source_id="oxipng" --dest_dir="$install_dir/oxipng_source" + mkdir -p "$tools_prefix/bin" + mv "$install_dir/oxipng_source/oxipng" "$tools_prefix/bin/oxipng" + ynh_secure_remove --file="$install_dir/oxipng_source" } ynh_maintenance_mode_ON () { diff --git a/scripts/install b/scripts/install index 6b9ce5e..97283dc 100644 --- a/scripts/install +++ b/scripts/install @@ -41,17 +41,18 @@ ynh_app_setting_set --app="$app" --key=unicorn_workers --value=$unicorn_workers # INSTALL DEPENDENCIES #================================================= ynh_script_progression --message="Installing Ruby..." - ynh_exec_warn_less ynh_install_ruby --ruby_version="$ruby_version" ynh_use_ruby ynh_script_progression --message="Installing NodeJS..." - ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version ynh_script_progression --message="Building and installing ImageMagick v7..." install_imagemagick +ynh_script_progression --message="Installing Oxipng..." +install_oxipng + #================================================= # CONFIGURE A POSTGRESQL DATABASE #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index b5c178c..a4d6342 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -72,6 +72,11 @@ ynh_exec_warn_less ynh_install_ruby --ruby_version="$ruby_version" ynh_script_progression --message="Upgrading NodeJS..." ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version +ynh_script_progression --message="Building and upgrading ImageMagick v7..." +install_imagemagick + +ynh_script_progression --message="Upgrading Oxipng..." +install_oxipng #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= From a00f2085684c55c0e1e785f27094fb1dcf8a4ab6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Fri, 30 Aug 2024 15:00:35 +0200 Subject: [PATCH 21/21] Fix systemd_action: the wrong log file was used --- scripts/change_url | 2 +- scripts/install | 2 +- scripts/restore | 2 +- scripts/upgrade | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/change_url b/scripts/change_url index 9b2800f..6ec3fdd 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -63,7 +63,7 @@ popd ynh_script_progression --message="Starting $app's systemd service..." # Start a systemd service -ynh_systemd_action --service_name="$app" --action="start" --log_path="$install_dir/discourse/log/unicorn.stderr.log" --line_match="INFO -- : worker=$((unicorn_workers-1)) ready" +ynh_systemd_action --service_name="$app" --action="start" --log_path="$install_dir/discourse/log/unicorn.stdout.log" --line_match="INFO -- : worker=$((unicorn_workers-1)) ready" #================================================= # END OF SCRIPT diff --git a/scripts/install b/scripts/install index 97283dc..5e9d206 100644 --- a/scripts/install +++ b/scripts/install @@ -220,7 +220,7 @@ ynh_use_logrotate --logfile="$install_dir/discourse/log/production.log" ynh_script_progression --message="Starting $app's systemd service..." # Start a systemd service -ynh_systemd_action --service_name="$app" --action="start" --log_path="$install_dir/discourse/log/unicorn.stderr.log" --line_match="INFO -- : worker=$((unicorn_workers-1)) ready" +ynh_systemd_action --service_name="$app" --action="start" --log_path="$install_dir/discourse/log/unicorn.stdout.log" --line_match="INFO -- : worker=$((unicorn_workers-1)) ready" #================================================= # END OF SCRIPT diff --git a/scripts/restore b/scripts/restore index fda5870..4119d81 100644 --- a/scripts/restore +++ b/scripts/restore @@ -70,7 +70,7 @@ ynh_restore_file --origin_path="/etc/logrotate.d/$app" #================================================= ynh_script_progression --message="Reloading NGINX web server and $app's service..." --weight=1 -ynh_systemd_action --service_name="$app" --action="start" --log_path="$install_dir/discourse/log/unicorn.stderr.log" --line_match="INFO -- : worker=$((unicorn_workers-1)) ready" +ynh_systemd_action --service_name="$app" --action="start" --log_path="$install_dir/discourse/log/unicorn.stdout.log" --line_match="INFO -- : worker=$((unicorn_workers-1)) ready" ynh_systemd_action --service_name=nginx --action=reload diff --git a/scripts/upgrade b/scripts/upgrade index a4d6342..55d5c33 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -32,7 +32,7 @@ ynh_maintenance_mode_ON #================================================= ynh_script_progression --message="Stopping a systemd service..." -ynh_systemd_action --service_name="$app" --action="stop" --log_path="$install_dir/discourse/log/unicorn.stderr.log" +ynh_systemd_action --service_name="$app" --action="stop" --log_path="$install_dir/discourse/log/unicorn.stdout.log" #================================================= # ENSURE DOWNWARD COMPATIBILITY @@ -239,7 +239,7 @@ ynh_use_logrotate --logfile="$install_dir/discourse/log/production.log" #================================================= ynh_script_progression --message="Starting $app's systemd service..." -ynh_systemd_action --service_name="$app" --action="start" --log_path="$install_dir/discourse/log/unicorn.stderr.log" --line_match="INFO -- : worker=$((unicorn_workers-1)) ready" +ynh_systemd_action --service_name="$app" --action="start" --log_path="$install_dir/discourse/log/unicorn.stdout.log" --line_match="INFO -- : worker=$((unicorn_workers-1)) ready" #================================================= # DISABLE MAINTENANCE MODE