mirror of
https://github.com/YunoHost-Apps/discourse_ynh.git
synced 2024-09-03 18:26:18 +02:00
v2
This commit is contained in:
parent
cc52378ad4
commit
c29cb2dd26
12 changed files with 560 additions and 497 deletions
|
@ -1,7 +0,0 @@
|
|||
SOURCE_URL=https://github.com/discourse/discourse/archive/v2.8.14.tar.gz
|
||||
SOURCE_SUM=b4b9a2857515ab79b2bc71cc0bdd09f9bf749d506c095b76d86846c9adf62623
|
||||
SOURCE_SUM_PRG=sha256sum
|
||||
SOURCE_FORMAT=tar.gz
|
||||
SOURCE_IN_SUBDIR=true
|
||||
SOURCE_FILENAME=
|
||||
SOURCE_EXTRACT=true
|
|
@ -1,3 +0,0 @@
|
|||
SOURCE_URL=https://github.com/jonmbake/discourse-ldap-auth/archive/v0.6.0.tar.gz
|
||||
SOURCE_SUM=1f64f90f648f53b40608912221adb60d86c8c13856aaba68c645cd88279445d4
|
||||
SOURCE_FORMAT=tar.gz
|
426
conf/nginx.conf
426
conf/nginx.conf
|
@ -1,213 +1,213 @@
|
|||
# maximum file upload size (keep up to date when changing the corresponding site setting)
|
||||
client_max_body_size 10m;
|
||||
|
||||
# extend timeouts
|
||||
proxy_connect_timeout 600;
|
||||
proxy_send_timeout 600;
|
||||
proxy_read_timeout 600;
|
||||
send_timeout 600;
|
||||
|
||||
# path to discourse's public directory
|
||||
set $public __FINALPATH__/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
|
||||
# use dates, it solves the problem fine even cross server
|
||||
etag off;
|
||||
|
||||
# prevent direct download of backups
|
||||
location ^~ __PATH__/backups/ {
|
||||
internal;
|
||||
}
|
||||
|
||||
# bypass rails stack with a cheap 204 for favicon.ico requests
|
||||
location __PATH__/favicon.ico {
|
||||
return 204;
|
||||
access_log off;
|
||||
log_not_found off;
|
||||
}
|
||||
|
||||
#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent;
|
||||
location __PATH__/ {
|
||||
alias __FINALPATH__/public/ ;
|
||||
proxy_hide_header ETag;
|
||||
|
||||
# auth_basic on;
|
||||
# auth_basic_user_file /etc/nginx/htpasswd;
|
||||
|
||||
# Include SSOWAT user panel.
|
||||
include conf.d/yunohost_panel.conf.inc;
|
||||
|
||||
|
||||
location ~* (assets|plugins|uploads)/.*\.(eot|ttf|woff|woff2|ico)$ {
|
||||
expires 1y;
|
||||
more_set_headers "Cache-Control : public,immutable";
|
||||
more_set_headers "Access-Control-Allow-Origin : *";
|
||||
}
|
||||
|
||||
location = __PATH__/srv/status {
|
||||
access_log off;
|
||||
log_not_found off;
|
||||
proxy_set_header Host $http_host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
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:__FINALPATH__/tmp/sockets/unicorn.sock;
|
||||
break;
|
||||
}
|
||||
|
||||
# some minimal caching here so we don't keep asking
|
||||
# longer term we should increas probably to 1y
|
||||
location ~ ^/javascripts/ {
|
||||
expires 1d;
|
||||
more_set_headers "Cache-Control : public,immutable";
|
||||
}
|
||||
|
||||
location ~ ^/assets/(?<asset_path>.+)$ {
|
||||
expires 1y;
|
||||
# asset pipeline enables this
|
||||
# brotli_static on;
|
||||
gzip_static on;
|
||||
more_set_headers "Cache-Control : public,immutable";
|
||||
# HOOK in asset location (used for extensibility)
|
||||
# TODO I don't think this break is needed, it just breaks out of rewrite
|
||||
break;
|
||||
}
|
||||
|
||||
location ~ ^/plugins/ {
|
||||
expires 1y;
|
||||
more_set_headers "Cache-Control : public,immutable";
|
||||
}
|
||||
|
||||
# cache emojis
|
||||
location ~ /images/emoji/ {
|
||||
expires 1y;
|
||||
more_set_headers "Cache-Control : public,immutable";
|
||||
}
|
||||
|
||||
location ~ ^/uploads/ {
|
||||
|
||||
# NOTE: it is really annoying that we can't just define headers
|
||||
# at the top level and inherit.
|
||||
#
|
||||
# proxy_set_header DOES NOT inherit, by design, we must repeat it,
|
||||
# otherwise headers are not set correctly
|
||||
proxy_set_header Host $http_host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
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_set_header X-Sendfile-Type X-Accel-Redirect;
|
||||
proxy_set_header X-Accel-Mapping __FINALPATH__/public/=/downloads/;
|
||||
expires 1y;
|
||||
more_set_headers "Cache-Control : public,immutable";
|
||||
|
||||
## optional upload anti-hotlinking rules
|
||||
#valid_referers none blocked mysite.com *.mysite.com;
|
||||
#if ($invalid_referer) { return 403; }
|
||||
|
||||
# custom CSS
|
||||
location ~ /stylesheet-cache/ {
|
||||
try_files $uri =404;
|
||||
}
|
||||
# this allows us to bypass rails
|
||||
location ~* \.(gif|png|jpg|jpeg|bmp|tif|tiff|svg|ico|webp)$ {
|
||||
try_files $uri =404;
|
||||
}
|
||||
# thumbnails & optimized images
|
||||
location ~ /_?optimized/ {
|
||||
try_files $uri =404;
|
||||
}
|
||||
|
||||
proxy_pass http://unix:__FINALPATH__/tmp/sockets/unicorn.sock;
|
||||
break;
|
||||
}
|
||||
|
||||
location ~ ^/admin/backups/ {
|
||||
proxy_set_header Host $http_host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
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_set_header X-Sendfile-Type X-Accel-Redirect;
|
||||
proxy_set_header X-Accel-Mapping __FINALPATH__/public/=/downloads/;
|
||||
proxy_pass http://unix:__FINALPATH__/tmp/sockets/unicorn.sock;
|
||||
break;
|
||||
}
|
||||
|
||||
# This big block is needed so we can selectively enable
|
||||
# acceleration for backups and avatars
|
||||
# see note about repetition above
|
||||
location ~ ^/(letter_avatar/|user_avatar|highlight-js|stylesheets|favicon/proxied|service-worker) {
|
||||
proxy_set_header Host $http_host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
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;
|
||||
|
||||
# if Set-Cookie is in the response nothing gets cached
|
||||
# this is double bad cause we are not passing last modified in
|
||||
proxy_ignore_headers "Set-Cookie";
|
||||
proxy_hide_header "Set-Cookie";
|
||||
|
||||
# note x-accel-redirect can not be used with proxy_cache
|
||||
# proxy_cache one;
|
||||
proxy_cache_valid 200 301 302 7d;
|
||||
proxy_cache_valid any 1m;
|
||||
proxy_pass http://unix:__FINALPATH__/tmp/sockets/unicorn.sock;
|
||||
break;
|
||||
}
|
||||
|
||||
# location /letter_avatar_proxy/ {
|
||||
# # Don't send any client headers to the avatars service
|
||||
# proxy_method GET;
|
||||
# proxy_pass_request_headers off;
|
||||
# proxy_pass_request_body off;
|
||||
#
|
||||
# # Don't let cookies interrupt caching, and don't pass them to the
|
||||
# # client
|
||||
# proxy_ignore_headers "Set-Cookie";
|
||||
# proxy_hide_header "Set-Cookie";
|
||||
#
|
||||
# proxy_cache one;
|
||||
# proxy_cache_key $uri;
|
||||
# proxy_cache_valid 200 7d;
|
||||
# proxy_cache_valid 404 1m;
|
||||
# proxy_set_header Connection "";
|
||||
#
|
||||
# proxy_pass https://avatars.discourse.org/;
|
||||
# break;
|
||||
# }
|
||||
|
||||
# we need buffering off for message bus
|
||||
location __PATH__/message-bus/ {
|
||||
proxy_set_header X-Request-Start "t=${msec}";
|
||||
proxy_set_header Host $http_host;
|
||||
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_http_version 1.1;
|
||||
proxy_buffering off;
|
||||
proxy_pass http://unix:__FINALPATH__/tmp/sockets/unicorn.sock;
|
||||
break;
|
||||
}
|
||||
|
||||
# this means every file in public is tried first
|
||||
try_files $uri @__NAME__;
|
||||
}
|
||||
|
||||
location __PATH__/downloads/ {
|
||||
internal;
|
||||
alias __FINALPATH__/public/ ;
|
||||
}
|
||||
|
||||
location @__NAME__ {
|
||||
more_set_headers "Referrer-Policy : no-referrer-when-downgrade";
|
||||
proxy_set_header Host $http_host;
|
||||
proxy_set_header X-Request-Start "t=${msec}";
|
||||
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:__FINALPATH__/tmp/sockets/unicorn.sock;
|
||||
}
|
||||
# maximum file upload size (keep up to date when changing the corresponding site setting)
|
||||
client_max_body_size 10m;
|
||||
|
||||
# extend timeouts
|
||||
proxy_connect_timeout 600;
|
||||
proxy_send_timeout 600;
|
||||
proxy_read_timeout 600;
|
||||
send_timeout 600;
|
||||
|
||||
# path to discourse's public directory
|
||||
set $public __INSTALL_DIR__/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
|
||||
# use dates, it solves the problem fine even cross server
|
||||
etag off;
|
||||
|
||||
# prevent direct download of backups
|
||||
location ^~ __PATH__/backups/ {
|
||||
internal;
|
||||
}
|
||||
|
||||
# bypass rails stack with a cheap 204 for favicon.ico requests
|
||||
location __PATH__/favicon.ico {
|
||||
return 204;
|
||||
access_log off;
|
||||
log_not_found off;
|
||||
}
|
||||
|
||||
#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent;
|
||||
location __PATH__/ {
|
||||
alias __INSTALL_DIR__/public/ ;
|
||||
proxy_hide_header ETag;
|
||||
|
||||
# auth_basic on;
|
||||
# auth_basic_user_file /etc/nginx/htpasswd;
|
||||
|
||||
# Include SSOWAT user panel.
|
||||
include conf.d/yunohost_panel.conf.inc;
|
||||
|
||||
|
||||
location ~* (assets|plugins|uploads)/.*\.(eot|ttf|woff|woff2|ico)$ {
|
||||
expires 1y;
|
||||
more_set_headers "Cache-Control : public,immutable";
|
||||
more_set_headers "Access-Control-Allow-Origin : *";
|
||||
}
|
||||
|
||||
location = __PATH__/srv/status {
|
||||
access_log off;
|
||||
log_not_found off;
|
||||
proxy_set_header Host $http_host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
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;
|
||||
break;
|
||||
}
|
||||
|
||||
# some minimal caching here so we don't keep asking
|
||||
# longer term we should increas probably to 1y
|
||||
location ~ ^/javascripts/ {
|
||||
expires 1d;
|
||||
more_set_headers "Cache-Control : public,immutable";
|
||||
}
|
||||
|
||||
location ~ ^/assets/(?<asset_path>.+)$ {
|
||||
expires 1y;
|
||||
# asset pipeline enables this
|
||||
# brotli_static on;
|
||||
gzip_static on;
|
||||
more_set_headers "Cache-Control : public,immutable";
|
||||
# HOOK in asset location (used for extensibility)
|
||||
# TODO I don't think this break is needed, it just breaks out of rewrite
|
||||
break;
|
||||
}
|
||||
|
||||
location ~ ^/plugins/ {
|
||||
expires 1y;
|
||||
more_set_headers "Cache-Control : public,immutable";
|
||||
}
|
||||
|
||||
# cache emojis
|
||||
location ~ /images/emoji/ {
|
||||
expires 1y;
|
||||
more_set_headers "Cache-Control : public,immutable";
|
||||
}
|
||||
|
||||
location ~ ^/uploads/ {
|
||||
|
||||
# NOTE: it is really annoying that we can't just define headers
|
||||
# at the top level and inherit.
|
||||
#
|
||||
# proxy_set_header DOES NOT inherit, by design, we must repeat it,
|
||||
# otherwise headers are not set correctly
|
||||
proxy_set_header Host $http_host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
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_set_header X-Sendfile-Type X-Accel-Redirect;
|
||||
proxy_set_header X-Accel-Mapping __INSTALL_DIR__/public/=/downloads/;
|
||||
expires 1y;
|
||||
more_set_headers "Cache-Control : public,immutable";
|
||||
|
||||
## optional upload anti-hotlinking rules
|
||||
#valid_referers none blocked mysite.com *.mysite.com;
|
||||
#if ($invalid_referer) { return 403; }
|
||||
|
||||
# custom CSS
|
||||
location ~ /stylesheet-cache/ {
|
||||
try_files $uri =404;
|
||||
}
|
||||
# this allows us to bypass rails
|
||||
location ~* \.(gif|png|jpg|jpeg|bmp|tif|tiff|svg|ico|webp)$ {
|
||||
try_files $uri =404;
|
||||
}
|
||||
# thumbnails & optimized images
|
||||
location ~ /_?optimized/ {
|
||||
try_files $uri =404;
|
||||
}
|
||||
|
||||
proxy_pass http://unix:__INSTALL_DIR__/tmp/sockets/unicorn.sock;
|
||||
break;
|
||||
}
|
||||
|
||||
location ~ ^/admin/backups/ {
|
||||
proxy_set_header Host $http_host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
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_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;
|
||||
break;
|
||||
}
|
||||
|
||||
# This big block is needed so we can selectively enable
|
||||
# acceleration for backups and avatars
|
||||
# see note about repetition above
|
||||
location ~ ^/(letter_avatar/|user_avatar|highlight-js|stylesheets|favicon/proxied|service-worker) {
|
||||
proxy_set_header Host $http_host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
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;
|
||||
|
||||
# if Set-Cookie is in the response nothing gets cached
|
||||
# this is double bad cause we are not passing last modified in
|
||||
proxy_ignore_headers "Set-Cookie";
|
||||
proxy_hide_header "Set-Cookie";
|
||||
|
||||
# note x-accel-redirect can not be used with proxy_cache
|
||||
# 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;
|
||||
break;
|
||||
}
|
||||
|
||||
# location /letter_avatar_proxy/ {
|
||||
# # Don't send any client headers to the avatars service
|
||||
# proxy_method GET;
|
||||
# proxy_pass_request_headers off;
|
||||
# proxy_pass_request_body off;
|
||||
#
|
||||
# # Don't let cookies interrupt caching, and don't pass them to the
|
||||
# # client
|
||||
# proxy_ignore_headers "Set-Cookie";
|
||||
# proxy_hide_header "Set-Cookie";
|
||||
#
|
||||
# proxy_cache one;
|
||||
# proxy_cache_key $uri;
|
||||
# proxy_cache_valid 200 7d;
|
||||
# proxy_cache_valid 404 1m;
|
||||
# proxy_set_header Connection "";
|
||||
#
|
||||
# proxy_pass https://avatars.discourse.org/;
|
||||
# break;
|
||||
# }
|
||||
|
||||
# we need buffering off for message bus
|
||||
location __PATH__/message-bus/ {
|
||||
proxy_set_header X-Request-Start "t=${msec}";
|
||||
proxy_set_header Host $http_host;
|
||||
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_http_version 1.1;
|
||||
proxy_buffering off;
|
||||
proxy_pass http://unix:__INSTALL_DIR__/tmp/sockets/unicorn.sock;
|
||||
break;
|
||||
}
|
||||
|
||||
# this means every file in public is tried first
|
||||
try_files $uri @__NAME__;
|
||||
}
|
||||
|
||||
location __PATH__/downloads/ {
|
||||
internal;
|
||||
alias __INSTALL_DIR__/public/ ;
|
||||
}
|
||||
|
||||
location @__NAME__ {
|
||||
more_set_headers "Referrer-Policy : no-referrer-when-downgrade";
|
||||
proxy_set_header Host $http_host;
|
||||
proxy_set_header X-Request-Start "t=${msec}";
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -8,14 +8,14 @@ After=postgresql.service
|
|||
[Service]
|
||||
User=__APP__
|
||||
Group=__APP__
|
||||
WorkingDirectory=__FINALPATH__
|
||||
WorkingDirectory=__INSTALL_DIR__
|
||||
Environment=__ADDITIONAL_ENV__
|
||||
Environment=RAILS_ENV=production
|
||||
Environment=UNICORN_SIDEKIQS=1
|
||||
Environment=LD_PRELOAD=__LIBJEMALLOC__
|
||||
Environment=UNICORN_LISTENER=__FINALPATH__/tmp/sockets/unicorn.sock
|
||||
Environment=UNICORN_LISTENER=__INSTALL_DIR__/tmp/sockets/unicorn.sock
|
||||
Environment="__YNH_RUBY_LOAD_PATH__"
|
||||
ExecStart=__FINALPATH__/bin/bundle exec unicorn --config config/unicorn.conf.rb -E production
|
||||
ExecStart=__INSTALL_DIR__/bin/bundle exec unicorn --config config/unicorn.conf.rb -E production
|
||||
Restart=always
|
||||
RestartSec=10
|
||||
|
||||
|
|
71
manifest.toml
Normal file
71
manifest.toml
Normal file
|
@ -0,0 +1,71 @@
|
|||
packaging_format = 2
|
||||
|
||||
id = "discourse"
|
||||
name = "Discourse"
|
||||
description.en = "Discussion platform"
|
||||
description.fr = "Plateforme de discussion"
|
||||
|
||||
version = "2.8.14~ynh1"
|
||||
|
||||
maintainers = ["JimboJoe"]
|
||||
|
||||
[upstream]
|
||||
license = "GPL-2.0"
|
||||
website = "http://Discourse.org"
|
||||
demo = "https://try.discourse.org"
|
||||
code = "https://github.com/discourse/discourse"
|
||||
cpe = "???" # FIXME: optional but recommended if relevant, this is meant to contain the Common Platform Enumeration, which is sort of a standard id for applications defined by the NIST. In particular, Yunohost may use this is in the future to easily track CVE (=security reports) related to apps. The CPE may be obtained by searching here: https://nvd.nist.gov/products/cpe/search. For example, for Nextcloud, the CPE is 'cpe:2.3:a:nextcloud:nextcloud' (no need to include the version number)
|
||||
fund = "???" # FIXME: optional but recommended (or remove if irrelevant / not applicable). This is meant to be an URL where people can financially support this app, especially when its development is based on volunteers and/or financed by its community. YunoHost may later advertise it in the webadmin.
|
||||
|
||||
[integration]
|
||||
yunohost = ">= 4.3.0"
|
||||
architectures = "all" # FIXME: can be replaced by a list of supported archs using the dpkg --print-architecture nomenclature (amd64/i386/armhf/arm64), for example: ["amd64", "i386"]
|
||||
multi_instance = true
|
||||
ldap = "?" # FIXME: replace with true, false, or "not_relevant". Not to confuse with the "sso" key : the "ldap" key corresponds to wether or not a user *can* login on the app using its YunoHost credentials.
|
||||
sso = "?" # FIXME: replace with true, false, or "not_relevant". Not to confuse with the "ldap" key : the "sso" key corresponds to wether or not a user is *automatically logged-in* on the app when logged-in on the YunoHost portal.
|
||||
disk = "50M" # FIXME: replace with an **estimate** minimum disk requirement. e.g. 20M, 400M, 1G, ...
|
||||
ram.build = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ...
|
||||
ram.runtime = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ...
|
||||
|
||||
[install]
|
||||
[install.domain]
|
||||
# this is a generic question - ask strings are automatically handled by Yunohost's core
|
||||
type = "domain"
|
||||
|
||||
[install.path]
|
||||
# this is a generic question - ask strings are automatically handled by Yunohost's core
|
||||
type = "path"
|
||||
default = "/forum"
|
||||
|
||||
[install.init_main_permission]
|
||||
type = "group"
|
||||
default = "visitors"
|
||||
|
||||
[install.admin]
|
||||
# this is a generic question - ask strings are automatically handled by Yunohost's core
|
||||
type = "user"
|
||||
|
||||
[resources]
|
||||
[resources.sources]
|
||||
[resources.sources.ldap-auth]
|
||||
url = "https://github.com/jonmbake/discourse-ldap-auth/archive/v0.6.0.tar.gz"
|
||||
sha256 = "1f64f90f648f53b40608912221adb60d86c8c13856aaba68c645cd88279445d4"
|
||||
|
||||
[resources.sources.main]
|
||||
url = "https://github.com/discourse/discourse/archive/v2.8.14.tar.gz"
|
||||
sha256 = "b4b9a2857515ab79b2bc71cc0bdd09f9bf749d506c095b76d86846c9adf62623"
|
||||
|
||||
|
||||
[resources.system_user]
|
||||
|
||||
[resources.install_dir]
|
||||
|
||||
[resources.permissions]
|
||||
main.url = "/"
|
||||
[[resources.apt.extras]]
|
||||
repo = "deb https://dl.yarnpkg.com/debian/ stable main"
|
||||
key = "https://dl.yarnpkg.com/debian/pubkey.gpg"
|
||||
packages = "yarn"
|
||||
|
||||
[resources.database]
|
||||
type = "postgresql"
|
|
@ -5,9 +5,9 @@
|
|||
#=================================================
|
||||
|
||||
# dependencies used by the app
|
||||
#pkg_dependencies="g++ libjemalloc1|libjemalloc2 libjemalloc-dev zlib1g-dev libreadline-dev libpq-dev libssl-dev libyaml-dev libcurl4-dev libapr1-dev libxslt1-dev libxml2-dev vim imagemagick postgresql postgresql-server-dev-all postgresql-contrib optipng jhead jpegoptim gifsicle brotli"
|
||||
pkg_dependencies="postgresql postgresql-client postgresql-contrib imagemagick libjemalloc1|libjemalloc2"
|
||||
build_pkg_dependencies="libcurl4-openssl-dev libyaml-dev libxml2-dev libpq-dev libreadline-dev brotli libunwind-dev libtcmalloc-minimal4 cmake pngcrush pngquant advancecomp jhead jpegoptim libjpeg-turbo-progs optipng"
|
||||
#REMOVEME? #pkg_dependencies="g++ libjemalloc1|libjemalloc2 libjemalloc-dev zlib1g-dev libreadline-dev libpq-dev libssl-dev libyaml-dev libcurl4-dev libapr1-dev libxslt1-dev libxml2-dev vim imagemagick postgresql postgresql-server-dev-all postgresql-contrib optipng jhead jpegoptim gifsicle brotli"
|
||||
#REMOVEME? pkg_dependencies="postgresql postgresql-client postgresql-contrib imagemagick libjemalloc1|libjemalloc2"
|
||||
#REMOVEME? build_pkg_dependencies="libcurl4-openssl-dev libyaml-dev libxml2-dev libpq-dev libreadline-dev brotli libunwind-dev libtcmalloc-minimal4 cmake pngcrush pngquant advancecomp jhead jpegoptim libjpeg-turbo-progs optipng"
|
||||
|
||||
ruby_version="2.7.6"
|
||||
|
||||
|
@ -68,12 +68,12 @@ check_memory_requirements_upgrade() {
|
|||
}
|
||||
|
||||
ynh_maintenance_mode_ON () {
|
||||
# Load value of $path_url and $domain from the config if their not set
|
||||
if [ -z $path_url ]; then
|
||||
path_url=$(ynh_app_setting_get $app path)
|
||||
# Load value of $path and $domain from the config if their not set
|
||||
if [ -z $path ]; then
|
||||
#REMOVEME? path=$(ynh_app_setting_get $app path)
|
||||
fi
|
||||
if [ -z $domain ]; then
|
||||
domain=$(ynh_app_setting_get $app domain)
|
||||
#REMOVEME? domain=$(ynh_app_setting_get $app domain)
|
||||
fi
|
||||
|
||||
# Create an html to serve as maintenance notice
|
||||
|
@ -98,10 +98,10 @@ ynh_maintenance_mode_ON () {
|
|||
</html>" > "/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_url}_maintenance and fall on the maintenance notice
|
||||
rewrite ^${path_url}/(.*)$ ${path_url}_maintenance/? redirect;
|
||||
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_url}_maintenance/ {
|
||||
location ${path}_maintenance/ {
|
||||
alias /var/www/html/ ;
|
||||
|
||||
try_files maintenance.$app.html =503;
|
||||
|
@ -112,7 +112,7 @@ include conf.d/yunohost_panel.conf.inc;
|
|||
|
||||
# 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_url}/(.*)$ ${path_url}_maintenance/\$1? redirect;
|
||||
# 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.
|
||||
|
@ -122,16 +122,16 @@ include conf.d/yunohost_panel.conf.inc;
|
|||
}
|
||||
|
||||
ynh_maintenance_mode_OFF () {
|
||||
# Load value of $path_url and $domain from the config if their not set
|
||||
if [ -z $path_url ]; then
|
||||
path_url=$(ynh_app_setting_get $app path)
|
||||
# Load value of $path and $domain from the config if their not set
|
||||
if [ -z $path ]; then
|
||||
#REMOVEME? path=$(ynh_app_setting_get $app path)
|
||||
fi
|
||||
if [ -z $domain ]; then
|
||||
domain=$(ynh_app_setting_get $app domain)
|
||||
#REMOVEME? domain=$(ynh_app_setting_get $app domain)
|
||||
fi
|
||||
|
||||
# Rewrite the nginx config file to redirect from ${path_url}_maintenance to the real url of the app.
|
||||
echo "rewrite ^${path_url}_maintenance/(.*)$ ${path_url}/\$1 redirect;" > "/etc/nginx/conf.d/$domain.d/maintenance.$app.conf"
|
||||
# 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.
|
||||
|
@ -170,10 +170,10 @@ ruby_version_path="$rbenv_install_dir/versions"
|
|||
export RBENV_ROOT="$rbenv_install_dir"
|
||||
export rbenv_root="$rbenv_install_dir"
|
||||
|
||||
ruby_dependencies=""
|
||||
build_ruby_dependencies="libjemalloc-dev curl build-essential libreadline-dev zlib1g-dev libsqlite3-dev libssl-dev libxml2-dev libxslt-dev autoconf automake bison libtool"
|
||||
pkg_dependencies="$pkg_dependencies $ruby_dependencies"
|
||||
build_pkg_dependencies="$build_pkg_dependencies $build_ruby_dependencies"
|
||||
#REMOVEME? ruby_dependencies=""
|
||||
#REMOVEME? build_ruby_dependencies="libjemalloc-dev curl build-essential libreadline-dev zlib1g-dev libsqlite3-dev libssl-dev libxml2-dev libxslt-dev autoconf automake bison libtool"
|
||||
#REMOVEME? pkg_dependencies="$pkg_dependencies $ruby_dependencies"
|
||||
#REMOVEME? build_pkg_dependencies="$build_pkg_dependencies $build_ruby_dependencies"
|
||||
|
||||
# Load the version of Ruby for an app, and set variables.
|
||||
#
|
||||
|
@ -192,14 +192,14 @@ build_pkg_dependencies="$build_pkg_dependencies $build_ruby_dependencies"
|
|||
# However, $PATH is duplicated into $ruby_path to outlast any manipulation of $PATH
|
||||
# You can use the variable `$ynh_ruby_load_path` to quickly load your Ruby version
|
||||
# in $PATH for an usage into a separate script.
|
||||
# Exemple: $ynh_ruby_load_path $final_path/script_that_use_gem.sh`
|
||||
# Exemple: $ynh_ruby_load_path $install_dir/script_that_use_gem.sh`
|
||||
#
|
||||
#
|
||||
# Finally, to start a Ruby service with the correct version, 2 solutions
|
||||
# Either the app is dependent of Ruby or gem, but does not called it directly.
|
||||
# In such situation, you need to load PATH
|
||||
# `Environment="__YNH_RUBY_LOAD_PATH__"`
|
||||
# `ExecStart=__FINALPATH__/my_app`
|
||||
# `ExecStart=__INSTALL_DIR__/my_app`
|
||||
# You will replace __YNH_RUBY_LOAD_PATH__ with $ynh_ruby_load_path
|
||||
#
|
||||
# Or Ruby start the app directly, then you don't need to load the PATH variable
|
||||
|
@ -214,10 +214,10 @@ build_pkg_dependencies="$build_pkg_dependencies $build_ruby_dependencies"
|
|||
#
|
||||
# Requires YunoHost version 3.2.2 or higher.
|
||||
ynh_use_ruby () {
|
||||
ruby_version=$(ynh_app_setting_get --app=$app --key=ruby_version)
|
||||
#REMOVEME? ruby_version=$(ynh_app_setting_get --app=$app --key=ruby_version)
|
||||
|
||||
# Get the absolute path of this version of Ruby
|
||||
ruby_path="$ruby_version_path/$YNH_APP_INSTANCE_NAME/bin"
|
||||
#REMOVEME? ruby_path="$ruby_version_path/$YNH_APP_INSTANCE_NAME/bin"
|
||||
|
||||
# Allow alias to be used into bash script
|
||||
shopt -s expand_aliases
|
||||
|
@ -237,7 +237,7 @@ ynh_use_ruby () {
|
|||
ynh_ruby_load_path="PATH=$PATH"
|
||||
|
||||
# Sets the local application-specific Ruby version
|
||||
pushd $final_path
|
||||
pushd $install_dir
|
||||
$rbenv_install_dir/bin/rbenv local $ruby_version
|
||||
popd
|
||||
}
|
||||
|
@ -375,16 +375,16 @@ ynh_install_ruby () {
|
|||
CONFIGURE_OPTS="--disable-install-doc --with-jemalloc" MAKE_OPTS="-j2" rbenv install --skip-existing $final_ruby_version > /dev/null 2>&1
|
||||
|
||||
# Store ruby_version into the config of this app
|
||||
ynh_app_setting_set --app=$YNH_APP_INSTANCE_NAME --key=ruby_version --value=$final_ruby_version
|
||||
#REMOVEME? ynh_app_setting_set --app=$YNH_APP_INSTANCE_NAME --key=ruby_version --value=$final_ruby_version
|
||||
|
||||
# Remove app virtualenv
|
||||
if `rbenv alias --list | grep --quiet "$YNH_APP_INSTANCE_NAME " 1>/dev/null 2>&1`
|
||||
#REMOVEME? if `rbenv alias --list | grep --quiet "$YNH_APP_INSTANCE_NAME " 1>/dev/null 2>&1`
|
||||
then
|
||||
rbenv alias $YNH_APP_INSTANCE_NAME --remove
|
||||
#REMOVEME? rbenv alias $YNH_APP_INSTANCE_NAME --remove
|
||||
fi
|
||||
|
||||
# Create app virtualenv
|
||||
rbenv alias $YNH_APP_INSTANCE_NAME $final_ruby_version
|
||||
#REMOVEME? rbenv alias $YNH_APP_INSTANCE_NAME $final_ruby_version
|
||||
|
||||
# Cleanup Ruby versions
|
||||
ynh_cleanup_ruby
|
||||
|
@ -406,7 +406,7 @@ eval \"\$(rbenv init -)\"
|
|||
#
|
||||
# usage: ynh_remove_ruby
|
||||
ynh_remove_ruby () {
|
||||
local ruby_version=$(ynh_app_setting_get --app=$YNH_APP_INSTANCE_NAME --key=ruby_version)
|
||||
#REMOVEME? #REMOVEME? local ruby_version=$(ynh_app_setting_get --app=$YNH_APP_INSTANCE_NAME --key=ruby_version)
|
||||
|
||||
# Load rbenv path in PATH
|
||||
local CLEAR_PATH="$rbenv_install_dir/bin:$PATH"
|
||||
|
@ -414,10 +414,10 @@ ynh_remove_ruby () {
|
|||
# Remove /usr/local/bin in PATH in case of Ruby prior installation
|
||||
PATH=$(echo $CLEAR_PATH | sed 's@/usr/local/bin:@@')
|
||||
|
||||
rbenv alias $YNH_APP_INSTANCE_NAME --remove
|
||||
#REMOVEME? rbenv alias $YNH_APP_INSTANCE_NAME --remove
|
||||
|
||||
# Remove the line for this app
|
||||
ynh_app_setting_delete --app=$YNH_APP_INSTANCE_NAME --key=ruby_version
|
||||
#REMOVEME? ynh_app_setting_delete --app=$YNH_APP_INSTANCE_NAME --key=ruby_version
|
||||
|
||||
# Cleanup Ruby versions
|
||||
ynh_cleanup_ruby
|
||||
|
@ -437,7 +437,7 @@ ynh_cleanup_ruby () {
|
|||
local required_ruby_versions=""
|
||||
for installed_app in $installed_apps
|
||||
do
|
||||
local installed_app_ruby_version=$(ynh_app_setting_get --app=$installed_app --key="ruby_version")
|
||||
#REMOVEME? local installed_app_ruby_version=$(ynh_app_setting_get --app=$installed_app --key="ruby_version")
|
||||
if [[ $installed_app_ruby_version ]]
|
||||
then
|
||||
required_ruby_versions="${installed_app_ruby_version}\n${required_ruby_versions}"
|
||||
|
|
|
@ -14,22 +14,22 @@ source /usr/share/yunohost/helpers
|
|||
# MANAGE SCRIPT FAILURE
|
||||
#=================================================
|
||||
|
||||
ynh_clean_setup () {
|
||||
#REMOVEME? ynh_clean_setup () {
|
||||
true
|
||||
}
|
||||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
#REMOVEME? ynh_abort_if_errors
|
||||
|
||||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_print_info --message="Loading installation settings..."
|
||||
#REMOVEME? ynh_print_info --message="Loading installation settings..."
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||
#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
|
||||
#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||
|
||||
#=================================================
|
||||
# DECLARE DATA AND CONF FILES TO BACKUP
|
||||
|
@ -40,7 +40,7 @@ ynh_print_info --message="Declaring files to be backed up..."
|
|||
# BACKUP THE APP MAIN DIR
|
||||
#=================================================
|
||||
|
||||
ynh_backup --src_path="$final_path"
|
||||
ynh_backup --src_path="$install_dir"
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE NGINX CONFIGURATION
|
||||
|
|
|
@ -13,60 +13,60 @@ source /usr/share/yunohost/helpers
|
|||
# RETRIEVE ARGUMENTS
|
||||
#=================================================
|
||||
|
||||
old_domain=$YNH_APP_OLD_DOMAIN
|
||||
old_path=$YNH_APP_OLD_PATH
|
||||
#REMOVEME? old_domain=$YNH_APP_OLD_DOMAIN
|
||||
#REMOVEME? old_path=$YNH_APP_OLD_PATH
|
||||
|
||||
new_domain=$YNH_APP_NEW_DOMAIN
|
||||
new_path=$YNH_APP_NEW_PATH
|
||||
#REMOVEME? new_domain=$YNH_APP_NEW_DOMAIN
|
||||
#REMOVEME? new_path=$YNH_APP_NEW_PATH
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Loading installation settings..."
|
||||
#REMOVEME? ynh_script_progression --message="Loading installation settings..."
|
||||
|
||||
# Needed for helper "ynh_add_nginx_config"
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
#REMOVEME? # Needed for helper "ynh_add_nginx_config"
|
||||
#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
|
||||
|
||||
# Add settings here as needed by your application
|
||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||
db_user=$db_name
|
||||
db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
|
||||
unicorn_workers=$(ynh_app_setting_get --app=$app --key=unicorn_workers)
|
||||
#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||
#REMOVEME? db_user=$db_name
|
||||
#REMOVEME? db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
|
||||
#REMOVEME? unicorn_workers=$(ynh_app_setting_get --app=$app --key=unicorn_workers)
|
||||
|
||||
#=================================================
|
||||
# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP
|
||||
#=================================================
|
||||
ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..."
|
||||
#REMOVEME? ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..."
|
||||
|
||||
# Backup the current version of the app
|
||||
ynh_backup_before_upgrade
|
||||
ynh_clean_setup () {
|
||||
ynh_clean_check_starting
|
||||
#REMOVEME? ynh_backup_before_upgrade
|
||||
#REMOVEME? ynh_clean_setup () {
|
||||
#REMOVEME? ynh_clean_check_starting
|
||||
# Remove the new domain config file, the remove script won't do it as it doesn't know yet its location.
|
||||
ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
|
||||
#REMOVEME? ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
|
||||
|
||||
# Restore it if the upgrade fails
|
||||
ynh_restore_upgradebackup
|
||||
#REMOVEME? ynh_restore_upgradebackup
|
||||
}
|
||||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
#REMOVEME? ynh_abort_if_errors
|
||||
|
||||
#=================================================
|
||||
# CHECK WHICH PARTS SHOULD BE CHANGED
|
||||
#=================================================
|
||||
|
||||
change_domain=0
|
||||
if [ "$old_domain" != "$new_domain" ]
|
||||
#REMOVEME? change_domain=0
|
||||
#REMOVEME? if [ "$old_domain" != "$new_domain" ]
|
||||
then
|
||||
change_domain=1
|
||||
#REMOVEME? change_domain=1
|
||||
fi
|
||||
|
||||
change_path=0
|
||||
if [ "$old_path" != "$new_path" ]
|
||||
#REMOVEME? change_path=0
|
||||
#REMOVEME? if [ "$old_path" != "$new_path" ]
|
||||
then
|
||||
change_path=1
|
||||
#REMOVEME? change_path=1
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
|
@ -83,33 +83,35 @@ ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app
|
|||
#=================================================
|
||||
ynh_script_progression --message="Updating NGINX web server configuration..."
|
||||
|
||||
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
|
||||
ynh_change_url_nginx_config
|
||||
|
||||
#REMOVEME? nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
|
||||
|
||||
# Change the path in the NGINX config file
|
||||
if [ $change_path -eq 1 ]
|
||||
then
|
||||
# Make a backup of the original NGINX config file if modified
|
||||
ynh_backup_if_checksum_is_different --file="$nginx_conf_path"
|
||||
#REMOVEME? ynh_backup_if_checksum_is_different --file="$nginx_conf_path"
|
||||
# Set global variables for NGINX helper
|
||||
domain="$old_domain"
|
||||
path_url="$new_path"
|
||||
#REMOVEME? domain="$old_domain"
|
||||
#REMOVEME? path="$new_path"
|
||||
# Create a dedicated NGINX config
|
||||
ynh_add_nginx_config
|
||||
#REMOVEME? ynh_add_nginx_config
|
||||
# Reference: https://meta.discourse.org/t/subfolder-support-with-docker/30507?u=falco&source_topic_id=54191
|
||||
if [ "$path_url" != "/" ] ; then
|
||||
ynh_replace_string --match_string='$proxy_add_x_forwarded_for' --replace_string='$http_your_original_ip_header' --target_file="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
if [ "$path" != "/" ] ; then
|
||||
#REMOVEME? ynh_replace_string --match_string='$proxy_add_x_forwarded_for' --replace_string='$http_your_original_ip_header' --target_file="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
fi
|
||||
ynh_store_file_checksum --file="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
#REMOVEME? ynh_store_file_checksum --file="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
fi
|
||||
|
||||
# Change the domain for NGINX
|
||||
if [ $change_domain -eq 1 ]
|
||||
then
|
||||
# Delete file checksum for the old conf file location
|
||||
ynh_delete_file_checksum --file="$nginx_conf_path"
|
||||
mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf
|
||||
#REMOVEME? ynh_delete_file_checksum --file="$nginx_conf_path"
|
||||
#REMOVEME? mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf
|
||||
# Store file checksum for the new config file location
|
||||
ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
|
||||
#REMOVEME? ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
|
@ -119,7 +121,7 @@ fi
|
|||
#=================================================
|
||||
ynh_script_progression --message="Updating a config file..."
|
||||
|
||||
discourse_config_file="$final_path/config/discourse.conf"
|
||||
discourse_config_file="$install_dir/config/discourse.conf"
|
||||
# Configure hostname
|
||||
ynh_replace_string --match_string="hostname = .*" --replace_string="hostname = \"$new_domain\"" --target_file="$discourse_config_file"
|
||||
ynh_replace_string --match_string="relative_url_root = .*" --replace_string="relative_url_root = ${new_path%/}" --target_file="$discourse_config_file"
|
||||
|
@ -151,14 +153,14 @@ ynh_exec_warn_less exec_login_as $app RAILS_ENV=production bin/rake posts:rebake
|
|||
ynh_script_progression --message="Starting a systemd service..."
|
||||
|
||||
# Start a systemd service
|
||||
ynh_systemd_action --service_name=$app --action="start" --log_path="$final_path/log/unicorn.stderr.log" --line_match="INFO -- : worker=$((unicorn_workers-1)) ready"
|
||||
ynh_systemd_action --service_name=$app --action="start" --log_path="$install_dir/log/unicorn.stderr.log" --line_match="INFO -- : worker=$((unicorn_workers-1)) ready"
|
||||
|
||||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reloading NGINX web server..."
|
||||
#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..."
|
||||
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
#REMOVEME? #REMOVEME? ynh_systemd_action --service_name=nginx --action=reload
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
|
|
136
scripts/install
136
scripts/install
|
@ -13,33 +13,33 @@ source /usr/share/yunohost/helpers
|
|||
# MANAGE SCRIPT FAILURE
|
||||
#=================================================
|
||||
|
||||
ynh_clean_setup () {
|
||||
#REMOVEME? ynh_clean_setup () {
|
||||
ynh_clean_check_starting
|
||||
}
|
||||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
#REMOVEME? ynh_abort_if_errors
|
||||
|
||||
#=================================================
|
||||
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
||||
#=================================================
|
||||
|
||||
domain=$YNH_APP_ARG_DOMAIN
|
||||
path_url=$YNH_APP_ARG_PATH
|
||||
is_public=$YNH_APP_ARG_IS_PUBLIC
|
||||
admin=$YNH_APP_ARG_ADMIN
|
||||
#REMOVEME? domain=$YNH_APP_ARG_DOMAIN
|
||||
#REMOVEME? path=$YNH_APP_ARG_PATH
|
||||
#REMOVEME? is_public=$YNH_APP_ARG_IS_PUBLIC
|
||||
#REMOVEME? admin=$YNH_APP_ARG_ADMIN
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
#=================================================
|
||||
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Validating installation parameters..."
|
||||
#REMOVEME? ynh_script_progression --message="Validating installation parameters..."
|
||||
|
||||
final_path=/var/www/$app
|
||||
test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
|
||||
#REMOVEME? install_dir=/var/www/$app
|
||||
#REMOVEME? test ! -e "$install_dir" || ynh_die --message="This path already contains a folder"
|
||||
|
||||
# Register (book) web path
|
||||
ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
|
||||
#REMOVEME? ynh_webpath_register --app=$app --domain=$domain --path=$path
|
||||
|
||||
if [ ${PACKAGE_CHECK_EXEC:-0} -eq 1 ]; then
|
||||
:
|
||||
|
@ -51,46 +51,46 @@ fi
|
|||
#=================================================
|
||||
# STORE SETTINGS FROM MANIFEST
|
||||
#=================================================
|
||||
ynh_script_progression --message="Storing installation settings..."
|
||||
#REMOVEME? ynh_script_progression --message="Storing installation settings..."
|
||||
|
||||
ynh_app_setting_set --app=$app --key=domain --value=$domain
|
||||
ynh_app_setting_set --app=$app --key=path --value=$path_url
|
||||
ynh_app_setting_set --app=$app --key=admin --value=$admin
|
||||
#REMOVEME? ynh_app_setting_set --app=$app --key=domain --value=$domain
|
||||
#REMOVEME? ynh_app_setting_set --app=$app --key=path --value=$path
|
||||
#REMOVEME? ynh_app_setting_set --app=$app --key=admin --value=$admin
|
||||
|
||||
#=================================================
|
||||
# STANDARD MODIFICATIONS
|
||||
#=================================================
|
||||
# INSTALL DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Installing dependencies..."
|
||||
#REMOVEME? ynh_script_progression --message="Installing dependencies..."
|
||||
|
||||
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies $build_pkg_dependencies
|
||||
ynh_exec_warn_less ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg"
|
||||
#REMOVEME? ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies $build_pkg_dependencies
|
||||
#REMOVEME? ynh_exec_warn_less ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg"
|
||||
ynh_exec_warn_less ynh_install_ruby --ruby_version=$ruby_version
|
||||
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version
|
||||
|
||||
#=================================================
|
||||
# CREATE DEDICATED USER
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring system user..."
|
||||
#REMOVEME? ynh_script_progression --message="Configuring system user..."
|
||||
|
||||
# Create a system user
|
||||
ynh_system_user_create --username=$app --home_dir="$final_path" --use_shell
|
||||
#REMOVEME? ynh_system_user_create --username=$app --home_dir="$install_dir" --use_shell
|
||||
|
||||
#=================================================
|
||||
# CREATE A POSTGRESQL DATABASE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Creating a PostgreSQL database..."
|
||||
#REMOVEME? ynh_script_progression --message="Creating a PostgreSQL database..."
|
||||
|
||||
db_name=$(ynh_sanitize_dbid --db_name=$app)
|
||||
db_user=$db_name
|
||||
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
|
||||
ynh_psql_test_if_first_run
|
||||
ynh_psql_setup_db --db_user=$db_user --db_name=$db_name
|
||||
#REMOVEME? db_name=$(ynh_sanitize_dbid --db_name=$app)
|
||||
#REMOVEME? db_user=$db_name
|
||||
#REMOVEME? ynh_app_setting_set --app=$app --key=db_name --value=$db_name
|
||||
#REMOVEME? ynh_psql_test_if_first_run
|
||||
#REMOVEME? ynh_psql_setup_db --db_user=$db_user --db_name=$db_name
|
||||
# Set extensions
|
||||
ynh_psql_execute_as_root --sql="CREATE EXTENSION IF NOT EXISTS hstore;" --database=$db_name
|
||||
ynh_psql_execute_as_root --sql="CREATE EXTENSION IF NOT EXISTS pg_trgm;" --database=$db_name
|
||||
db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
|
||||
#REMOVEME? db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
|
||||
|
||||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
|
@ -106,17 +106,17 @@ if [ -n "$(uname -m | grep arm)" ] ; then
|
|||
cp ../sources/patches_arm/* ../sources/patches
|
||||
fi
|
||||
|
||||
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
|
||||
#REMOVEME? ynh_app_setting_set --app=$app --key=install_dir --value=$install_dir
|
||||
# Download, check integrity, uncompress and patch the source from app.src
|
||||
ynh_setup_source --dest_dir="$final_path"
|
||||
ynh_setup_source --dest_dir="$install_dir"
|
||||
|
||||
# Install LDAP plugin
|
||||
mkdir -p "$final_path/plugins/discourse-ldap-auth"
|
||||
ynh_setup_source --dest_dir="$final_path/plugins/discourse-ldap-auth" --source_id=ldap-auth
|
||||
mkdir -p "$install_dir/plugins/discourse-ldap-auth"
|
||||
ynh_setup_source --dest_dir="$install_dir/plugins/discourse-ldap-auth" --source_id=ldap-auth
|
||||
|
||||
chmod 750 "$final_path"
|
||||
chmod -R o-rwx "$final_path"
|
||||
chown -R $app:www-data "$final_path"
|
||||
chmod 750 "$install_dir"
|
||||
chmod -R o-rwx "$install_dir"
|
||||
chown -R $app:www-data "$install_dir"
|
||||
|
||||
#=================================================
|
||||
# NGINX CONFIGURATION
|
||||
|
@ -127,7 +127,7 @@ ynh_script_progression --message="Configuring NGINX web server..."
|
|||
ynh_add_nginx_config
|
||||
|
||||
# Reference: https://meta.discourse.org/t/subfolder-support-with-docker/30507?u=falco&source_topic_id=54191
|
||||
if [ "$path_url" != "/" ] ; then
|
||||
if [ "$path" != "/" ] ; then
|
||||
ynh_replace_string --match_string='$proxy_add_x_forwarded_for' --replace_string='$http_your_original_ip_header' --target_file="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
fi
|
||||
ynh_store_file_checksum --file="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
|
@ -142,14 +142,14 @@ ynh_script_progression --message="Adding a configuration file..."
|
|||
admin_mail=$(ynh_user_get_info --username=$admin --key=mail)
|
||||
redis_db=$(ynh_redis_get_free_db)
|
||||
ynh_app_setting_set --app="$app" --key=redis_db --value="$redis_db"
|
||||
relative_url_root=${path_url%/}
|
||||
relative_url_root=${path%/}
|
||||
|
||||
ynh_add_config --template="../conf/discourse_defaults.conf" --destination="$final_path/config/discourse.conf"
|
||||
ynh_add_config --template="../conf/discourse_defaults.conf" --destination="$install_dir/config/discourse.conf"
|
||||
|
||||
ynh_add_config --template="../conf/settings.yml" --destination="$final_path/plugins/discourse-ldap-auth/config/settings.yml"
|
||||
ynh_add_config --template="../conf/settings.yml" --destination="$install_dir/plugins/discourse-ldap-auth/config/settings.yml"
|
||||
|
||||
# Disable svgo worker
|
||||
echo "svgo: false" > $final_path/.image_optim.yml
|
||||
echo "svgo: false" > $install_dir/.image_optim.yml
|
||||
|
||||
#=================================================
|
||||
# SETUP UNICORN, A RUBY SERVER
|
||||
|
@ -158,14 +158,14 @@ ynh_script_progression --message="Setting up Unicorn..."
|
|||
|
||||
# Set a secret value
|
||||
secret="$(ynh_string_random)"
|
||||
ynh_add_config --template="../conf/secrets.yml" --destination="$final_path/config/secrets.yml"
|
||||
ynh_add_config --template="../conf/secrets.yml" --destination="$install_dir/config/secrets.yml"
|
||||
|
||||
pushd "$final_path"
|
||||
pushd "$install_dir"
|
||||
ynh_use_ruby
|
||||
# Install bundler, a gems installer
|
||||
ynh_gem install bundler
|
||||
# Install without documentation
|
||||
ynh_exec_as $app echo "gem: --no-ri --no-rdoc" >> "$final_path/.gemrc"
|
||||
ynh_exec_as $app echo "gem: --no-ri --no-rdoc" >> "$install_dir/.gemrc"
|
||||
popd
|
||||
|
||||
# Specific actions on ARM architecture
|
||||
|
@ -183,12 +183,12 @@ exec_login_as $app 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 [ -n "$(uname -m | grep arm)" ] ; then
|
||||
(cd $final_path/vendor/bundle/ruby/*/gems/mini_suffix-*/vendor
|
||||
(cd $install_dir/vendor/bundle/ruby/*/gems/mini_suffix-*/vendor
|
||||
rm libpsl.so
|
||||
ln -s $(ldconfig -p | grep libpsl | awk 'END {print $NF}') libpsl.so)
|
||||
fi
|
||||
|
||||
pushd "$final_path"
|
||||
pushd "$install_dir"
|
||||
ynh_use_nodejs
|
||||
ynh_npm install --location=global terser
|
||||
ynh_npm install --location=global uglify-js
|
||||
|
@ -204,7 +204,7 @@ ynh_script_progression --message="Preparing the database..."
|
|||
ynh_exec_warn_less exec_login_as $app RAILS_ENV=production bin/bundle exec rake db:migrate
|
||||
ynh_exec_warn_less exec_login_as $app RAILS_ENV=production bin/bundle exec rake themes:update assets:precompile
|
||||
|
||||
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
|
||||
#REMOVEME? ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
|
||||
ynh_package_autoremove
|
||||
|
||||
#=================================================
|
||||
|
@ -216,13 +216,13 @@ ynh_script_progression --message="Populating the database..."
|
|||
ynh_psql_connect_as --user=$db_user --password=$db_pwd --database=$db_name <<< "INSERT INTO site_settings (name, data_type, value, created_at, updated_at) VALUES ('title', 1, 'YunoHost Forum', 'NOW()', 'NOW()');
|
||||
INSERT INTO site_settings (name, data_type, value, created_at, updated_at) VALUES ('site_description', 1, 'YunoHost Forum', 'NOW()', 'NOW()');
|
||||
INSERT INTO site_settings (name, data_type, value, created_at, updated_at) VALUES ('contact_email', 14, '$admin_mail', 'NOW()', 'NOW()');
|
||||
INSERT INTO site_settings (name, data_type, value, created_at, updated_at) VALUES ('contact_url', 1, '$domain$path_url', 'NOW()', 'NOW()');
|
||||
INSERT INTO site_settings (name, data_type, value, created_at, updated_at) VALUES ('contact_url', 1, '$domain$path', 'NOW()', 'NOW()');
|
||||
INSERT INTO site_settings (name, data_type, value, created_at, updated_at) VALUES ('site_contact_username', 15, '$admin', 'NOW()', 'NOW()');
|
||||
INSERT INTO site_settings (name, data_type, value, created_at, updated_at) VALUES ('logo_url', 1, '${path_url%/}/images/d-logo-sketch.png', 'NOW()', 'NOW()');
|
||||
INSERT INTO site_settings (name, data_type, value, created_at, updated_at) VALUES ('long_polling_base_url', 1, '${path_url%/}/', 'NOW()', 'NOW()');
|
||||
INSERT INTO site_settings (name, data_type, value, created_at, updated_at) VALUES ('logo_small_url', 1, '${path_url%/}/images/d-logo-sketch-small.png', 'NOW()', 'NOW()');
|
||||
INSERT INTO site_settings (name, data_type, value, created_at, updated_at) VALUES ('favicon_url', 1, '${path_url%/}/images/default-favicon.ico', 'NOW()', 'NOW()');
|
||||
INSERT INTO site_settings (name, data_type, value, created_at, updated_at) VALUES ('apple_touch_icon_url', 1, '${path_url%/}/images/default-apple-touch-icon.png', 'NOW()', 'NOW()');
|
||||
INSERT INTO site_settings (name, data_type, value, created_at, updated_at) VALUES ('logo_url', 1, '${path%/}/images/d-logo-sketch.png', 'NOW()', 'NOW()');
|
||||
INSERT INTO site_settings (name, data_type, value, created_at, updated_at) VALUES ('long_polling_base_url', 1, '${path%/}/', 'NOW()', 'NOW()');
|
||||
INSERT INTO site_settings (name, data_type, value, created_at, updated_at) VALUES ('logo_small_url', 1, '${path%/}/images/d-logo-sketch-small.png', 'NOW()', 'NOW()');
|
||||
INSERT INTO site_settings (name, data_type, value, created_at, updated_at) VALUES ('favicon_url', 1, '${path%/}/images/default-favicon.ico', 'NOW()', 'NOW()');
|
||||
INSERT INTO site_settings (name, data_type, value, created_at, updated_at) VALUES ('apple_touch_icon_url', 1, '${path%/}/images/default-apple-touch-icon.png', 'NOW()', 'NOW()');
|
||||
INSERT INTO site_settings (name, data_type, value, created_at, updated_at) VALUES ('wizard_enabled', 5, 'f', 'NOW()', 'NOW()');
|
||||
INSERT INTO site_settings (name, data_type, value, created_at, updated_at) VALUES ('force_https', 5, 't', 'NOW()', 'NOW()');
|
||||
"
|
||||
|
@ -248,7 +248,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
|
||||
(cd $final_path/plugins/discourse-ldap-auth/gems/${ruby_version}/gems/omniauth-ldap*/
|
||||
(cd $install_dir/plugins/discourse-ldap-auth/gems/${ruby_version}/gems/omniauth-ldap*/
|
||||
patch -p1 < $YNH_CWD/../conf/ldap-auth-fix-subfolder.patch)
|
||||
|
||||
#=================================================
|
||||
|
@ -275,20 +275,20 @@ ynh_add_systemd_config
|
|||
ynh_script_progression --message="Securing files and directories..."
|
||||
|
||||
# Add a pids and socket directory for the systemd script.
|
||||
mkdir -p "$final_path/tmp/pids"
|
||||
mkdir "$final_path/tmp/sockets"
|
||||
mkdir -p "$install_dir/tmp/pids"
|
||||
mkdir "$install_dir/tmp/sockets"
|
||||
|
||||
# Create specific folders and links for subfolder compatibility
|
||||
# (see: https://meta.discourse.org/t/subfolder-support-with-docker/30507)
|
||||
(
|
||||
cd $final_path
|
||||
cd $install_dir
|
||||
mkdir -p "public/forum"
|
||||
cd public/forum && ln -s ../uploads && ln -s ../backups
|
||||
)
|
||||
|
||||
chmod 750 "$final_path"
|
||||
chmod -R o-rwx "$final_path"
|
||||
chown -R $app:www-data "$final_path"
|
||||
chmod 750 "$install_dir"
|
||||
chmod -R o-rwx "$install_dir"
|
||||
chown -R $app:www-data "$install_dir"
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
|
@ -298,16 +298,16 @@ chown -R $app:www-data "$final_path"
|
|||
ynh_script_progression --message="Configuring log rotation..."
|
||||
|
||||
# Use logrotate to manage application logfile(s)
|
||||
ynh_use_logrotate --logfile="$final_path/log/unicorn.stderr.log"
|
||||
ynh_use_logrotate --logfile="$final_path/log/unicorn.stdout.log"
|
||||
ynh_use_logrotate --logfile="$final_path/log/production.log"
|
||||
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"
|
||||
|
||||
#=================================================
|
||||
# INTEGRATE SERVICE IN YUNOHOST
|
||||
#=================================================
|
||||
ynh_script_progression --message="Integrating service in YunoHost..."
|
||||
|
||||
yunohost service add $app --log "$final_path/log/unicorn.stderr.log" "$final_path/log/unicorn.stdout.log" "$final_path/log/production.log"
|
||||
yunohost service add $app --log "$install_dir/log/unicorn.stderr.log" "$install_dir/log/unicorn.stdout.log" "$install_dir/log/production.log"
|
||||
|
||||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
|
@ -315,27 +315,27 @@ yunohost service add $app --log "$final_path/log/unicorn.stderr.log" "$final_pat
|
|||
ynh_script_progression --message="Starting a systemd service..."
|
||||
|
||||
# Start a systemd service
|
||||
ynh_systemd_action --service_name=$app --action="start" --log_path="$final_path/log/unicorn.stderr.log" --line_match="INFO -- : worker=$((unicorn_workers-1)) ready"
|
||||
ynh_systemd_action --service_name=$app --action="start" --log_path="$install_dir/log/unicorn.stderr.log" --line_match="INFO -- : worker=$((unicorn_workers-1)) ready"
|
||||
|
||||
#=================================================
|
||||
# SETUP SSOWAT
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring permissions..."
|
||||
#REMOVEME? ynh_script_progression --message="Configuring permissions..."
|
||||
|
||||
# Make app public if necessary
|
||||
if [ $is_public -eq 1 ]
|
||||
#REMOVEME? if [ $is_public -eq 1 ]
|
||||
then
|
||||
# Everyone can access the app.
|
||||
# The "main" permission is automatically created before the install script.
|
||||
ynh_permission_update --permission="main" --add="visitors"
|
||||
#REMOVEME? ynh_permission_update --permission="main" --add="visitors"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reloading NGINX web server..."
|
||||
#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..."
|
||||
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
#REMOVEME? ynh_systemd_action --service_name=nginx --action=reload
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
|
|
|
@ -12,15 +12,15 @@ source /usr/share/yunohost/helpers
|
|||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Loading installation settings..."
|
||||
#REMOVEME? ynh_script_progression --message="Loading installation settings..."
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||
db_user=$db_name
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
redis_db=$(ynh_app_setting_get --app=$app --key=redis_db)
|
||||
#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||
#REMOVEME? db_user=$db_name
|
||||
#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
|
||||
#REMOVEME? redis_db=$(ynh_app_setting_get --app=$app --key=redis_db)
|
||||
|
||||
#=================================================
|
||||
# STANDARD REMOVE
|
||||
|
@ -54,10 +54,10 @@ ynh_remove_logrotate
|
|||
#=================================================
|
||||
# REMOVE THE POSTGRESQL DATABASE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing the PostgreSQL database..."
|
||||
#REMOVEME? ynh_script_progression --message="Removing the PostgreSQL database..."
|
||||
|
||||
# Remove a database if it exists, along with the associated user
|
||||
ynh_psql_remove_db --db_user="$db_user" --db_name="$db_name"
|
||||
#REMOVEME? ynh_psql_remove_db --db_user="$db_user" --db_name="$db_name"
|
||||
|
||||
#=================================================
|
||||
# REMOVE THE REDIS DATABASE
|
||||
|
@ -69,10 +69,10 @@ ynh_redis_remove_db "$redis_db"
|
|||
#=================================================
|
||||
# REMOVE APP MAIN DIR
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing app main directory..."
|
||||
#REMOVEME? ynh_script_progression --message="Removing app main directory..."
|
||||
|
||||
# Remove the app directory securely
|
||||
ynh_secure_remove --file="$final_path"
|
||||
#REMOVEME? ynh_secure_remove --file="$install_dir"
|
||||
|
||||
#=================================================
|
||||
# REMOVE NGINX CONFIGURATION
|
||||
|
@ -85,10 +85,10 @@ ynh_remove_nginx_config
|
|||
#=================================================
|
||||
# REMOVE DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing dependencies..."
|
||||
#REMOVEME? ynh_script_progression --message="Removing dependencies..."
|
||||
|
||||
# Remove metapackage and its dependencies
|
||||
ynh_remove_app_dependencies
|
||||
#REMOVEME? ynh_remove_app_dependencies
|
||||
ynh_remove_nodejs
|
||||
ynh_remove_ruby
|
||||
|
||||
|
@ -97,10 +97,10 @@ ynh_remove_ruby
|
|||
#=================================================
|
||||
# REMOVE DEDICATED USER
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing the dedicated system user..."
|
||||
#REMOVEME? ynh_script_progression --message="Removing the dedicated system user..."
|
||||
|
||||
# Delete a system user
|
||||
ynh_system_user_delete --username=$app
|
||||
#REMOVEME? ynh_system_user_delete --username=$app
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
|
|
|
@ -14,32 +14,32 @@ source /usr/share/yunohost/helpers
|
|||
# MANAGE SCRIPT FAILURE
|
||||
#=================================================
|
||||
|
||||
ynh_clean_setup () {
|
||||
#REMOVEME? ynh_clean_setup () {
|
||||
ynh_clean_check_starting
|
||||
}
|
||||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
#REMOVEME? ynh_abort_if_errors
|
||||
|
||||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Loading installation settings..."
|
||||
#REMOVEME? ynh_script_progression --message="Loading installation settings..."
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
path_url=$(ynh_app_setting_get --app=$app --key=path)
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||
db_user=$db_name
|
||||
#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
#REMOVEME? path=$(ynh_app_setting_get --app=$app --key=path)
|
||||
#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
|
||||
#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||
#REMOVEME? db_user=$db_name
|
||||
|
||||
#=================================================
|
||||
# CHECK IF THE APP CAN BE RESTORED
|
||||
#=================================================
|
||||
ynh_script_progression --message="Validating restoration parameters..."
|
||||
#REMOVEME? ynh_script_progression --message="Validating restoration parameters..."
|
||||
|
||||
test ! -d $final_path \
|
||||
|| ynh_die --message="There is already a directory: $final_path "
|
||||
#REMOVEME? test ! -d $install_dir \
|
||||
|| ynh_die --message="There is already a directory: $install_dir "
|
||||
|
||||
if [ ${PACKAGE_CHECK_EXEC:-0} -eq 1 ]; then
|
||||
:
|
||||
|
@ -53,32 +53,32 @@ fi
|
|||
#=================================================
|
||||
# RECREATE THE DEDICATED USER
|
||||
#=================================================
|
||||
ynh_script_progression --message="Recreating the dedicated system user..."
|
||||
#REMOVEME? ynh_script_progression --message="Recreating the dedicated system user..."
|
||||
|
||||
# Create the dedicated user (if not existing)
|
||||
ynh_system_user_create --username=$app --home_dir="$final_path" --use_shell
|
||||
#REMOVEME? ynh_system_user_create --username=$app --home_dir="$install_dir" --use_shell
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE APP MAIN DIR
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the app main directory..."
|
||||
|
||||
ynh_restore_file --origin_path="$final_path"
|
||||
ynh_restore_file --origin_path="$install_dir"
|
||||
|
||||
chmod 750 "$final_path"
|
||||
chmod -R o-rwx "$final_path"
|
||||
chown -R $app:www-data "$final_path"
|
||||
chmod 750 "$install_dir"
|
||||
chmod -R o-rwx "$install_dir"
|
||||
chown -R $app:www-data "$install_dir"
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC RESTORATION
|
||||
#=================================================
|
||||
# REINSTALL DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reinstalling dependencies..."
|
||||
#REMOVEME? ynh_script_progression --message="Reinstalling dependencies..."
|
||||
|
||||
# Define and install dependencies
|
||||
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies $build_pkg_dependencies
|
||||
ynh_exec_warn_less ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg"
|
||||
#REMOVEME? ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies $build_pkg_dependencies
|
||||
#REMOVEME? ynh_exec_warn_less ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg"
|
||||
ynh_exec_warn_less ynh_install_ruby --ruby_version=$ruby_version
|
||||
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version
|
||||
|
||||
|
@ -92,11 +92,11 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
|||
#=================================================
|
||||
# RESTORE THE POSTGRESQL DATABASE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the PostgreSQL database..."
|
||||
#REMOVEME? ynh_script_progression --message="Restoring the PostgreSQL database..."
|
||||
|
||||
ynh_psql_test_if_first_run
|
||||
db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
|
||||
ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
|
||||
#REMOVEME? ynh_psql_test_if_first_run
|
||||
#REMOVEME? db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
|
||||
#REMOVEME? ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
|
||||
ynh_psql_execute_as_root --sql="CREATE EXTENSION IF NOT EXISTS hstore;" --database=$db_name
|
||||
ynh_psql_execute_as_root --sql="CREATE EXTENSION IF NOT EXISTS pg_trgm;" --database=$db_name
|
||||
ynh_psql_execute_file_as_root --file="./db.sql" --database="$db_name"
|
||||
|
@ -106,12 +106,12 @@ ynh_psql_execute_file_as_root --file="./db.sql" --database="$db_name"
|
|||
#=================================================
|
||||
ynh_script_progression --message="Reinstall Bundle Gem..."
|
||||
|
||||
pushd "$final_path"
|
||||
pushd "$install_dir"
|
||||
ynh_use_ruby
|
||||
ynh_gem install bundler
|
||||
popd
|
||||
|
||||
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
|
||||
#REMOVEME? ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
|
||||
ynh_package_autoremove
|
||||
|
||||
#=================================================
|
||||
|
@ -134,7 +134,7 @@ ynh_restore_file --origin_path="/etc/logrotate.d/$app"
|
|||
#=================================================
|
||||
ynh_script_progression --message="Integrating service in YunoHost..."
|
||||
|
||||
yunohost service add $app --log "$final_path/log/unicorn.stderr.log" "$final_path/log/unicorn.stdout.log" "$final_path/log/production.log"
|
||||
yunohost service add $app --log "$install_dir/log/unicorn.stderr.log" "$install_dir/log/unicorn.stdout.log" "$install_dir/log/production.log"
|
||||
|
||||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
|
@ -147,7 +147,7 @@ else
|
|||
unicorn_workers=3
|
||||
fi
|
||||
ynh_app_setting_set --app=$app --key=unicorn_workers --value=$unicorn_workers
|
||||
ynh_systemd_action --service_name=$app --action="start" --log_path="$final_path/log/unicorn.stderr.log" --line_match="INFO -- : worker=$((unicorn_workers-1)) ready"
|
||||
ynh_systemd_action --service_name=$app --action="start" --log_path="$install_dir/log/unicorn.stderr.log" --line_match="INFO -- : worker=$((unicorn_workers-1)) ready"
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
|
|
154
scripts/upgrade
154
scripts/upgrade
|
@ -12,19 +12,19 @@ source /usr/share/yunohost/helpers
|
|||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Loading installation settings..."
|
||||
#REMOVEME? ynh_script_progression --message="Loading installation settings..."
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
path_url=$(ynh_app_setting_get --app=$app --key=path)
|
||||
admin=$(ynh_app_setting_get --app=$app --key=admin)
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||
db_user=$db_name
|
||||
db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
|
||||
redis_db=$(ynh_app_setting_get --app=$app --key=redis_db)
|
||||
unicorn_workers=$(ynh_app_setting_get --app=$app --key=unicorn_workers)
|
||||
#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
#REMOVEME? path=$(ynh_app_setting_get --app=$app --key=path)
|
||||
#REMOVEME? admin=$(ynh_app_setting_get --app=$app --key=admin)
|
||||
#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
|
||||
#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||
#REMOVEME? db_user=$db_name
|
||||
#REMOVEME? db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
|
||||
#REMOVEME? redis_db=$(ynh_app_setting_get --app=$app --key=redis_db)
|
||||
#REMOVEME? unicorn_workers=$(ynh_app_setting_get --app=$app --key=unicorn_workers)
|
||||
|
||||
if [ ${PACKAGE_CHECK_EXEC:-0} -eq 1 ]; then
|
||||
:
|
||||
|
@ -43,17 +43,17 @@ upgrade_type=$(ynh_check_app_version_changed)
|
|||
#=================================================
|
||||
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
||||
#=================================================
|
||||
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..."
|
||||
#REMOVEME? ynh_script_progression --message="Backing up the app before upgrading (may take a while)..."
|
||||
|
||||
# Backup the current version of the app
|
||||
ynh_backup_before_upgrade
|
||||
ynh_clean_setup () {
|
||||
#REMOVEME? ynh_backup_before_upgrade
|
||||
#REMOVEME? ynh_clean_setup () {
|
||||
ynh_clean_check_starting
|
||||
# Restore it if the upgrade fails
|
||||
ynh_restore_upgradebackup
|
||||
#REMOVEME? ynh_restore_upgradebackup
|
||||
}
|
||||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
#REMOVEME? ynh_abort_if_errors
|
||||
|
||||
#=================================================
|
||||
# ENABLE MAINTENANCE MODE
|
||||
|
@ -69,7 +69,7 @@ ynh_maintenance_mode_ON
|
|||
#=================================================
|
||||
ynh_script_progression --message="Stopping a systemd service..."
|
||||
|
||||
ynh_systemd_action --service_name=$app --action="stop" --log_path="$final_path/log/unicorn.stderr.log"
|
||||
ynh_systemd_action --service_name=$app --action="stop" --log_path="$install_dir/log/unicorn.stderr.log"
|
||||
|
||||
#=================================================
|
||||
# ENSURE DOWNWARD COMPATIBILITY
|
||||
|
@ -91,8 +91,8 @@ then
|
|||
fi
|
||||
|
||||
# Cleaning legacy permissions
|
||||
if ynh_legacy_permissions_exists; then
|
||||
ynh_legacy_permissions_delete_all
|
||||
#REMOVEME? if ynh_legacy_permissions_exists; then
|
||||
#REMOVEME? ynh_legacy_permissions_delete_all
|
||||
|
||||
ynh_app_setting_delete --app=$app --key=is_public
|
||||
fi
|
||||
|
@ -100,10 +100,10 @@ fi
|
|||
#=================================================
|
||||
# CREATE DEDICATED USER
|
||||
#=================================================
|
||||
ynh_script_progression --message="Making sure dedicated system user exists..."
|
||||
#REMOVEME? ynh_script_progression --message="Making sure dedicated system user exists..."
|
||||
|
||||
# Create a dedicated user (if not existing)
|
||||
ynh_system_user_create --username=$app --home_dir="$final_path" --use_shell
|
||||
#REMOVEME? ynh_system_user_create --username=$app --home_dir="$install_dir" --use_shell
|
||||
|
||||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
|
@ -124,66 +124,66 @@ then
|
|||
|
||||
# Backup files to keep
|
||||
tmpdir=$(mktemp -d)
|
||||
cp -Rp $final_path/plugins $final_path/config/discourse.conf $tmpdir
|
||||
if [ -d $final_path/public/uploads ] ; then
|
||||
cp -Rp $final_path/public/uploads $tmpdir
|
||||
cp -Rp $install_dir/plugins $install_dir/config/discourse.conf $tmpdir
|
||||
if [ -d $install_dir/public/uploads ] ; then
|
||||
cp -Rp $install_dir/public/uploads $tmpdir
|
||||
fi
|
||||
if [ -d $final_path/public/backups ] ; then
|
||||
cp -Rp $final_path/public/backups $tmpdir
|
||||
if [ -d $install_dir/public/backups ] ; then
|
||||
cp -Rp $install_dir/public/backups $tmpdir
|
||||
fi
|
||||
if [ -d $final_path/log ] ; then
|
||||
cp -Rp $final_path/log $tmpdir
|
||||
if [ -d $install_dir/log ] ; then
|
||||
cp -Rp $install_dir/log $tmpdir
|
||||
fi
|
||||
# Remove destination directory
|
||||
ynh_secure_remove --file=$final_path
|
||||
#REMOVEME? ynh_secure_remove --file=$install_dir
|
||||
# Download, check integrity, uncompress and patch the source from app.src
|
||||
ynh_setup_source --dest_dir="$final_path"
|
||||
ynh_setup_source --dest_dir="$install_dir"
|
||||
# Restore previous files
|
||||
if [ -d $tmpdir/uploads ] ; then
|
||||
cp -Rp $tmpdir/uploads $final_path/public
|
||||
cp -Rp $tmpdir/uploads $install_dir/public
|
||||
fi
|
||||
if [ -d $tmpdir/backups ] ; then
|
||||
cp -Rp $tmpdir/backups $final_path/public
|
||||
cp -Rp $tmpdir/backups $install_dir/public
|
||||
fi
|
||||
if [ -d $tmpdir/log ] ; then
|
||||
cp -Rp $tmpdir/log $final_path
|
||||
cp -Rp $tmpdir/log $install_dir
|
||||
fi
|
||||
(
|
||||
cd $tmpdir/plugins/
|
||||
for discourse_plugin_dir in */
|
||||
do
|
||||
# Only copy plugins not included in Discourse archive
|
||||
if [ ! -d "$final_path/plugins/$discourse_plugin_dir" ]
|
||||
if [ ! -d "$install_dir/plugins/$discourse_plugin_dir" ]
|
||||
then
|
||||
cp -a "$discourse_plugin_dir" "$final_path/plugins/$discourse_plugin_dir"
|
||||
cp -a "$discourse_plugin_dir" "$install_dir/plugins/$discourse_plugin_dir"
|
||||
fi
|
||||
done
|
||||
)
|
||||
cp -Rp $tmpdir/log $final_path
|
||||
cp -p $tmpdir/discourse.conf $final_path/config
|
||||
cp -Rp $tmpdir/log $install_dir
|
||||
cp -p $tmpdir/discourse.conf $install_dir/config
|
||||
ynh_secure_remove --file="$tmpdir"
|
||||
|
||||
# Install LDAP plugin
|
||||
tmpdir=$(mktemp -d)
|
||||
cp -Rp "$final_path/plugins/discourse-ldap-auth/config/settings.yml" $tmpdir
|
||||
ynh_secure_remove --file="$final_path/plugins/discourse-ldap-auth"
|
||||
mkdir -p "$final_path/plugins/discourse-ldap-auth"
|
||||
ynh_setup_source --dest_dir="$final_path/plugins/discourse-ldap-auth" --source_id=ldap-auth
|
||||
cp -p $tmpdir/settings.yml $final_path/plugins/discourse-ldap-auth/config
|
||||
cp -Rp "$install_dir/plugins/discourse-ldap-auth/config/settings.yml" $tmpdir
|
||||
#REMOVEME? ynh_secure_remove --file="$install_dir/plugins/discourse-ldap-auth"
|
||||
mkdir -p "$install_dir/plugins/discourse-ldap-auth"
|
||||
ynh_setup_source --dest_dir="$install_dir/plugins/discourse-ldap-auth" --source_id=ldap-auth
|
||||
cp -p $tmpdir/settings.yml $install_dir/plugins/discourse-ldap-auth/config
|
||||
ynh_secure_remove --file="$tmpdir"
|
||||
fi
|
||||
|
||||
chmod 750 "$final_path"
|
||||
chmod -R o-rwx "$final_path"
|
||||
chown -R $app:www-data "$final_path"
|
||||
chmod 750 "$install_dir"
|
||||
chmod -R o-rwx "$install_dir"
|
||||
chown -R $app:www-data "$install_dir"
|
||||
|
||||
#=================================================
|
||||
# UPGRADE DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading dependencies..."
|
||||
#REMOVEME? ynh_script_progression --message="Upgrading dependencies..."
|
||||
|
||||
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies $build_pkg_dependencies
|
||||
ynh_exec_warn_less ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg"
|
||||
#REMOVEME? ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies $build_pkg_dependencies
|
||||
#REMOVEME? ynh_exec_warn_less ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg"
|
||||
ynh_exec_warn_less ynh_install_ruby --ruby_version=$ruby_version
|
||||
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version
|
||||
ynh_use_ruby
|
||||
|
@ -197,7 +197,7 @@ ynh_script_progression --message="Upgrading NGINX web server configuration..."
|
|||
ynh_add_nginx_config
|
||||
|
||||
# Reference: https://meta.discourse.org/t/subfolder-support-with-docker/30507?u=falco&source_topic_id=54191
|
||||
if [ "$path_url" != "/" ] ; then
|
||||
if [ "$path" != "/" ] ; then
|
||||
ynh_replace_string --match_string='$proxy_add_x_forwarded_for' --replace_string='$http_your_original_ip_header' --target_file="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
fi
|
||||
ynh_store_file_checksum --file="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
|
@ -213,13 +213,13 @@ then
|
|||
ynh_script_progression --message="Updating a config file..."
|
||||
|
||||
admin_mail=$(ynh_user_get_info --username=$admin --key=mail)
|
||||
relative_url_root=${path_url%/}
|
||||
ynh_add_config --template="../conf/discourse_defaults.conf" --destination="$final_path/config/discourse.conf"
|
||||
relative_url_root=${path%/}
|
||||
ynh_add_config --template="../conf/discourse_defaults.conf" --destination="$install_dir/config/discourse.conf"
|
||||
|
||||
ynh_add_config --template="../conf/settings.yml" --destination="$final_path/plugins/discourse-ldap-auth/config/settings.yml"
|
||||
ynh_add_config --template="../conf/settings.yml" --destination="$install_dir/plugins/discourse-ldap-auth/config/settings.yml"
|
||||
|
||||
# Disable svgo worker
|
||||
echo "svgo: false" > $final_path/.image_optim.yml
|
||||
echo "svgo: false" > $install_dir/.image_optim.yml
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
|
@ -230,7 +230,7 @@ if [ "$upgrade_type" == "UPGRADE_APP" ]
|
|||
then
|
||||
ynh_script_progression --message="Setting up Unicorn..."
|
||||
|
||||
unicorn_config_file="$final_path/config/unicorn.conf.rb"
|
||||
unicorn_config_file="$install_dir/config/unicorn.conf.rb"
|
||||
# Make a backup of the original config file if modified
|
||||
ynh_backup_if_checksum_is_different "$unicorn_config_file"
|
||||
|
||||
|
@ -238,18 +238,18 @@ then
|
|||
ynh_store_file_checksum --file="$unicorn_config_file"
|
||||
|
||||
secret="$(ynh_string_random)"
|
||||
ynh_add_config --template="../conf/secrets.yml" --destination="$final_path/config/secrets.yml"
|
||||
ynh_add_config --template="../conf/secrets.yml" --destination="$install_dir/config/secrets.yml"
|
||||
|
||||
# Set permissions to app files
|
||||
chmod 750 "$final_path"
|
||||
chmod -R o-rwx "$final_path"
|
||||
chown -R $app:www-data "$final_path"
|
||||
chmod 750 "$install_dir"
|
||||
chmod -R o-rwx "$install_dir"
|
||||
chown -R $app:www-data "$install_dir"
|
||||
|
||||
pushd "$final_path"
|
||||
pushd "$install_dir"
|
||||
# Install bundler, a gems installer
|
||||
ynh_gem install bundler
|
||||
# Install without documentation
|
||||
ynh_exec_as $app echo "gem: --no-ri --no-rdoc" >> "$final_path/.gemrc"
|
||||
ynh_exec_as $app echo "gem: --no-ri --no-rdoc" >> "$install_dir/.gemrc"
|
||||
popd
|
||||
|
||||
# Specific actions on ARM architecture
|
||||
|
@ -267,13 +267,13 @@ then
|
|||
# because the provided binary isn't compatible
|
||||
if [ -n "$(uname -m | grep arm)" ] ; then
|
||||
(
|
||||
cd $final_path/vendor/bundle/ruby/*/gems/mini_suffix-*/vendor
|
||||
cd $install_dir/vendor/bundle/ruby/*/gems/mini_suffix-*/vendor
|
||||
rm libpsl.so
|
||||
ln -s $(ldconfig -p | grep libpsl | awk 'END {print $NF}') libpsl.so
|
||||
)
|
||||
fi
|
||||
|
||||
pushd "$final_path"
|
||||
pushd "$install_dir"
|
||||
ynh_use_nodejs
|
||||
ynh_npm install --location=global terser
|
||||
ynh_npm install --location=global uglify-js
|
||||
|
@ -294,7 +294,7 @@ then
|
|||
ynh_exec_warn_less exec_login_as $app RAILS_ENV=production bin/bundle exec rake themes:update assets:precompile
|
||||
fi
|
||||
|
||||
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
|
||||
#REMOVEME? ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
|
||||
ynh_package_autoremove
|
||||
|
||||
#=================================================
|
||||
|
@ -309,7 +309,7 @@ then
|
|||
# (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
|
||||
(
|
||||
cd $final_path/plugins/discourse-ldap-auth/gems/${ruby_version}/gems/omniauth-ldap*/
|
||||
cd $install_dir/plugins/discourse-ldap-auth/gems/${ruby_version}/gems/omniauth-ldap*/
|
||||
patch -p1 < $YNH_CWD/../conf/ldap-auth-fix-subfolder.patch
|
||||
)
|
||||
fi
|
||||
|
@ -333,13 +333,13 @@ fi
|
|||
ynh_script_progression --message="Securing files and directories..."
|
||||
|
||||
# Add a pids and socket directory for the systemd script.
|
||||
mkdir -p "$final_path/tmp/pids"
|
||||
mkdir -p "$final_path/tmp/sockets"
|
||||
mkdir -p "$install_dir/tmp/pids"
|
||||
mkdir -p "$install_dir/tmp/sockets"
|
||||
|
||||
# Create specific folders and links for subfolder compatibilityn
|
||||
# (see: https://meta.discourse.org/t/subfolder-support-with-docker/30507)
|
||||
(
|
||||
cd $final_path
|
||||
cd $install_dir
|
||||
mkdir -p "public/forum"
|
||||
cd public/forum
|
||||
if [ ! -L ./uploads ]; then
|
||||
|
@ -351,9 +351,9 @@ mkdir -p "$final_path/tmp/sockets"
|
|||
)
|
||||
|
||||
# Set permissions to app files
|
||||
chmod 750 "$final_path"
|
||||
chmod -R o-rwx "$final_path"
|
||||
chown -R $app:www-data "$final_path"
|
||||
chmod 750 "$install_dir"
|
||||
chmod -R o-rwx "$install_dir"
|
||||
chown -R $app:www-data "$install_dir"
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
|
@ -363,23 +363,23 @@ chown -R $app:www-data "$final_path"
|
|||
ynh_script_progression --message="Upgrading logrotate configuration..."
|
||||
|
||||
# Use logrotate to manage app-specific logfile(s)
|
||||
ynh_use_logrotate --logfile="$final_path/log/unicorn.stderr.log"
|
||||
ynh_use_logrotate --logfile="$final_path/log/unicorn.stdout.log"
|
||||
ynh_use_logrotate --logfile="$final_path/log/production.log"
|
||||
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"
|
||||
|
||||
#=================================================
|
||||
# INTEGRATE SERVICE IN YUNOHOST
|
||||
#=================================================
|
||||
ynh_script_progression --message="Integrating service in YunoHost..."
|
||||
|
||||
yunohost service add $app --log "$final_path/log/unicorn.stderr.log" "$final_path/log/unicorn.stdout.log" "$final_path/log/production.log"
|
||||
yunohost service add $app --log "$install_dir/log/unicorn.stderr.log" "$install_dir/log/unicorn.stdout.log" "$install_dir/log/production.log"
|
||||
|
||||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Starting a systemd service..."
|
||||
|
||||
ynh_systemd_action --service_name=$app --action="start" --log_path="$final_path/log/unicorn.stderr.log" --line_match="INFO -- : worker=$((unicorn_workers-1)) ready"
|
||||
ynh_systemd_action --service_name=$app --action="start" --log_path="$install_dir/log/unicorn.stderr.log" --line_match="INFO -- : worker=$((unicorn_workers-1)) ready"
|
||||
|
||||
#=================================================
|
||||
# DISABLE MAINTENANCE MODE
|
||||
|
@ -391,9 +391,9 @@ ynh_maintenance_mode_OFF
|
|||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reloading NGINX web server..."
|
||||
#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..."
|
||||
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
#REMOVEME? ynh_systemd_action --service_name=nginx --action=reload
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
|
|
Loading…
Add table
Reference in a new issue