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

Merge branch 'testing' into 2.7.8-with-config

This commit is contained in:
yalh76 2022-06-07 20:57:48 +02:00
commit 5cca9ed04b
15 changed files with 146 additions and 144 deletions

View file

@ -5,7 +5,7 @@ It shall NOT be edited by hand.
# Discourse for YunoHost # 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) [![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)* *[Lire ce readme en français.](./README_fr.md)*
@ -21,15 +21,13 @@ Discourse is the 100% open source discussion platform built for the next decade
- discussion forum - discussion forum
- long-form chat room - long-form chat room
**Shipped version:** 2.9.0~ynh1 **Shipped version:** 2.9.0~ynh1
**Demo:** https://try.discourse.org **Demo:** https://try.discourse.org
## Screenshots ## Screenshots
![](./doc/screenshots/screenshot.png) ![Screenshot of Discourse](./doc/screenshots/screenshot.png)
## Disclaimers / important information ## Disclaimers / important information
@ -112,20 +110,21 @@ systemctl restart discourse
## Documentation and resources ## Documentation and resources
* Official app website: http://Discourse.org * Official app website: <http://Discourse.org>
* Upstream app code repository: https://github.com/discourse/discourse * Upstream app code repository: <https://github.com/discourse/discourse>
* YunoHost documentation for this app: https://yunohost.org/app_discourse * YunoHost documentation for this app: <https://yunohost.org/app_discourse>
* Report a bug: https://github.com/YunoHost-Apps/discourse_ynh/issues * Report a bug: <https://github.com/YunoHost-Apps/discourse_ynh/issues>
## Developer info ## Developer info
Please send your pull request to the [testing branch](https://github.com/YunoHost-Apps/discourse_ynh/tree/testing). 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. To try the testing branch, please proceed like that.
```
``` bash
sudo yunohost app install https://github.com/YunoHost-Apps/discourse_ynh/tree/testing --debug sudo yunohost app install https://github.com/YunoHost-Apps/discourse_ynh/tree/testing --debug
or or
sudo yunohost app upgrade discourse -u https://github.com/YunoHost-Apps/discourse_ynh/tree/testing --debug 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 # 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) [![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)* *[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. > *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.* Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour savoir comment l'installer et en profiter.*
@ -17,14 +21,13 @@ Discourse est la plate-forme de discussion 100% open source construite pour la p
- forum de discussion - forum de discussion
- salle de discussion - salle de discussion
**Version incluse :** 2.9.0~ynh1 **Version incluse :** 2.9.0~ynh1
**Démo :** https://try.discourse.org **Démo :** https://try.discourse.org
## Captures d'écran ## Captures d'écran
![](./doc/screenshots/screenshot.png) ![Capture d'écran de Discourse](./doc/screenshots/screenshot.png)
## Avertissements / informations importantes ## Avertissements / informations importantes
@ -126,20 +129,21 @@ systemctl restart discourse
## Documentations et ressources ## Documentations et ressources
* Site officiel de l'app : http://Discourse.org * Site officiel de l'app : <http://Discourse.org>
* Dépôt de code officiel de l'app : https://github.com/discourse/discourse * Dépôt de code officiel de l'app : <https://github.com/discourse/discourse>
* Documentation YunoHost pour cette app : https://yunohost.org/app_discourse * Documentation YunoHost pour cette app : <https://yunohost.org/app_discourse>
* Signaler un bug : https://github.com/YunoHost-Apps/discourse_ynh/issues * Signaler un bug : <https://github.com/YunoHost-Apps/discourse_ynh/issues>
## Informations pour les développeurs ## Informations pour les développeurs
Merci de faire vos pull request sur la [branche testing](https://github.com/YunoHost-Apps/discourse_ynh/tree/testing). 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. Pour essayer la branche testing, procédez comme suit.
```
``` bash
sudo yunohost app install https://github.com/YunoHost-Apps/discourse_ynh/tree/testing --debug sudo yunohost app install https://github.com/YunoHost-Apps/discourse_ynh/tree/testing --debug
ou ou
sudo yunohost app upgrade discourse -u https://github.com/YunoHost-Apps/discourse_ynh/tree/testing --debug 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 ; Manifest
domain="domain.tld" domain="domain.tld"
path="/path" path="/path"
admin="john"
is_public=1 is_public=1
admin="john"
; Checks ; Checks
pkg_linter=1 pkg_linter=1
setup_sub_dir=1 setup_sub_dir=1

View file

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

View file

@ -44,7 +44,7 @@ db_backup_port = 5432
db_name = __DB_NAME__ db_name = __DB_NAME__
# username accessing database # username accessing database
db_username = __DB_NAME__ db_username = __DB_USER__
# password used to access the db # password used to access the db
db_password = __DB_PWD__ db_password = __DB_PWD__

View file

@ -29,7 +29,7 @@
#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent; #sub_path_only rewrite ^__PATH__$ __PATH__/ permanent;
location __PATH__/ { location __PATH__/ {
alias __FINALPATH__/public/; alias __FINALPATH__/public/ ;
proxy_hide_header ETag; proxy_hide_header ETag;
# auth_basic on; # auth_basic on;
@ -199,7 +199,7 @@
location __PATH__/downloads/ { location __PATH__/downloads/ {
internal; internal;
alias __FINALPATH__/public/; alias __FINALPATH__/public/ ;
} }
location @__NAME__ { location @__NAME__ {

View file

@ -14,7 +14,8 @@ Environment=RAILS_ENV=production
Environment=UNICORN_SIDEKIQS=1 Environment=UNICORN_SIDEKIQS=1
Environment=LD_PRELOAD=__LIBJEMALLOC__ Environment=LD_PRELOAD=__LIBJEMALLOC__
Environment=UNICORN_LISTENER=__FINALPATH__/tmp/sockets/unicorn.sock 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 Restart=always
RestartSec=10 RestartSec=10
@ -25,7 +26,7 @@ RestartSec=10
NoNewPrivileges=yes NoNewPrivileges=yes
PrivateTmp=yes PrivateTmp=yes
PrivateDevices=yes PrivateDevices=yes
RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6 RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6 AF_NETLINK
RestrictNamespaces=yes RestrictNamespaces=yes
RestrictRealtime=yes RestrictRealtime=yes
DevicePolicy=closed DevicePolicy=closed

View file

@ -28,7 +28,7 @@
"nginx" "nginx"
], ],
"arguments": { "arguments": {
"install" : [ "install": [
{ {
"name": "domain", "name": "domain",
"type": "domain" "type": "domain"
@ -39,14 +39,14 @@
"example": "/forum", "example": "/forum",
"default": "/forum" "default": "/forum"
}, },
{
"name": "admin",
"type": "user"
},
{ {
"name": "is_public", "name": "is_public",
"type": "boolean", "type": "boolean",
"default": true "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" 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.2" ruby_version="2.7.2"
#================================================= #=================================================
# PERSONAL HELPERS # PERSONAL HELPERS
@ -163,6 +164,12 @@ rbenv_install_dir="/opt/rbenv"
ruby_version_path="$rbenv_install_dir/versions" ruby_version_path="$rbenv_install_dir/versions"
# RBENV_ROOT is the directory of rbenv, it needs to be loaded as a environment variable. # 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"
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. # 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 # 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. # Either the app is dependent of Ruby or gem, but does not called it directly.
# In such situation, you need to load PATH # In such situation, you need to load PATH
# `Environment="__YNH_RUBY_LOAD_ENV_PATH__"` # `Environment="__YNH_RUBY_LOAD_PATH__"`
# `ExecStart=__FINALPATH__/my_app` # `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 # Or Ruby start the app directly, then you don't need to load the PATH variable
# `ExecStart=__YNH_RUBY__ my_app run` # `ExecStart=__YNH_RUBY__ my_app run`
@ -201,7 +208,7 @@ export RBENV_ROOT="$rbenv_install_dir"
# #
# usage: ynh_use_ruby # usage: ynh_use_ruby
# #
# Requires YunoHost version 2.7.12 or higher. # Requires YunoHost version 3.2.2 or higher.
ynh_use_ruby () { ynh_use_ruby () {
ruby_version=$(ynh_app_setting_get --app=$app --key=ruby_version) 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 # usage: ynh_install_ruby --ruby_version=ruby_version
# | arg: -v, --ruby_version= - Version of ruby to install. # | 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 () { ynh_install_ruby () {
# Declare an array to define the options of this helper. # Declare an array to define the options of this helper.
local legacy_args=v local legacy_args=v

View file

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

View file

@ -43,6 +43,7 @@ ynh_script_progression --message="Backing up the app before changing its URL (ma
# Backup the current version of the app # Backup the current version of the app
ynh_backup_before_upgrade ynh_backup_before_upgrade
ynh_clean_setup () { 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. # 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" ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
@ -114,6 +115,9 @@ fi
#================================================= #=================================================
# SPECIFIC MODIFICATIONS # SPECIFIC MODIFICATIONS
#================================================= #=================================================
# UPDATE A CONFIG FILE
#=================================================
ynh_script_progression --message="Updating a config file..."
discourse_config_file="$final_path/config/discourse.conf" discourse_config_file="$final_path/config/discourse.conf"
# Configure hostname # 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 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 # 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 # 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 # GENERIC FINALISATION

View file

@ -14,7 +14,6 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
ynh_clean_setup () { ynh_clean_setup () {
# Clean remainings not handled by remove script
ynh_clean_check_starting ynh_clean_check_starting
} }
# Exit if an error occurs during the execution of the script # Exit if an error occurs during the execution of the script
@ -26,8 +25,8 @@ ynh_abort_if_errors
domain=$YNH_APP_ARG_DOMAIN domain=$YNH_APP_ARG_DOMAIN
path_url=$YNH_APP_ARG_PATH path_url=$YNH_APP_ARG_PATH
admin=$YNH_APP_ARG_ADMIN
is_public=$YNH_APP_ARG_IS_PUBLIC is_public=$YNH_APP_ARG_IS_PUBLIC
admin=$YNH_APP_ARG_ADMIN
email=$(ynh_user_get_info --username="$admin" --key=mail) email=$(ynh_user_get_info --username="$admin" --key=mail)
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
@ -67,10 +66,8 @@ ynh_app_setting_set --app=$app --key=email --value=$email
#================================================= #=================================================
ynh_script_progression --message="Installing dependencies..." ynh_script_progression --message="Installing dependencies..."
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies 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_exec_warn_less ynh_install_ruby --ruby_version=$ruby_version
# Install Yarn
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_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg"
#================================================= #=================================================
@ -94,6 +91,7 @@ ynh_psql_setup_db --db_user=$db_user --db_name=$db_name
# Set extensions # 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 hstore;" --database=$db_name
ynh_psql_execute_as_root --sql="CREATE EXTENSION IF NOT EXISTS pg_trgm;" --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 # DOWNLOAD, CHECK AND UNPACK SOURCE
@ -138,9 +136,9 @@ ynh_store_file_checksum --file="/etc/nginx/conf.d/$domain.d/$app.conf"
#================================================= #=================================================
# SPECIFIC SETUP # SPECIFIC SETUP
#================================================= #=================================================
# CONFIGURE DISCOURSE # ADD A CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Configuring Discourse..." ynh_script_progression --message="Adding a configuration file..."
# Configure redis # Configure redis
redis_db=$(ynh_redis_get_free_db) redis_db=$(ynh_redis_get_free_db)
@ -165,11 +163,6 @@ ynh_script_progression --message="Setting up Unicorn..."
secret="$(ynh_string_random)" 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="$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" pushd "$final_path"
ynh_use_ruby ynh_use_ruby
# Install bundler, a gems installer # Install bundler, a gems installer
@ -203,9 +196,11 @@ fi
#================================================= #=================================================
ynh_script_progression --message="Preparing the database..." ynh_script_progression --message="Preparing the database..."
rake_exec="exec_login_as $app RAILS_ENV=production bin/rake" ynh_exec_warn_less exec_login_as $app RAILS_ENV=production bin/rake db:migrate
ynh_exec_warn_less $rake_exec db:migrate ynh_exec_warn_less exec_login_as $app RAILS_ENV=production bin/rake assets:precompile
ynh_exec_warn_less $rake_exec assets:precompile
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
ynh_package_autoremove
#================================================= #=================================================
# POPULATE THE DATABASE # POPULATE THE DATABASE
@ -234,7 +229,7 @@ ynh_script_progression --message="Creating Discourse admin user..."
# Create a random password # Create a random password
admin_pwd=$(ynh_string_random) admin_pwd=$(ynh_string_random)
$rake_exec admin:create <<< "$email exec_login_as $app RAILS_ENV=production bin/rake admin:create <<< "$email
$admin_pwd $admin_pwd
$admin_pwd $admin_pwd
y y
@ -248,7 +243,7 @@ ynh_script_progression --message="Configuring plugins..."
# Patch ldap-auth plugin dependency (omniauth-ldap) to fix it when using domain subfolder # 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) # (Can only do that now because we are patching dependencies which have just been downloaded)
# Patch applied: https://github.com/omniauth/omniauth-ldap/pull/16 # Patch 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) patch -p1 < $YNH_CWD/../conf/ldap-auth-fix-subfolder.patch)
#================================================= #=================================================
@ -256,8 +251,6 @@ patch -p1 < $YNH_CWD/../conf/ldap-auth-fix-subfolder.patch)
#================================================= #=================================================
ynh_script_progression --message="Configuring a systemd service..." 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 assume for the moment that ARM devices are only dual core, so
# we restrict the number of workers to 2 (the default is 3) # we restrict the number of workers to 2 (the default is 3)
if [ -n "$(uname -m | grep arm)" ] ; then if [ -n "$(uname -m | grep arm)" ] ; then
@ -268,9 +261,7 @@ else
unicorn_workers=3 unicorn_workers=3
fi fi
ynh_app_setting_set --app=$app --key=unicorn_workers --value=$unicorn_workers ynh_app_setting_set --app=$app --key=unicorn_workers --value=$unicorn_workers
libjemalloc="$(ldconfig -p | grep libjemalloc | awk 'END {print $NF}')"
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"
ynh_add_systemd_config 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 # Remove the dedicated systemd config
ynh_remove_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 # 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 # Remove a database if it exists, along with the associated user
ynh_psql_remove_db --db_user="$db_user" --db_name="$db_name" 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 # REMOVE THE REDIS DATABASE
#================================================= #=================================================
@ -65,14 +66,6 @@ ynh_script_progression --message="Removing the redis database..."
ynh_redis_remove_db "$redis_db" 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 # REMOVE APP MAIN DIR
#================================================= #=================================================
@ -90,12 +83,13 @@ ynh_script_progression --message="Removing NGINX web server configuration..."
ynh_remove_nginx_config 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 # Remove metapackage and its dependencies
ynh_remove_logrotate ynh_remove_ruby
ynh_remove_app_dependencies
#================================================= #=================================================
# GENERIC FINALIZATION # GENERIC FINALIZATION

View file

@ -39,7 +39,8 @@ db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
#================================================= #=================================================
ynh_script_progression --message="Validating restoration parameters..." 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 if [ ${PACKAGE_CHECK_EXEC:-0} -eq 1 ]; then
: :
@ -84,8 +85,20 @@ chown -R $app:www-data "$final_path"
ynh_script_progression --message="Reinstalling dependencies..." ynh_script_progression --message="Reinstalling dependencies..."
# Define and install dependencies # Define and install dependencies
ynh_install_app_dependencies $pkg_dependencies 2>/dev/null ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies $build_pkg_dependencies
ynh_install_ruby --ruby_version=$RUBY_VERSION 2>/dev/null 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 # REINSTALL BUNDLE GEM
@ -97,18 +110,8 @@ pushd "$final_path"
ynh_gem install bundler ynh_gem install bundler
popd popd
#================================================= ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
# RESTORE THE POSTGRESQL DATABASE ynh_package_autoremove
#=================================================
ynh_script_progression --message="Restoring the PostgreSQL database..."
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"
#================================================= #=================================================
# RESTORE SYSTEMD # RESTORE SYSTEMD
@ -118,6 +121,13 @@ ynh_script_progression --message="Restoring the systemd configuration..."
ynh_restore_file --origin_path="/etc/systemd/system/$app.service" ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
systemctl enable $app.service --quiet 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 # INTEGRATE SERVICE IN YUNOHOST
#================================================= #=================================================
@ -139,13 +149,6 @@ 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="$final_path/log/unicorn.stderr.log" --line_match="INFO -- : worker=$((unicorn_workers-1)) ready"
sleep 60 sleep 60
#=================================================
# RESTORE THE LOGROTATE CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring the logrotate configuration..."
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
#================================================= #=================================================
# GENERIC FINALIZATION # GENERIC FINALIZATION
#================================================= #=================================================

View file

@ -21,6 +21,7 @@ path_url=$(ynh_app_setting_get --app=$app --key=path)
admin=$(ynh_app_setting_get --app=$app --key=admin) admin=$(ynh_app_setting_get --app=$app --key=admin)
final_path=$(ynh_app_setting_get --app=$app --key=final_path) final_path=$(ynh_app_setting_get --app=$app --key=final_path)
db_name=$(ynh_app_setting_get --app=$app --key=db_name) 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) db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
redis_db=$(ynh_app_setting_get --app=$app --key=redis_db) redis_db=$(ynh_app_setting_get --app=$app --key=redis_db)
unicorn_workers=$(ynh_app_setting_get --app=$app --key=unicorn_workers) unicorn_workers=$(ynh_app_setting_get --app=$app --key=unicorn_workers)
@ -40,32 +41,6 @@ ynh_script_progression --message="Checking version..."
upgrade_type=$(ynh_check_app_version_changed) 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 # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#================================================= #=================================================
@ -97,6 +72,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" 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 # CREATE DEDICATED USER
#================================================= #=================================================
@ -191,19 +192,19 @@ ynh_store_file_checksum --file="/etc/nginx/conf.d/$domain.d/$app.conf"
#================================================= #=================================================
ynh_script_progression --message="Upgrading dependencies..." ynh_script_progression --message="Upgrading dependencies..."
ynh_install_app_dependencies $pkg_dependencies 2>/dev/null ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies $build_pkg_dependencies
ynh_install_ruby --ruby_version=$RUBY_VERSION 2>/dev/null ynh_exec_warn_less ynh_install_ruby --ruby_version=$ruby_version
ynh_use_ruby ynh_use_ruby
#================================================= #=================================================
# SPECIFIC UPGRADE # SPECIFIC UPGRADE
#================================================= #=================================================
# CONFIGURE DISCOURSE # UPDATE A CONFIG FILE
#================================================= #=================================================
if [ "$upgrade_type" == "UPGRADE_APP" ] if [ "$upgrade_type" == "UPGRADE_APP" ]
then then
ynh_script_progression --message="Configuring Discourse..." ynh_script_progression --message="Updating a config file..."
ynh_add_config --template="../conf/discourse_defaults.conf" --destination="$final_path/config/discourse.conf" ynh_add_config --template="../conf/discourse_defaults.conf" --destination="$final_path/config/discourse.conf"
chmod 400 "$final_path/config/discourse.conf" chmod 400 "$final_path/config/discourse.conf"
@ -272,11 +273,13 @@ if [ "$upgrade_type" == "UPGRADE_APP" ]
then then
ynh_script_progression --message="Preparing the database..." ynh_script_progression --message="Preparing the database..."
rake_exec="exec_login_as $app RAILS_ENV=production bin/rake" ynh_exec_warn_less exec_login_as $app RAILS_ENV=production bin/rake db:migrate
ynh_exec_warn_less $rake_exec db:migrate ynh_exec_warn_less exec_login_as $app RAILS_ENV=production bin/rake assets:precompile
ynh_exec_warn_less $rake_exec assets:precompile
fi fi
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
ynh_package_autoremove
#================================================= #=================================================
# CONFIGURE PLUGINS # CONFIGURE PLUGINS
#================================================= #=================================================
@ -289,7 +292,7 @@ then
# (Can only do that now because we are patching dependencies which have just been downloaded) # (Can only do that now because we are patching dependencies which have just been downloaded)
# Patch applied: https://github.com/omniauth/omniauth-ldap/pull/16 # Patch 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 patch -p1 < $YNH_CWD/../conf/ldap-auth-fix-subfolder.patch
) )
fi fi
@ -302,11 +305,8 @@ if [ "$upgrade_type" == "UPGRADE_APP" ]
then then
ynh_script_progression --message="Configuring a systemd service..." 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" additional_env="UNICORN_WORKERS=$unicorn_workers"
ynh_replace_string --match_string="__ADDITIONAL_ENV__" --replace_string="$additional_env" --target_file="../conf/systemd.service" libjemalloc="$(ldconfig -p | grep libjemalloc | awk 'END {print $NF}')"
ynh_replace_string --match_string="__LIBJEMALLOC__" --replace_string="$(ldconfig -p | grep libjemalloc | awk 'END {print $NF}')" --target_file="../conf/systemd.service"
ynh_add_systemd_config ynh_add_systemd_config
fi fi