1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/discourse_ynh.git synced 2024-09-03 18:26:18 +02:00

Merge pull request #110 from YunoHost-Apps/testing

Apply last example_ynh
This commit is contained in:
yalh76 2022-06-09 08:19:24 +02:00 committed by GitHub
commit b319842118
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 521 additions and 227 deletions

View file

@ -5,7 +5,7 @@ It shall NOT be edited by hand.
# Discourse for YunoHost
[![Integration level](https://dash.yunohost.org/integration/discourse.svg)](https://dash.yunohost.org/appci/app/discourse) ![](https://ci-apps.yunohost.org/ci/badges/discourse.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/discourse.maintain.svg)
[![Integration level](https://dash.yunohost.org/integration/discourse.svg)](https://dash.yunohost.org/appci/app/discourse) ![Working status](https://ci-apps.yunohost.org/ci/badges/discourse.status.svg) ![Maintenance status](https://ci-apps.yunohost.org/ci/badges/discourse.maintain.svg)
[![Install Discourse with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=discourse)
*[Lire ce readme en français.](./README_fr.md)*
@ -17,13 +17,13 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in
Discourse is modern forum software for your community. Use it as a mailing list, discussion forum, long-form chat room, and more!
**Shipped version:** 2.7.13~ynh1
**Shipped version:** 2.7.13~ynh2
**Demo:** https://try.discourse.org
## Screenshots
![](./doc/screenshots/screenshot.png)
![Screenshot of Discourse](./doc/screenshots/screenshot.png)
## Disclaimers / important information
@ -131,20 +131,21 @@ systemctl restart discourse
## Documentation and resources
* Official app website: http://Discourse.org
* Upstream app code repository: https://github.com/discourse/discourse
* YunoHost documentation for this app: https://yunohost.org/app_discourse
* Report a bug: https://github.com/YunoHost-Apps/discourse_ynh/issues
* Official app website: <http://Discourse.org>
* Upstream app code repository: <https://github.com/discourse/discourse>
* YunoHost documentation for this app: <https://yunohost.org/app_discourse>
* Report a bug: <https://github.com/YunoHost-Apps/discourse_ynh/issues>
## Developer info
Please send your pull request to the [testing branch](https://github.com/YunoHost-Apps/discourse_ynh/tree/testing).
To try the testing branch, please proceed like that.
```
``` bash
sudo yunohost app install https://github.com/YunoHost-Apps/discourse_ynh/tree/testing --debug
or
sudo yunohost app upgrade discourse -u https://github.com/YunoHost-Apps/discourse_ynh/tree/testing --debug
```
**More info regarding app packaging:** https://yunohost.org/packaging_apps
**More info regarding app packaging:** <https://yunohost.org/packaging_apps>

View file

@ -1,10 +1,14 @@
<!--
N.B.: This README was automatically generated by https://github.com/YunoHost/apps/tree/master/tools/README-generator
It shall NOT be edited by hand.
-->
# Discourse pour YunoHost
[![Niveau d'intégration](https://dash.yunohost.org/integration/discourse.svg)](https://dash.yunohost.org/appci/app/discourse) ![](https://ci-apps.yunohost.org/ci/badges/discourse.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/discourse.maintain.svg)
[![Niveau d'intégration](https://dash.yunohost.org/integration/discourse.svg)](https://dash.yunohost.org/appci/app/discourse) ![Statut du fonctionnement](https://ci-apps.yunohost.org/ci/badges/discourse.status.svg) ![Statut de maintenance](https://ci-apps.yunohost.org/ci/badges/discourse.maintain.svg)
[![Installer Discourse avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=discourse)
*[Read this readme in english.](./README.md)*
*[Lire ce readme en français.](./README_fr.md)*
> *Ce package vous permet d'installer Discourse rapidement et simplement sur un serveur YunoHost.
Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour savoir comment l'installer et en profiter.*
@ -13,13 +17,13 @@ Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour
Discourse est un logiciel de forum moderne pour votre communauté. Utilisez-le comme liste de diffusion, forum de discussion, salle de discussion longue durée, et plus encore !
**Version incluse :** 2.7.13~ynh1
**Version incluse :** 2.7.13~ynh2
**Démo :** https://try.discourse.org
## Captures d'écran
![](./doc/screenshots/screenshot.png)
![Capture d'écran de Discourse](./doc/screenshots/screenshot.png)
## Avertissements / informations importantes
@ -190,20 +194,21 @@ systemctl restart discourse
## Documentations et ressources
* Site officiel de l'app : http://Discourse.org
* Dépôt de code officiel de l'app : https://github.com/discourse/discourse
* Documentation YunoHost pour cette app : https://yunohost.org/app_discourse
* Signaler un bug : https://github.com/YunoHost-Apps/discourse_ynh/issues
* Site officiel de l'app : <http://Discourse.org>
* Dépôt de code officiel de l'app : <https://github.com/discourse/discourse>
* Documentation YunoHost pour cette app : <https://yunohost.org/app_discourse>
* Signaler un bug : <https://github.com/YunoHost-Apps/discourse_ynh/issues>
## Informations pour les développeurs
Merci de faire vos pull request sur la [branche testing](https://github.com/YunoHost-Apps/discourse_ynh/tree/testing).
Pour essayer la branche testing, procédez comme suit.
```
``` bash
sudo yunohost app install https://github.com/YunoHost-Apps/discourse_ynh/tree/testing --debug
ou
sudo yunohost app upgrade discourse -u https://github.com/YunoHost-Apps/discourse_ynh/tree/testing --debug
```
**Plus d'infos sur le packaging d'applications :** https://yunohost.org/packaging_apps
**Plus d'infos sur le packaging d'applications :** <https://yunohost.org/packaging_apps>

View file

@ -2,8 +2,8 @@
; Manifest
domain="domain.tld"
path="/path"
admin="john"
is_public=1
admin="john"
; Checks
pkg_linter=1
setup_sub_dir=1
@ -25,4 +25,4 @@ Notification=none
;;; Upgrade options
; commit=c626379c98bb7f052061446cd152e4406979d49d
name=2.6.1~ynh2
manifest_arg=domain=DOMAIN&path=PATH&admin=USER&is_public=1&
manifest_arg=domain=DOMAIN&path=PATH&admin=USER&is_public=1

View file

@ -3,3 +3,5 @@ SOURCE_SUM=29905c395311844fb3dacbbc11de37d3147ec45fc6c5f0a68b5d8ea98a2bc364
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true
SOURCE_FILENAME=
SOURCE_EXTRACT=true

View file

@ -0,0 +1,338 @@
#
# DO NOT EDIT THIS FILE
# If you need to make changes create a file called discourse.conf in this directory with your changes
# On import this file will be imported using ERB
#
# Discourse supports multiple mechanisms for production config.
#
# 1. You can do nothing and get these defaults (not recommended, you should at least set hostname)
# 2. You can copy this file to config/discourse.conf and amend with your settings
# 3. You can pass in config from your environment, all the settings below are available.
# Append DISCOURSE_ and upper case the setting in ENV. For example:
# to pass in db_timeout of 200 you would use DISCOURSE_DB_TIMEOUT=200
# All settings apply to production only
# connection pool size, sidekiq is set to 5, allowing an extra 3 for bg threads
db_pool = 8
# ActiveRecord connection pool timeout in milliseconds
db_timeout = 5000
# Database connection timeout in seconds
db_connect_timeout = 5
# socket file used to access db
db_socket =
# host address for db server
# This is set to blank so it tries to use sockets first
db_host =
# host address for db server when taking a backup via `pg_dump`
# Defaults to `db_host` if not configured
db_backup_host =
# port running db server, no need to set it
db_port =
# db server port to use when taking a backup via `pg_dump`
db_backup_port = 5432
# database name running discourse
db_name = __DB_NAME__
# username accessing database
db_username = __DB_USER__
# password used to access the db
db_password = __DB_PWD__
# Disallow prepared statements
# see: https://github.com/rails/rails/issues/21992
db_prepared_statements = false
# host address for db replica server
db_replica_host =
# port running replica db server, defaults to 5432 if not set
db_replica_port =
db_advisory_locks = true
# hostname running the forum
hostname = "__DOMAIN__"
# backup hostname mainly for cdn use
backup_hostname =
# address of smtp server used to send emails
smtp_address = localhost
# port of smtp server used to send emails
smtp_port = 25
# domain passed to smtp server
smtp_domain = __DOMAIN__
# username for smtp server
smtp_user_name =
# password for smtp server
smtp_password =
# smtp authentication mechanism
smtp_authentication = plain
# enable TLS encryption for smtp connections
smtp_enable_start_tls = false
# mode for verifying smtp server certificates
# to disable, set to 'none'
smtp_openssl_verify_mode =
# force implicit TLS as per RFC 8314 3.3
smtp_force_tls = false
# load MiniProfiler in production, to be used by developers
load_mini_profiler = false
# Every how many requests should MP profile a request (aka take snapshot)
# Default is never
mini_profiler_snapshots_period = 0
# specify the URL of the destination that MiniProfiler should ship snapshots to
# mini_profiler_snapshots_transport_auth_key is required as well
mini_profiler_snapshots_transport_url =
# authorization key that will be included as a header in requests made by the
# snapshots transporter to the URL specified above. The destination should
# know this key and only accept requests that have this key in the
# `Mini-Profiler-Transport-Auth` header.
mini_profiler_snapshots_transport_auth_key =
# recommended, cdn used to access assets
cdn_url =
# The hostname used by the CDN to request assets
cdn_origin_hostname =
# comma delimited list of emails that have developer level access
developer_emails = __ADMIN_MAIL__
# redis server address
redis_host = localhost
# redis server port
redis_port = 6379
# redis replica server address
redis_replica_host =
# redis replica server port
redis_replica_port = 6379
# redis database
redis_db = __REDIS_DB__
# redis password
redis_password =
# skip configuring client id for cloud providers who support no client commands
redis_skip_client_commands = false
# uses SSL for all Redis connections if true
redis_use_ssl = false
# message bus redis server switch
message_bus_redis_enabled = false
# message bus redis server address
message_bus_redis_host = localhost
# message bus redis server port
message_bus_redis_port = 6379
# message bus redis replica server address
message_bus_redis_replica_host =
# message bus redis slave server port
message_bus_redis_replica_port = 6379
# message bus redis database
message_bus_redis_db = 0
# message bus redis password
message_bus_redis_password =
# skip configuring client id for cloud providers who support no client commands
message_bus_redis_skip_client_commands = false
# enable Cross-origin Resource Sharing (CORS) directly at the application level
enable_cors = false
cors_origin = ''
# enable if you really need to serve assets in prd
serve_static_assets = true
# number of sidekiq workers (launched via unicorn master)
sidekiq_workers = 5
# adjust stylesheets to rtl (requires "rtlit" gem)
rtl_css = false
# connection reaping helps keep connection counts down, postgres
# will not work properly with huge numbers of open connections
# reap connections from pool that are older than 30 seconds
connection_reaper_age = 30
# run reap check every 30 seconds
connection_reaper_interval = 30
# set to relative URL (for subdirectory hosting)
# IMPORTANT: path must not include a trailing /
# EG: /forum
relative_url_root = "__PATH_URL__"
# increasing this number will increase redis memory use
# this ensures backlog (ability of channels to catch up are capped)
# message bus default cap is 1000, we are winding it down to 100
message_bus_max_backlog_size = 100
# must be a 64 byte hex string, anything else will be ignored with a warning
secret_key_base =
# fallback path for all assets which are served via the application
# used by static_controller
# in multi host setups this allows you to have old unicorn instances serve
# newly compiled assets
fallback_assets_path =
# S3 settings used for serving ALL public files
# be sure to configre a CDN as well per cdn_url
s3_bucket =
s3_region =
s3_access_key_id =
s3_secret_access_key =
s3_use_iam_profile =
s3_cdn_url =
s3_endpoint =
s3_http_continue_timeout =
s3_install_cors_rule =
### rate limits apply to all sites
max_user_api_reqs_per_minute = 20
max_user_api_reqs_per_day = 2880
max_admin_api_reqs_per_key_per_minute = 60
max_reqs_per_ip_per_minute = 200
max_reqs_per_ip_per_10_seconds = 50
# applies to asset type routes (avatars/css and so on)
max_asset_reqs_per_ip_per_10_seconds = 200
# global rate limiter will simply warn if the limit is exceeded, can be warn+block, warn, block or none
max_reqs_per_ip_mode = block
# bypass rate limiting any IP resolved as a private IP
max_reqs_rate_limit_on_private = false
# logged in DoS protection
# protection will only trigger for requests that queue longer than this amount
force_anonymous_min_queue_seconds = 1
# only trigger anon if we see more than N requests for this path in last 10 seconds
force_anonymous_min_per_10_seconds = 3
# Any requests with the headers Discourse-Background = true will not be allowed to queue
# longer than this amount of time.
# Discourse will rate limit and ask client to try again later.
background_requests_max_queue_length = 0.5
# if a message bus request queues for 100ms or longer, we will reject it and ask consumer
# to back off
reject_message_bus_queue_seconds = 0.1
# disable search if app server is queueing for longer than this (in seconds)
disable_search_queue_threshold = 1
# maximum number of posts rebaked across the cluster in the periodical job
# rebake process is very expensive, on multisite we have to make sure we never
# flood the queue
max_old_rebakes_per_15_minutes = 300
# maximum number of log messages in /logs
max_logster_logs = 1000
# during precompile update maxmind database if older than N days
# set to 0 to disable
refresh_maxmind_db_during_precompile_days = 2
# backup path containing maxmind db files
maxmind_backup_path =
# register an account at: https://www.maxmind.com/en/geolite2/signup
# then head to profile and get your license key
maxmind_license_key=
# when enabled the following headers will be added to every response:
# (note, if measurements do not exist for the header they will be omitted)
#
# X-Redis-Calls: 10
# X-Redis-Time: 1.02
# X-Sql-Calls: 102
# X-Sql-Time: 1.02
# X-Queue-Time: 1.01
enable_performance_http_headers = false
# gather JavaScript errors from clients (rate limited to 1 error per IP per minute)
enable_js_error_reporting = true
# This is probably not a number you want to touch, it controls the number of workers
# we allow mini scheduler to run. Prior to 2019 we ran a single worker.
# On extremely busy setups this could lead to situations where regular jobs would
# starve. Specifically jobs such as "run heartbeat" which keeps sidekiq running.
# Having a high number here is very low risk. Regular jobs are limited in scope and scale.
mini_scheduler_workers = 5
# enable compression on anonymous cache redis entries
# this slightly increases the cost of storing cache entries but can make it much
# cheaper to retrieve cache entries when redis is stores on a different machine to the one
# running the web
compress_anon_cache = false
# Only store entries in redis for anonymous cache if they are observed more than N times
# for a specific key
#
# This ensures there are no pathological cases where we keep storing data in anonymous cache
# never to use it, set to 1 to store immediately, set to 0 to disable anon cache
anon_cache_store_threshold = 2
# EXPERIMENTAL - not yet supported in production
# by default admins can install and amend any theme
# you may restrict it so only specific themes are approved
# in allowlist mode all theme updates must happen via git repos
# themes missing from the list are automatically disallowed
# list is a comma seperated list of git repos eg:
# https://github.com/discourse/discourse-custom-header-links.git,https://github.com/discourse/discourse-simple-theme.git
allowed_theme_repos =
# Demon::EmailSync is used in conjunction with the enable_imap site setting
# to sync N IMAP mailboxes with specific groups. It is a process started in
# unicorn.conf, and it spawns N threads (one for each multisite connection) and
# for each database spans another N threads (one for each configured group).
#
# We want this off by default so the process is not started when it does not
# need to be (e.g. development, test, certain hosting tiers)
enable_email_sync_demon = false
# we never want to queue more than 10000 digests per 30 minute block
# this can easily lead to blocking sidekiq
# on multisites we recommend a far lower number
max_digests_enqueued_per_30_mins_per_site = 10000
# This cluster name can be passed to the /srv/status route to verify
# the application cluster is the same one you are expecting
cluster_name =

24
conf/settings.yml Normal file
View file

@ -0,0 +1,24 @@
plugins:
ldap_enabled:
default: true
ldap_user_create_mode:
default: 'auto'
ldap_lookup_users_by:
default: 'email'
ldap_hostname:
default: 'localhost'
ldap_port:
default: 389
ldap_method:
default: 'plain'
ldap_base:
default: 'ou=users,dc=yunohost,dc=org'
ldap_uid:
default: 'uid'
ldap_bind_dn:
default: ''
ldap_password:
default: ''
secret: true
ldap_filter:
default: ''

View file

@ -14,7 +14,8 @@ Environment=RAILS_ENV=production
Environment=UNICORN_SIDEKIQS=1
Environment=LD_PRELOAD=__LIBJEMALLOC__
Environment=UNICORN_LISTENER=__FINALPATH__/tmp/sockets/unicorn.sock
ExecStart=__RBENV_ROOT__/shims/bundle exec unicorn --config config/unicorn.conf.rb -E production
Environment="__YNH_RUBY_LOAD_PATH__"
ExecStart=__FINALPATH__/bin/bundle exec unicorn --config config/unicorn.conf.rb -E production
Restart=always
RestartSec=10
@ -25,7 +26,7 @@ RestartSec=10
NoNewPrivileges=yes
PrivateTmp=yes
PrivateDevices=yes
RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6
RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6 AF_NETLINK
RestrictNamespaces=yes
RestrictRealtime=yes
DevicePolicy=closed

View file

@ -6,7 +6,7 @@
"en": "Discussion platform",
"fr": "Plateforme de discussion"
},
"version": "2.7.13~ynh1",
"version": "2.7.13~ynh2",
"url": "http://Discourse.org",
"upstream": {
"license": "GPL-2.0",
@ -39,14 +39,14 @@
"example": "/forum",
"default": "/forum"
},
{
"name": "admin",
"type": "user"
},
{
"name": "is_public",
"type": "boolean",
"default": true
},
{
"name": "admin",
"type": "user"
}
]
}

View file

@ -5,8 +5,9 @@
#=================================================
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"
build_pkg_dependencies=""
RUBY_VERSION="2.7.1"
ruby_version="2.7.1"
#=================================================
# PERSONAL HELPERS
@ -163,6 +164,12 @@ rbenv_install_dir="/opt/rbenv"
ruby_version_path="$rbenv_install_dir/versions"
# RBENV_ROOT is the directory of rbenv, it needs to be loaded as a environment variable.
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"
# Load the version of Ruby for an app, and set variables.
#
@ -187,9 +194,9 @@ export RBENV_ROOT="$rbenv_install_dir"
# 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_ENV_PATH__"`
# `Environment="__YNH_RUBY_LOAD_PATH__"`
# `ExecStart=__FINALPATH__/my_app`
# You will replace __YNH_RUBY_LOAD_ENV_PATH__ with $ynh_ruby_load_path
# 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
# `ExecStart=__YNH_RUBY__ my_app run`
@ -201,7 +208,7 @@ export RBENV_ROOT="$rbenv_install_dir"
#
# usage: ynh_use_ruby
#
# Requires YunoHost version 2.7.12 or higher.
# Requires YunoHost version 3.2.2 or higher.
ynh_use_ruby () {
ruby_version=$(ynh_app_setting_get --app=$app --key=ruby_version)
@ -246,7 +253,7 @@ ynh_use_ruby () {
# usage: ynh_install_ruby --ruby_version=ruby_version
# | arg: -v, --ruby_version= - Version of ruby to install.
#
# Requires YunoHost version 2.7.12 or higher.
# Requires YunoHost version 3.2.2 or higher.
ynh_install_ruby () {
# Declare an array to define the options of this helper.
local legacy_args=v
@ -464,7 +471,7 @@ ynh_cleanup_ruby () {
# | returns: the database number to use
ynh_redis_get_free_db() {
local result max db
result="$(redis-cli INFO keyspace)"
result=$(redis-cli INFO keyspace)
# get the num
max=$(cat /etc/redis/redis.conf | grep ^databases | grep -Eow "[0-9]+")

View file

@ -15,7 +15,7 @@ source /usr/share/yunohost/helpers
#=================================================
ynh_clean_setup () {
ynh_clean_check_starting
true
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
@ -30,7 +30,6 @@ 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)
unicorn_workers=$(ynh_app_setting_get --app=$app --key=unicorn_workers)
#=================================================
# DECLARE DATA AND CONF FILES TO BACKUP

View file

@ -32,7 +32,7 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path)
# 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=db_pwd)
db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
unicorn_workers=$(ynh_app_setting_get --app=$app --key=unicorn_workers)
#=================================================
@ -43,6 +43,7 @@ ynh_script_progression --message="Backing up the app before changing its URL (ma
# Backup the current version of the app
ynh_backup_before_upgrade
ynh_clean_setup () {
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"
@ -114,6 +115,9 @@ fi
#=================================================
# SPECIFIC MODIFICATIONS
#=================================================
# UPDATE A CONFIG FILE
#=================================================
ynh_script_progression --message="Updating a config file..."
discourse_config_file="$final_path/config/discourse.conf"
# Configure hostname
@ -133,13 +137,11 @@ ynh_use_ruby
exec_login_as $app RAILS_ENV=production bin/bundle exec script/discourse remap ${old_path%/}/uploads ${new_path%/}/uploads <<< "YES
# "
rake_exec="exec_login_as $app RAILS_ENV=production bin/rake"
# Regenerate assets
ynh_exec_warn_less $rake_exec assets:precompile
ynh_exec_warn_less exec_login_as $app RAILS_ENV=production bin/rake assets:precompile
# Regenerate all forum posts
ynh_exec_warn_less $rake_exec posts:rebake
ynh_exec_warn_less exec_login_as $app RAILS_ENV=production bin/rake posts:rebake
#=================================================
# GENERIC FINALISATION

View file

@ -14,7 +14,6 @@ source /usr/share/yunohost/helpers
#=================================================
ynh_clean_setup () {
# Clean remainings not handled by remove script
ynh_clean_check_starting
}
# Exit if an error occurs during the execution of the script
@ -26,8 +25,8 @@ ynh_abort_if_errors
domain=$YNH_APP_ARG_DOMAIN
path_url=$YNH_APP_ARG_PATH
admin=$YNH_APP_ARG_ADMIN
is_public=$YNH_APP_ARG_IS_PUBLIC
admin=$YNH_APP_ARG_ADMIN
app=$YNH_APP_INSTANCE_NAME
@ -65,8 +64,8 @@ ynh_app_setting_set --app=$app --key=admin --value=$admin
#=================================================
ynh_script_progression --message="Installing dependencies..."
ynh_install_app_dependencies $pkg_dependencies 2>/dev/null
ynh_install_ruby --ruby_version=$RUBY_VERSION 2>/dev/null
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies $build_pkg_dependencies
ynh_exec_warn_less ynh_install_ruby --ruby_version=$ruby_version
#=================================================
# CREATE DEDICATED USER
@ -83,14 +82,13 @@ ynh_script_progression --message="Creating a PostgreSQL database..."
db_name=$(ynh_sanitize_dbid --db_name=$app)
db_user=$db_name
db_pwd=$(ynh_string_random)
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
ynh_app_setting_set --app=$app --key=db_pwd --value=$db_pwd
ynh_psql_test_if_first_run
ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
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)
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
@ -135,51 +133,17 @@ ynh_store_file_checksum --file="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# SPECIFIC SETUP
#=================================================
# CONFIGURE DISCOURSE
# ADD A CONFIGURATION
#=================================================
ynh_script_progression --message="Configuring Discourse..."
ynh_script_progression --message="Adding a configuration file..."
# Configure database
discourse_config_file="$final_path/config/discourse.conf"
cp $final_path/config/discourse_defaults.conf $discourse_config_file
ynh_replace_string --match_string="db_name = discourse" --replace_string="db_name = $db_name" --target_file="$discourse_config_file"
ynh_replace_string --match_string="db_username = discourse" --replace_string="db_username = $db_name" --target_file="$discourse_config_file"
ynh_replace_string --match_string="db_password =" --replace_string="db_password = $db_pwd" --target_file="$discourse_config_file"
# Configure hostname
ynh_replace_string --match_string="hostname = \"www.example.com\"" --replace_string="hostname = \"$domain\"" --target_file="$discourse_config_file"
ynh_replace_string --match_string="relative_url_root =" --replace_string="relative_url_root = ${path_url%/}" --target_file="$discourse_config_file"
# Serve static assets (i.e. images, js, etc.)
ynh_replace_string --match_string="serve_static_assets = false" --replace_string="serve_static_assets = true" --target_file="$discourse_config_file"
# Don't show miniprofiler
ynh_replace_string --match_string="load_mini_profiler = true" --replace_string="load_mini_profiler = false" --target_file="$discourse_config_file"
# Configure e-mail server
admin_mail=$(ynh_user_get_info "$admin" mail)
ynh_replace_string --match_string="developer_emails =" --replace_string="developer_emails = $admin_mail" --target_file="$discourse_config_file"
ynh_replace_string --match_string="smtp_address =" --replace_string="smtp_address = localhost" --target_file="$discourse_config_file"
ynh_replace_string --match_string="smtp_domain =" --replace_string="smtp_domain = $domain" --target_file="$discourse_config_file"
ynh_replace_string --match_string="smtp_enable_start_tls = true" --replace_string="smtp_enable_start_tls = false" --target_file="$discourse_config_file"
# Configure redis
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"
ynh_replace_string --match_string="redis_db = 0" --replace_string="redis_db = $redis_db" --target_file="$discourse_config_file"
# Don't notify on new versions (handled by the YunoHost package)
ynh_replace_string --match_string="new_version_emails = true" --replace_string="new_version_emails = false" --target_file="$discourse_config_file"
ynh_add_config --template="../conf/discourse_defaults.conf" --destination="$final_path/config/discourse.conf"
# Calculate and store the config file checksum
ynh_store_file_checksum --file="$discourse_config_file"
# Configure LDAP plugin
ldap_config_file="$final_path/plugins/discourse-ldap-auth/config/settings.yml"
ynh_replace_string --match_string="adfs.example.com" --replace_string="localhost" --target_file="$ldap_config_file"
ynh_replace_string --match_string="dc=example,dc=com" --replace_string="ou=users,dc=yunohost,dc=org" --target_file="$ldap_config_file"
ynh_replace_string --match_string="sAMAccountName" --replace_string="uid" --target_file="$ldap_config_file"
ynh_store_file_checksum --file="$ldap_config_file"
ynh_add_config --template="../conf/settings.yml" --destination="$final_path/plugins/discourse-ldap-auth/config/settings.yml"
# Disable svgo worker
echo "svgo: false" > $final_path/.image_optim.yml
@ -193,11 +157,6 @@ ynh_script_progression --message="Setting up Unicorn..."
secret="$(ynh_string_random)"
ynh_add_config --template="../conf/secrets.yml" --destination="$final_path/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"
pushd "$final_path"
ynh_use_ruby
# Install bundler, a gems installer
@ -231,9 +190,11 @@ fi
#=================================================
ynh_script_progression --message="Preparing the database..."
rake_exec="exec_login_as $app RAILS_ENV=production bin/rake"
ynh_exec_warn_less $rake_exec db:migrate
ynh_exec_warn_less $rake_exec assets:precompile
ynh_exec_warn_less exec_login_as $app RAILS_ENV=production bin/rake db:migrate
ynh_exec_warn_less exec_login_as $app RAILS_ENV=production bin/rake assets:precompile
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
ynh_package_autoremove
#=================================================
# POPULATE THE DATABASE
@ -262,7 +223,7 @@ ynh_script_progression --message="Creating Discourse admin user..."
# Create a random password
admin_pwd=$(ynh_string_random)
$rake_exec admin:create <<< "$admin_mail
exec_login_as $app RAILS_ENV=production bin/rake admin:create <<< "$admin_mail
$admin_pwd
$admin_pwd
y
@ -276,7 +237,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 $final_path/plugins/discourse-ldap-auth/gems/${ruby_version}/gems/omniauth-ldap*/
patch -p1 < $YNH_CWD/../conf/ldap-auth-fix-subfolder.patch)
#=================================================
@ -284,8 +245,6 @@ patch -p1 < $YNH_CWD/../conf/ldap-auth-fix-subfolder.patch)
#=================================================
ynh_script_progression --message="Configuring a systemd service..."
ynh_replace_string --match_string="__RBENV_ROOT__" --replace_string="$RBENV_ROOT" --target_file="../conf/systemd.service"
# We assume for the moment that ARM devices are only dual core, so
# we restrict the number of workers to 2 (the default is 3)
if [ -n "$(uname -m | grep arm)" ] ; then
@ -296,9 +255,7 @@ else
unicorn_workers=3
fi
ynh_app_setting_set --app=$app --key=unicorn_workers --value=$unicorn_workers
ynh_replace_string --match_string="__ADDITIONAL_ENV__" --replace_string="$additional_env" --target_file="../conf/systemd.service"
ynh_replace_string --match_string="__LIBJEMALLOC__" --replace_string="$(ldconfig -p | grep libjemalloc | awk 'END {print $NF}')" --target_file="../conf/systemd.service"
libjemalloc="$(ldconfig -p | grep libjemalloc | awk 'END {print $NF}')"
ynh_add_systemd_config
#=================================================

View file

@ -43,6 +43,14 @@ ynh_script_progression --message="Stopping and removing the systemd service..."
# Remove the dedicated systemd config
ynh_remove_systemd_config
#=================================================
# REMOVE LOGROTATE CONFIGURATION
#=================================================
ynh_script_progression --message="Removing logrotate configuration..."
# Remove the app-specific logrotate config
ynh_remove_logrotate
#=================================================
# REMOVE THE POSTGRESQL DATABASE
#=================================================
@ -51,13 +59,6 @@ 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"
#=================================================
# REMOVE RUBY
#=================================================
ynh_script_progression --message="Removing Ruby..."
ynh_remove_ruby
#=================================================
# REMOVE THE REDIS DATABASE
#=================================================
@ -65,14 +66,6 @@ ynh_script_progression --message="Removing the redis database..."
ynh_redis_remove_db "$redis_db"
#=================================================
# REMOVE DEPENDENCIES
#=================================================
ynh_script_progression --message="Removing dependencies..."
# Remove metapackage and its dependencies
ynh_remove_app_dependencies
#=================================================
# REMOVE APP MAIN DIR
#=================================================
@ -90,12 +83,13 @@ ynh_script_progression --message="Removing NGINX web server configuration..."
ynh_remove_nginx_config
#=================================================
# REMOVE LOGROTATE CONFIGURATION
# REMOVE DEPENDENCIES
#=================================================
ynh_script_progression --message="Removing logrotate configuration..."
ynh_script_progression --message="Removing dependencies..."
# Remove the app-specific logrotate config
ynh_remove_logrotate
# Remove metapackage and its dependencies
ynh_remove_ruby
ynh_remove_app_dependencies
#=================================================
# GENERIC FINALIZATION

View file

@ -38,7 +38,8 @@ db_user=$db_name
#=================================================
ynh_script_progression --message="Validating restoration parameters..."
test ! -d $final_path || ynh_die --message="There is already a directory: $final_path "
test ! -d $final_path \
|| ynh_die --message="There is already a directory: $final_path "
if [ ${PACKAGE_CHECK_EXEC:-0} -eq 1 ]; then
:
@ -83,8 +84,20 @@ chown -R $app:www-data "$final_path"
ynh_script_progression --message="Reinstalling dependencies..."
# Define and install dependencies
ynh_install_app_dependencies $pkg_dependencies 2>/dev/null
ynh_install_ruby --ruby_version=$RUBY_VERSION 2>/dev/null
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies $build_pkg_dependencies
ynh_exec_warn_less ynh_install_ruby --ruby_version=$ruby_version
#=================================================
# RESTORE THE POSTGRESQL DATABASE
#=================================================
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
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"
#=================================================
# REINSTALL BUNDLE GEM
@ -96,19 +109,8 @@ pushd "$final_path"
ynh_gem install bundler
popd
#=================================================
# RESTORE THE POSTGRESQL DATABASE
#=================================================
ynh_script_progression --message="Restoring the PostgreSQL database..."
db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd)
ynh_psql_test_if_first_run
ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
# 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
# Restore dump
ynh_psql_execute_file_as_root --file="./db.sql" --database="$db_name"
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
ynh_package_autoremove
#=================================================
# RESTORE SYSTEMD
@ -118,6 +120,13 @@ ynh_script_progression --message="Restoring the systemd configuration..."
ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
systemctl enable $app.service --quiet
#=================================================
# RESTORE THE LOGROTATE CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring the logrotate configuration..."
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
@ -138,13 +147,6 @@ 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"
#=================================================
# RESTORE THE LOGROTATE CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring the logrotate configuration..."
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
#=================================================
# GENERIC FINALIZATION
#=================================================

View file

@ -21,7 +21,8 @@ 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_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd)
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)
@ -39,32 +40,6 @@ ynh_script_progression --message="Checking version..."
upgrade_type=$(ynh_check_app_version_changed)
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
ynh_script_progression --message="Ensuring downward compatibility..."
# If unicorn_workers doesn't exist, create it
if [ -z "$unicorn_workers" ]
then
# We assume for the moment that ARM devices are only dual core, so
# we restrict the number of workers to 2 (the default is 3)
if [ -n "$(uname -m | grep arm)" ]
then
unicorn_workers=2
else
unicorn_workers=3
fi
ynh_app_setting_set --app=$app --key=unicorn_workers --value=$unicorn_workers
fi
# Cleaning legacy permissions
if ynh_legacy_permissions_exists; then
ynh_legacy_permissions_delete_all
ynh_app_setting_delete --app=$app --key=is_public
fi
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
@ -96,6 +71,32 @@ ynh_script_progression --message="Stopping a systemd service..."
ynh_systemd_action --service_name=$app --action="stop" --log_path="$final_path/log/unicorn.stderr.log"
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
ynh_script_progression --message="Ensuring downward compatibility..."
# If unicorn_workers doesn't exist, create it
if [ -z "$unicorn_workers" ]
then
# We assume for the moment that ARM devices are only dual core, so
# we restrict the number of workers to 2 (the default is 3)
if [ -n "$(uname -m | grep arm)" ]
then
unicorn_workers=2
else
unicorn_workers=3
fi
ynh_app_setting_set --app=$app --key=unicorn_workers --value=$unicorn_workers
fi
# Cleaning legacy permissions
if ynh_legacy_permissions_exists; then
ynh_legacy_permissions_delete_all
ynh_app_setting_delete --app=$app --key=is_public
fi
#=================================================
# CREATE DEDICATED USER
#=================================================
@ -190,62 +191,24 @@ ynh_store_file_checksum --file="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
ynh_script_progression --message="Upgrading dependencies..."
ynh_install_app_dependencies $pkg_dependencies 2>/dev/null
ynh_install_ruby --ruby_version=$RUBY_VERSION 2>/dev/null
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies $build_pkg_dependencies
ynh_exec_warn_less ynh_install_ruby --ruby_version=$ruby_version
ynh_use_ruby
#=================================================
# SPECIFIC UPGRADE
#=================================================
# CONFIGURE DISCOURSE
# UPDATE A CONFIG FILE
#=================================================
if [ "$upgrade_type" == "UPGRADE_APP" ]
then
ynh_script_progression --message="Configuring Discourse..."
ynh_script_progression --message="Updating a config file..."
# Configure Discourse
discourse_config_file="$final_path/config/discourse.conf"
# Make a backup of the original config file if modified
ynh_backup_if_checksum_is_different --file="$discourse_config_file"
admin_mail=$(ynh_user_get_info --username=$admin --key=mail)
ynh_add_config --template="../conf/discourse_defaults.conf" --destination="$final_path/config/discourse.conf"
cp $final_path/config/discourse_defaults.conf $discourse_config_file
ynh_replace_string --match_string="db_name = discourse" --replace_string="db_name = $db_name" --target_file="$discourse_config_file"
ynh_replace_string --match_string="db_username = discourse" --replace_string="db_username = $db_name" --target_file="$discourse_config_file"
ynh_replace_string --match_string="db_password =" --replace_string="db_password = $db_pwd" --target_file="$discourse_config_file"
# Configure hostname
ynh_replace_string --match_string="hostname = \"www.example.com\"" --replace_string="hostname = \"$domain\"" --target_file="$discourse_config_file"
ynh_replace_string --match_string="relative_url_root =" --replace_string="relative_url_root = ${path_url%/}" --target_file="$discourse_config_file"
# Serve static assets (i.e. images, js, etc.)
ynh_replace_string --match_string="serve_static_assets = false" --replace_string="serve_static_assets = true" --target_file="$discourse_config_file"
# Don't show miniprofiler
ynh_replace_string --match_string="load_mini_profiler = true" --replace_string="load_mini_profiler = false" --target_file="$discourse_config_file"
# Configure e-mail server
admin_mail=$(ynh_user_get_info "$admin" mail)
ynh_replace_string --match_string="developer_emails =" --replace_string="developer_emails = $admin_mail" --target_file="$discourse_config_file"
ynh_replace_string --match_string="smtp_address =" --replace_string="smtp_address = localhost" --target_file="$discourse_config_file"
ynh_replace_string --match_string="smtp_domain =" --replace_string="smtp_domain = $domain" --target_file="$discourse_config_file"
ynh_replace_string --match_string="smtp_enable_start_tls = true" --replace_string="smtp_enable_start_tls = false" --target_file="$discourse_config_file"
# Configure redis
ynh_replace_string --match_string="redis_db = 0" --replace_string="redis_db = $redis_db" --target_file="$discourse_config_file"
# Don't notify on new versions (handled by the YunoHost package)
ynh_replace_string --match_string="new_version_emails = true" --replace_string="new_version_emails = false" --target_file="$discourse_config_file"
# Calculate and store the config file checksum
ynh_store_file_checksum --file="$discourse_config_file"
# Configure LDAP plugin
ldap_config_file="$final_path/plugins/discourse-ldap-auth/config/settings.yml"
# Make a backup of the original config file if modified
ynh_backup_if_checksum_is_different "$ldap_config_file"
ynh_replace_string --match_string="adfs.example.com" --replace_string="localhost" --target_file="$ldap_config_file"
ynh_replace_string --match_string="dc=example,dc=com" --replace_string="ou=users,dc=yunohost,dc=org" --target_file="$ldap_config_file"
ynh_replace_string --match_string="sAMAccountName" --replace_string="uid" --target_file="$ldap_config_file"
# Calculate and store the config file checksum
ynh_store_file_checksum --file="$ldap_config_file"
ynh_add_config --template="../conf/settings.yml" --destination="$final_path/plugins/discourse-ldap-auth/config/settings.yml"
# Disable svgo worker
echo "svgo: false" > $final_path/.image_optim.yml
@ -311,11 +274,13 @@ if [ "$upgrade_type" == "UPGRADE_APP" ]
then
ynh_script_progression --message="Preparing the database..."
rake_exec="exec_login_as $app RAILS_ENV=production bin/rake"
ynh_exec_warn_less $rake_exec db:migrate
ynh_exec_warn_less $rake_exec assets:precompile
ynh_exec_warn_less exec_login_as $app RAILS_ENV=production bin/rake db:migrate
ynh_exec_warn_less exec_login_as $app RAILS_ENV=production bin/rake assets:precompile
fi
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
ynh_package_autoremove
#=================================================
# CONFIGURE PLUGINS
#=================================================
@ -328,7 +293,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 $final_path/plugins/discourse-ldap-auth/gems/${ruby_version}/gems/omniauth-ldap*/
patch -p1 < $YNH_CWD/../conf/ldap-auth-fix-subfolder.patch
)
fi
@ -341,11 +306,8 @@ if [ "$upgrade_type" == "UPGRADE_APP" ]
then
ynh_script_progression --message="Configuring a systemd service..."
ynh_replace_string --match_string="__RBENV_ROOT__" --replace_string="$RBENV_ROOT" --target_file="../conf/systemd.service"
additional_env="UNICORN_WORKERS=$unicorn_workers"
ynh_replace_string --match_string="__ADDITIONAL_ENV__" --replace_string="$additional_env" --target_file="../conf/systemd.service"
ynh_replace_string --match_string="__LIBJEMALLOC__" --replace_string="$(ldconfig -p | grep libjemalloc | awk 'END {print $NF}')" --target_file="../conf/systemd.service"
libjemalloc="$(ldconfig -p | grep libjemalloc | awk 'END {print $NF}')"
ynh_add_systemd_config
fi