mirror of
https://github.com/YunoHost-Apps/discourse_ynh.git
synced 2024-09-03 18:26:18 +02:00
Merge branch 'testing' into 2.6.2
This commit is contained in:
commit
40f039a618
12 changed files with 494 additions and 386 deletions
2
.github/ISSUE_TEMPLATE.md
vendored
2
.github/ISSUE_TEMPLATE.md
vendored
|
@ -8,7 +8,7 @@ about: When creating a bug report, please use the following template to provide
|
||||||
1. *Read this whole template first.*
|
1. *Read this whole template first.*
|
||||||
2. *Determine if you are on the right place:*
|
2. *Determine if you are on the right place:*
|
||||||
- *If you were performing an action on the app from the webadmin or the CLI (install, update, backup, restore, change_url...), you are on the right place!*
|
- *If you were performing an action on the app from the webadmin or the CLI (install, update, backup, restore, change_url...), you are on the right place!*
|
||||||
- *Otherwise, the issue may be due to the app itself. Refer to its documentation or repository for help.*
|
- *Otherwise, the issue may be due to Discourse itself. Refer to its documentation or repository for help.*
|
||||||
- *When in doubt, post here and we will figure it out together.*
|
- *When in doubt, post here and we will figure it out together.*
|
||||||
3. *Delete the italic comments as you write over them below, and remove this guide.*
|
3. *Delete the italic comments as you write over them below, and remove this guide.*
|
||||||
---
|
---
|
||||||
|
|
198
README.md
198
README.md
|
@ -1,99 +1,99 @@
|
||||||
<!--
|
<!--
|
||||||
N.B.: This README was automatically generated by https://github.com/YunoHost/apps/tree/master/tools/README-generator
|
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.
|
It shall NOT be edited by hand.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
# Discourse for YunoHost
|
# Discourse for YunoHost
|
||||||
|
|
||||||
[](https://dash.yunohost.org/appci/app/discourse)  
|
[](https://dash.yunohost.org/appci/app/discourse)  
|
||||||
[](https://install-app.yunohost.org/?app=discourse)
|
[](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)*
|
||||||
|
|
||||||
> *This package allows you to install Discourse quickly and simply on a YunoHost server.
|
> *This package allows you to install Discourse quickly and simply on a YunoHost server.
|
||||||
If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/install) to learn how to install it.*
|
If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/install) to learn how to install it.*
|
||||||
|
|
||||||
## Overview
|
## Overview
|
||||||
|
|
||||||
Discussion platform
|
Discussion platform
|
||||||
|
|
||||||
**Shipped version:** 2.7.0~ynh1
|
**Shipped version:** 2.7.0~ynh1
|
||||||
|
|
||||||
**Demo:** https://try.discourse.org
|
**Demo:** https://try.discourse.org
|
||||||
|
|
||||||
## Screenshots
|
## Screenshots
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
## Disclaimers / important information
|
## Disclaimers / important information
|
||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
|
|
||||||
Use the admin panel of your Discourse to configure this app.
|
Use the admin panel of your Discourse to configure this app.
|
||||||
|
|
||||||
### Configuring "Reply-By-Email"
|
### Configuring "Reply-By-Email"
|
||||||
|
|
||||||
* You should create a dedicated YunoHost user for Discourse whose mailbox will be used by the *Discourse* application. You can do this with `yunohost user create response`, for example. You should ensure that the email address is configured to be on your Discourse domain.
|
* You should create a dedicated YunoHost user for Discourse whose mailbox will be used by the *Discourse* application. You can do this with `yunohost user create response`, for example. You should ensure that the email address is configured to be on your Discourse domain.
|
||||||
|
|
||||||
* You should then configure your Discourse `/var/www/discourse/config/discourse.conf` file with the correct SMTP configuration values. Please see [this comment](https://github.com/YunoHost-Apps/discourse_ynh/issues/2#issuecomment-409510325) for an explanation of what values to change. Please be aware, when you update the application, you will have to re-apply this configuration.
|
* You should then configure your Discourse `/var/www/discourse/config/discourse.conf` file with the correct SMTP configuration values. Please see [this comment](https://github.com/YunoHost-Apps/discourse_ynh/issues/2#issuecomment-409510325) for an explanation of what values to change. Please be aware, when you update the application, you will have to re-apply this configuration.
|
||||||
|
|
||||||
* You must enable the POP3 configuration for *Dovecot*. See [this thread](https://forum.yunohost.org/t/how-to-enable-pop3-in-yunohost/1662/2) on how to do that. You can validate your configuration with `systemctl restart dovecot && dovecot -n`. Don't forget to open the ports you need (`995` is the default). You can validate that with `nmap -p 995 yunohostdomain.org`.
|
* You must enable the POP3 configuration for *Dovecot*. See [this thread](https://forum.yunohost.org/t/how-to-enable-pop3-in-yunohost/1662/2) on how to do that. You can validate your configuration with `systemctl restart dovecot && dovecot -n`. Don't forget to open the ports you need (`995` is the default). You can validate that with `nmap -p 995 yunohostdomain.org`.
|
||||||
|
|
||||||
* You should then configure the Pop3 polling in the Discourse admin interface. Please see [this comment](https://meta.discourse.org/t/set-up-reply-via-email-support/14003) for how to do so. You will need to follow step 5 in that comment. You can specify your main Yunohost domain for the `pop3_polling_host`.
|
* You should then configure the Pop3 polling in the Discourse admin interface. Please see [this comment](https://meta.discourse.org/t/set-up-reply-via-email-support/14003) for how to do so. You will need to follow step 5 in that comment. You can specify your main Yunohost domain for the `pop3_polling_host`.
|
||||||
|
|
||||||
You should now be able to start testing. Try using the `/admin/email` "Send Test Email" and then view the "Sent" or "Skipped" etc. tabs. You should see a report on what happened with the email. You may also want to look in `/var/www/discourse/log/production.log` as well as `/var/www/mail.err`. You should perhaps also use [Rainloop](https://github.com/YunoHost-Apps/rainloop_ynh) or another Yunohost email client application to quickly test that both your user and the dedicated Yunohost Discourse user (`response@...`) is receiving mail.
|
You should now be able to start testing. Try using the `/admin/email` "Send Test Email" and then view the "Sent" or "Skipped" etc. tabs. You should see a report on what happened with the email. You may also want to look in `/var/www/discourse/log/production.log` as well as `/var/www/mail.err`. You should perhaps also use [Rainloop](https://github.com/YunoHost-Apps/rainloop_ynh) or another Yunohost email client application to quickly test that both your user and the dedicated Yunohost Discourse user (`response@...`) is receiving mail.
|
||||||
|
|
||||||
### "Reply-By-Email" and mail forwarding
|
### "Reply-By-Email" and mail forwarding
|
||||||
|
|
||||||
If you use the administration UI in YunoHost to setup a mail forwarding address for your users then you may face the problem whereby your users are replying by email from the forwarded email address and the *Discourse* software is not able to understand how to receive that email.
|
If you use the administration UI in YunoHost to setup a mail forwarding address for your users then you may face the problem whereby your users are replying by email from the forwarded email address and the *Discourse* software is not able to understand how to receive that email.
|
||||||
|
|
||||||
For example, your user has email address `foo@myyunohostdomain.org` and all mail is forwarded to `foo@theirexternalmail.com`. *Discourse* receives replies from `foo@theirexternalmail.com` but cannot understand how to deliver this to the user account with `foo@myyunohostdomain.org` configured.
|
For example, your user has email address `foo@myyunohostdomain.org` and all mail is forwarded to `foo@theirexternalmail.com`. *Discourse* receives replies from `foo@theirexternalmail.com` but cannot understand how to deliver this to the user account with `foo@myyunohostdomain.org` configured.
|
||||||
|
|
||||||
Their is on-going work to allow for [multiple email addresses for one user](https://meta.discourse.org/t/additional-email-address-per-user-account-support/59847) in Discourse development but at current major version (2.3 as of 2019-08-06), there is no web interface for this functionality. It is possible to set it up via the command-line interface but it is **experimental** and you should not undertake this work unless you take some time to understand what it is you are going to do.
|
Their is on-going work to allow for [multiple email addresses for one user](https://meta.discourse.org/t/additional-email-address-per-user-account-support/59847) in Discourse development but at current major version (2.3 as of 2019-08-06), there is no web interface for this functionality. It is possible to set it up via the command-line interface but it is **experimental** and you should not undertake this work unless you take some time to understand what it is you are going to do.
|
||||||
|
|
||||||
Here's how to setup a secondary mail address for a user account:
|
Here's how to setup a secondary mail address for a user account:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
$ cd /var/www/discourse
|
$ cd /var/www/discourse
|
||||||
$ RAILS_ENV=production /opt/rbenv/versions/2.6.0/bin/bundle exec rails c
|
$ RAILS_ENV=production /opt/rbenv/versions/2.6.0/bin/bundle exec rails c
|
||||||
$ UserEmail.create!(user: User.find_by_username("foo"), email: "foo@theirexternalmail.com")
|
$ UserEmail.create!(user: User.find_by_username("foo"), email: "foo@theirexternalmail.com")
|
||||||
```
|
```
|
||||||
|
|
||||||
Discourse can now receive mail from `foo@theirexternalmail.com` and give it to the user account with mail address `foo@myyunohostdomain.org`.
|
Discourse can now receive mail from `foo@theirexternalmail.com` and give it to the user account with mail address `foo@myyunohostdomain.org`.
|
||||||
|
|
||||||
#### Multi-user support
|
#### Multi-user support
|
||||||
|
|
||||||
Supported, with LDAP and SSO.
|
Supported, with LDAP and SSO.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
Default administrator and YunoHost users must login using LDAP:
|
Default administrator and YunoHost users must login using LDAP:
|
||||||
* click on the "with LDAP" button
|
* click on the "with LDAP" button
|
||||||
* use your YunoHost credentials
|
* use your YunoHost credentials
|
||||||
|
|
||||||
When disabling Local Login and other authentication services, clicking the `Login` or `Sign Up` button will directly bring up the LDAP Login popup.
|
When disabling Local Login and other authentication services, clicking the `Login` or `Sign Up` button will directly bring up the LDAP Login popup.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
|
||||||
## 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.
|
||||||
```
|
```
|
||||||
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
|
||||||
|
|
|
@ -29,3 +29,5 @@ Notification=none
|
||||||
manifest_arg=domain=DOMAIN&path=PATH&admin=USER&is_public=1&
|
manifest_arg=domain=DOMAIN&path=PATH&admin=USER&is_public=1&
|
||||||
; commit=086de718f49a506c66498d2f7610f5fd0ce07d50
|
; commit=086de718f49a506c66498d2f7610f5fd0ce07d50
|
||||||
name=2.3.10~ynh1
|
name=2.3.10~ynh1
|
||||||
|
; commit=b2e6633e0145c7eed2eb8c645ca7dbbd6c26fc06
|
||||||
|
name=2.6.0~ynh1
|
||||||
|
|
|
@ -14,7 +14,7 @@ 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=__RBENVROOT__/shims/bundle exec unicorn --config config/unicorn.conf.rb -E production
|
ExecStart=__RBENV_ROOT__/shims/bundle exec unicorn --config config/unicorn.conf.rb -E production
|
||||||
Restart=always
|
Restart=always
|
||||||
RestartSec=10
|
RestartSec=10
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
{
|
{
|
||||||
"name": "domain",
|
"name": "domain",
|
||||||
"type": "domain",
|
"type": "domain",
|
||||||
"example": "domain.org"
|
"example": "example.com"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "path",
|
"name": "path",
|
||||||
|
@ -43,7 +43,7 @@
|
||||||
{
|
{
|
||||||
"name": "admin",
|
"name": "admin",
|
||||||
"type": "user",
|
"type": "user",
|
||||||
"example": "homer"
|
"example": "johndoe"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "is_public",
|
"name": "is_public",
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
# COMMON VARIABLES
|
# COMMON VARIABLES
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
pkg_dependencies="g++ libjemalloc1|libjemalloc2 libjemalloc-dev zlib1g-dev libreadline-dev libpq-dev libssl-dev libyaml-dev libcurl4-openssl-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"
|
||||||
|
|
||||||
RUBY_VERSION="2.7.1"
|
RUBY_VERSION="2.7.1"
|
||||||
|
|
||||||
|
@ -163,46 +163,89 @@ ynh_maintenance_mode_OFF () {
|
||||||
# RUBY HELPER
|
# RUBY HELPER
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
|
ynh_ruby_try_bash_extension() {
|
||||||
|
if [ -x src/configure ]; then
|
||||||
|
src/configure && make -C src || {
|
||||||
|
ynh_print_info --message="Optional bash extension failed to build, but things will still work normally."
|
||||||
|
}
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
rbenv_install_dir="/opt/rbenv"
|
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.
|
# 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"
|
||||||
|
|
||||||
# Install ruby version management
|
# Load the version of Ruby for an app, and set variables.
|
||||||
#
|
#
|
||||||
# [internal]
|
# ynh_use_ruby has to be used in any app scripts before using Ruby for the first time.
|
||||||
|
# This helper will provide alias and variables to use in your scripts.
|
||||||
#
|
#
|
||||||
# usage: ynh_install_rbenv
|
# To use gem or Ruby, use the alias `ynh_gem` and `ynh_ruby`
|
||||||
ynh_install_rbenv () {
|
# Those alias will use the correct version installed for the app
|
||||||
echo "Installation of rbenv - ruby version management" >&2
|
# For example: use `ynh_gem install` instead of `gem install`
|
||||||
# Build an app.src for rbenv
|
#
|
||||||
mkdir -p "../conf"
|
# With `sudo` or `ynh_exec_as`, use instead the fallback variables `$ynh_gem` and `$ynh_ruby`
|
||||||
echo "SOURCE_URL=https://github.com/rbenv/rbenv/archive/v1.1.2.tar.gz
|
# And propagate $PATH to sudo with $ynh_ruby_load_path
|
||||||
SOURCE_SUM=80ad89ffe04c0b481503bd375f05c212bbc7d44ef5f5e649e0acdf25eba86736" > "../conf/rbenv.src"
|
# Exemple: `ynh_exec_as $app $ynh_ruby_load_path $ynh_gem install`
|
||||||
# Download and extract rbenv
|
#
|
||||||
ynh_setup_source "$rbenv_install_dir" rbenv
|
# $PATH contains the path of the requested version of Ruby.
|
||||||
|
# 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`
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# 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__"`
|
||||||
|
# `ExecStart=__FINALPATH__/my_app`
|
||||||
|
# You will replace __YNH_RUBY_LOAD_ENV_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`
|
||||||
|
# You will replace __YNH_RUBY__ with $ynh_ruby
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# one other variable is also available
|
||||||
|
# - $ruby_path: The absolute path to Ruby binaries for the chosen version.
|
||||||
|
#
|
||||||
|
# usage: ynh_use_ruby
|
||||||
|
#
|
||||||
|
# Requires YunoHost version 2.7.12 or higher.
|
||||||
|
ynh_use_ruby () {
|
||||||
|
ruby_version=$(ynh_app_setting_get --app=$app --key=ruby_version)
|
||||||
|
|
||||||
# Build an app.src for ruby-build
|
# Get the absolute path of this version of Ruby
|
||||||
mkdir -p "../conf"
|
ruby_path="$ruby_version_path/$YNH_APP_INSTANCE_NAME/bin"
|
||||||
echo "SOURCE_URL=https://github.com/rbenv/ruby-build/archive/v20200520.tar.gz
|
|
||||||
SOURCE_SUM=52be6908a94fbd4a94f5064e8b19d4a3baa4b773269c3884165518d83bcc8922" > "../conf/ruby-build.src"
|
|
||||||
# Download and extract ruby-build
|
|
||||||
ynh_setup_source "$rbenv_install_dir/plugins/ruby-build" ruby-build
|
|
||||||
|
|
||||||
(cd $rbenv_install_dir
|
# Allow alias to be used into bash script
|
||||||
./src/configure && make -C src)
|
shopt -s expand_aliases
|
||||||
|
|
||||||
# Create shims directory if needed
|
# Create an alias for the specific version of Ruby and a variable as fallback
|
||||||
if [ ! -d $rbenv_install_dir/shims ] ; then
|
ynh_ruby="$ruby_path/ruby"
|
||||||
mkdir $rbenv_install_dir/shims
|
alias ynh_ruby="$ynh_ruby"
|
||||||
fi
|
# And gem
|
||||||
|
ynh_gem="$ruby_path/gem"
|
||||||
|
alias ynh_gem="$ynh_gem"
|
||||||
|
|
||||||
|
# Load the path of this version of Ruby in $PATH
|
||||||
|
if [[ :$PATH: != *":$ruby_path"* ]]; then
|
||||||
|
PATH="$ruby_path:$PATH"
|
||||||
|
fi
|
||||||
|
# Create an alias to easily load the PATH
|
||||||
|
ynh_ruby_load_path="PATH=$PATH"
|
||||||
|
|
||||||
|
# Sets the local application-specific Ruby version
|
||||||
|
pushd $final_path
|
||||||
|
$rbenv_install_dir/bin/rbenv local $ruby_version
|
||||||
|
popd
|
||||||
}
|
}
|
||||||
|
|
||||||
# Install a specific version of ruby
|
# Install a specific version of Ruby
|
||||||
#
|
#
|
||||||
# ynh_install_ruby will install the version of ruby provided as argument by using rbenv.
|
# ynh_install_ruby will install the version of Ruby provided as argument by using rbenv.
|
||||||
#
|
|
||||||
# rbenv (ruby version management) stores the target ruby version in a .ruby_version file created in the target folder (using rbenv local <version>)
|
|
||||||
# It then uses that information for every ruby user that uses rbenv provided ruby command
|
|
||||||
#
|
#
|
||||||
# This helper creates a /etc/profile.d/rbenv.sh that configures PATH environment for rbenv
|
# This helper creates a /etc/profile.d/rbenv.sh that configures PATH environment for rbenv
|
||||||
# for every LOGIN user, hence your user must have a defined shell (as opposed to /usr/sbin/nologin)
|
# for every LOGIN user, hence your user must have a defined shell (as opposed to /usr/sbin/nologin)
|
||||||
|
@ -212,142 +255,215 @@ fi
|
||||||
# When not possible (e.g. in systemd service definition), please use direct path
|
# When not possible (e.g. in systemd service definition), please use direct path
|
||||||
# to rbenv shims (e.g. $RBENV_ROOT/shims/bundle)
|
# to rbenv shims (e.g. $RBENV_ROOT/shims/bundle)
|
||||||
#
|
#
|
||||||
# usage: ynh_install_ruby ruby_version user
|
# 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.
|
||||||
# If possible, prefer to use major version number (e.g. 8 instead of 8.10.0).
|
#
|
||||||
# The crontab will handle the update of minor versions when needed.
|
# Requires YunoHost version 2.7.12 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.
|
||||||
declare -Ar args_array=( [v]=ruby_version= )
|
local legacy_args=v
|
||||||
# Use rbenv, https://github.com/rbenv/rbenv to manage the ruby versions
|
local -A args_array=( [v]=ruby_version= )
|
||||||
local ruby_version
|
local ruby_version
|
||||||
# Manage arguments with getopts
|
# Manage arguments with getopts
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
|
|
||||||
# Create $rbenv_install_dir
|
# Load rbenv path in PATH
|
||||||
mkdir -p "$rbenv_install_dir/plugins/ruby-build"
|
local CLEAR_PATH="$rbenv_install_dir/bin:$PATH"
|
||||||
|
|
||||||
# Load rbenv path in PATH
|
# Remove /usr/local/bin in PATH in case of Ruby prior installation
|
||||||
CLEAR_PATH="$rbenv_install_dir/bin:$PATH"
|
PATH=$(echo $CLEAR_PATH | sed 's@/usr/local/bin:@@')
|
||||||
|
|
||||||
# Remove /usr/local/bin in PATH in case of ruby prior installation
|
# Move an existing Ruby binary, to avoid to block rbenv
|
||||||
PATH=$(echo $CLEAR_PATH | sed 's@/usr/local/bin:@@')
|
test -x /usr/bin/ruby && mv /usr/bin/ruby /usr/bin/ruby_rbenv
|
||||||
|
|
||||||
# Move an existing ruby binary, to avoid to block rbenv
|
# Install or update rbenv
|
||||||
test -x /usr/bin/ruby && mv /usr/bin/ruby /usr/bin/ruby_rbenv
|
rbenv="$(command -v rbenv $rbenv_install_dir/bin/rbenv | grep "$rbenv_install_dir/bin/rbenv" | head -1)"
|
||||||
|
if [ -n "$rbenv" ]; then
|
||||||
|
ynh_print_info --message="rbenv already seems installed in \`$rbenv'."
|
||||||
|
pushd "${rbenv%/*/*}"
|
||||||
|
if git remote -v 2>/dev/null | grep "https://github.com/rbenv/rbenv.git"; then
|
||||||
|
ynh_print_info --message="Trying to update with git..."
|
||||||
|
git pull -q --tags origin master
|
||||||
|
ynh_ruby_try_bash_extension
|
||||||
|
else
|
||||||
|
ynh_print_info --message="Reinstalling rbenv with git..."
|
||||||
|
cd ..
|
||||||
|
ynh_secure_remove --file=$rbenv_install_dir
|
||||||
|
mkdir -p $rbenv_install_dir
|
||||||
|
cd $rbenv_install_dir
|
||||||
|
git init -q
|
||||||
|
git remote add -f -t master origin https://github.com/rbenv/rbenv.git > /dev/null 2>&1
|
||||||
|
git checkout -q -b master origin/master
|
||||||
|
ynh_ruby_try_bash_extension
|
||||||
|
rbenv=$rbenv_install_dir/bin/rbenv
|
||||||
|
fi
|
||||||
|
popd
|
||||||
|
else
|
||||||
|
ynh_print_info --message="Installing rbenv with git..."
|
||||||
|
mkdir -p $rbenv_install_dir
|
||||||
|
pushd $rbenv_install_dir
|
||||||
|
git init -q
|
||||||
|
git remote add -f -t master origin https://github.com/rbenv/rbenv.git > /dev/null 2>&1
|
||||||
|
git checkout -q -b master origin/master
|
||||||
|
ynh_ruby_try_bash_extension
|
||||||
|
rbenv=$rbenv_install_dir/bin/rbenv
|
||||||
|
popd
|
||||||
|
fi
|
||||||
|
|
||||||
# If rbenv is not previously setup, install it
|
ruby_build="$(command -v "$rbenv_install_dir"/plugins/*/bin/rbenv-install rbenv-install | head -1)"
|
||||||
if ! type rbenv > /dev/null 2>&1
|
if [ -n "$ruby_build" ]; then
|
||||||
then
|
ynh_print_info --message="\`rbenv install' command already available in \`$ruby_build'."
|
||||||
ynh_install_rbenv
|
pushd "${ruby_build%/*/*}"
|
||||||
elif dpkg --compare-versions "$($rbenv_install_dir/bin/rbenv --version | cut -d" " -f2)" lt "1.1.2"
|
if git remote -v 2>/dev/null | grep "https://github.com/rbenv/ruby-build.git"; then
|
||||||
then
|
ynh_print_info --message="Trying to update rbenv with git..."
|
||||||
ynh_install_rbenv
|
git pull -q origin master
|
||||||
elif dpkg --compare-versions "$($rbenv_install_dir/plugins/ruby-build/bin/ruby-build --version | cut -d" " -f2)" lt "20200520"
|
fi
|
||||||
then
|
popd
|
||||||
ynh_install_rbenv
|
else
|
||||||
fi
|
ynh_print_info --message="Installing ruby-build with git..."
|
||||||
|
mkdir -p "${rbenv_install_dir}/plugins"
|
||||||
|
git clone -q https://github.com/rbenv/ruby-build.git "${rbenv_install_dir}/plugins/ruby-build"
|
||||||
|
fi
|
||||||
|
|
||||||
# Restore /usr/local/bin in PATH (if needed)
|
rbenv_alias="$(command -v "$rbenv_install_dir"/plugins/*/bin/rbenv-alias rbenv-alias | head -1)"
|
||||||
PATH=$CLEAR_PATH
|
if [ -n "$rbenv_alias" ]; then
|
||||||
|
ynh_print_info --message="\`rbenv alias' command already available in \`$rbenv_alias'."
|
||||||
|
pushd "${rbenv_alias%/*/*}"
|
||||||
|
if git remote -v 2>/dev/null | grep "https://github.com/tpope/rbenv-aliases.git"; then
|
||||||
|
ynh_print_info --message="Trying to update rbenv-aliases with git..."
|
||||||
|
git pull -q origin master
|
||||||
|
fi
|
||||||
|
popd
|
||||||
|
else
|
||||||
|
ynh_print_info --message="Installing rbenv-aliases with git..."
|
||||||
|
mkdir -p "${rbenv_install_dir}/plugins"
|
||||||
|
git clone -q https://github.com/tpope/rbenv-aliases.git "${rbenv_install_dir}/plugins/rbenv-aliase"
|
||||||
|
fi
|
||||||
|
|
||||||
# And replace the old ruby binary
|
rbenv_latest="$(command -v "$rbenv_install_dir"/plugins/*/bin/rbenv-latest rbenv-latest | head -1)"
|
||||||
test -x /usr/bin/ruby_rbenv && mv /usr/bin/ruby_rbenv /usr/bin/ruby
|
if [ -n "$rbenv_latest" ]; then
|
||||||
|
ynh_print_info --message="\`rbenv latest' command already available in \`$rbenv_latest'."
|
||||||
|
pushd "${rbenv_latest%/*/*}"
|
||||||
|
if git remote -v 2>/dev/null | grep "https://github.com/momo-lab/xxenv-latest.git"; then
|
||||||
|
ynh_print_info --message="Trying to update xxenv-latest with git..."
|
||||||
|
git pull -q origin master
|
||||||
|
fi
|
||||||
|
popd
|
||||||
|
else
|
||||||
|
ynh_print_info --message="Installing xxenv-latest with git..."
|
||||||
|
mkdir -p "${rbenv_install_dir}/plugins"
|
||||||
|
git clone -q https://github.com/momo-lab/xxenv-latest.git "${rbenv_install_dir}/plugins/xxenv-latest"
|
||||||
|
fi
|
||||||
|
|
||||||
# Install the requested version of ruby
|
# Enable caching
|
||||||
CONFIGURE_OPTS="--disable-install-doc --with-jemalloc" MAKE_OPTS="-j2" rbenv install --skip-existing $ruby_version
|
mkdir -p "${rbenv_install_dir}/cache"
|
||||||
|
|
||||||
# Store the ID of this app and the version of ruby requested for it
|
# Create shims directory if needed
|
||||||
echo "$YNH_APP_ID:$ruby_version" | tee --append "$rbenv_install_dir/ynh_app_version"
|
mkdir -p "${rbenv_install_dir}/shims"
|
||||||
|
|
||||||
# Store ruby_version into the config of this app
|
# Restore /usr/local/bin in PATH
|
||||||
ynh_app_setting_set $app ruby_version $ruby_version
|
PATH=$CLEAR_PATH
|
||||||
|
|
||||||
# Set environment for ruby users
|
# And replace the old Ruby binary
|
||||||
echo "#rbenv
|
test -x /usr/bin/ruby_rbenv && mv /usr/bin/ruby_rbenv /usr/bin/ruby
|
||||||
|
|
||||||
|
# Install the requested version of Ruby
|
||||||
|
local final_ruby_version=$(rbenv latest --print $ruby_version)
|
||||||
|
if ! [ -n "$final_ruby_version" ]; then
|
||||||
|
final_ruby_version=$ruby_version
|
||||||
|
fi
|
||||||
|
ynh_print_info --message="Installing Ruby-$final_ruby_version"
|
||||||
|
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
|
||||||
|
|
||||||
|
# Remove app virtualenv
|
||||||
|
if `rbenv alias --list | grep --quiet "$YNH_APP_INSTANCE_NAME " 1>/dev/null 2>&1`
|
||||||
|
then
|
||||||
|
rbenv alias $YNH_APP_INSTANCE_NAME --remove
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Create app virtualenv
|
||||||
|
rbenv alias $YNH_APP_INSTANCE_NAME $final_ruby_version
|
||||||
|
|
||||||
|
# Cleanup Ruby versions
|
||||||
|
ynh_cleanup_ruby
|
||||||
|
|
||||||
|
# Set environment for Ruby users
|
||||||
|
echo "#rbenv
|
||||||
export RBENV_ROOT=$rbenv_install_dir
|
export RBENV_ROOT=$rbenv_install_dir
|
||||||
export PATH=\"$rbenv_install_dir/bin:$PATH\"
|
export PATH=\"$rbenv_install_dir/bin:$PATH\"
|
||||||
eval \"\$(rbenv init -)\"
|
eval \"\$(rbenv init -)\"
|
||||||
#rbenv" > /etc/profile.d/rbenv.sh
|
#rbenv" > /etc/profile.d/rbenv.sh
|
||||||
|
|
||||||
# Load the right environment for the Installation
|
# Load the environment
|
||||||
eval "$(rbenv init -)"
|
eval "$(rbenv init -)"
|
||||||
|
|
||||||
(cd $final_path
|
|
||||||
rbenv local $ruby_version)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Remove the version of ruby used by the app.
|
# Remove the version of Ruby used by the app.
|
||||||
#
|
#
|
||||||
# This helper will check if another app uses the same version of ruby,
|
# This helper will also cleanup Ruby versions
|
||||||
# if not, this version of ruby will be removed.
|
|
||||||
# If no other app uses ruby, rbenv will be also removed.
|
|
||||||
#
|
#
|
||||||
# usage: ynh_remove_ruby
|
# usage: ynh_remove_ruby
|
||||||
ynh_remove_ruby () {
|
ynh_remove_ruby () {
|
||||||
ruby_version=$(ynh_app_setting_get $app ruby_version)
|
local ruby_version=$(ynh_app_setting_get --app=$YNH_APP_INSTANCE_NAME --key=ruby_version)
|
||||||
|
|
||||||
# Remove the line for this app
|
# Load rbenv path in PATH
|
||||||
sed --in-place "/$YNH_APP_ID:$ruby_version/d" "$rbenv_install_dir/ynh_app_version"
|
local CLEAR_PATH="$rbenv_install_dir/bin:$PATH"
|
||||||
|
|
||||||
# If no other app uses this version of ruby, remove it.
|
# Remove /usr/local/bin in PATH in case of Ruby prior installation
|
||||||
if ! grep --quiet "$ruby_version" "$rbenv_install_dir/ynh_app_version"
|
PATH=$(echo $CLEAR_PATH | sed 's@/usr/local/bin:@@')
|
||||||
then
|
|
||||||
$rbenv_install_dir/bin/rbenv uninstall --force $ruby_version
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Remove rbenv environment configuration
|
rbenv alias $YNH_APP_INSTANCE_NAME --remove
|
||||||
rm /etc/profile.d/rbenv.sh
|
|
||||||
|
|
||||||
# If no other app uses rbenv, remove rbenv and dedicated group
|
# Remove the line for this app
|
||||||
if [ ! -s "$rbenv_install_dir/ynh_app_version" ]
|
ynh_app_setting_delete --app=$YNH_APP_INSTANCE_NAME --key=ruby_version
|
||||||
then
|
|
||||||
ynh_secure_remove "$rbenv_install_dir"
|
# Cleanup Ruby versions
|
||||||
fi
|
ynh_cleanup_ruby
|
||||||
}
|
}
|
||||||
|
|
||||||
# Remove the version of ruby used by the app.
|
# Remove no more needed versions of Ruby used by the app.
|
||||||
#
|
#
|
||||||
# This helper will check if another app uses the same version of ruby,
|
# This helper will check what Ruby version are no more required,
|
||||||
# if not, this version of ruby will be removed.
|
# and uninstall them
|
||||||
# If no other app uses ruby, rbenv will be also removed.
|
# If no app uses Ruby, rbenv will be also removed.
|
||||||
#
|
#
|
||||||
# usage: ynh_remove_ruby
|
# usage: ynh_cleanup_ruby
|
||||||
ynh_remove_ruby () {
|
ynh_cleanup_ruby () {
|
||||||
ruby_version=$(ynh_app_setting_get $app ruby_version)
|
|
||||||
|
|
||||||
# Remove the line for this app
|
# List required Ruby versions
|
||||||
sed --in-place "/$YNH_APP_ID:$ruby_version/d" "$rbenv_install_dir/ynh_app_version"
|
local installed_apps=$(yunohost app list | grep -oP 'id: \K.*$')
|
||||||
|
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")
|
||||||
|
if [[ $installed_app_ruby_version ]]
|
||||||
|
then
|
||||||
|
required_ruby_versions="${installed_app_ruby_version}\n${required_ruby_versions}"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# Remove no more needed Ruby versions
|
||||||
|
local installed_ruby_versions=$(rbenv versions --bare --skip-aliases | grep -Ev '/')
|
||||||
|
for installed_ruby_version in $installed_ruby_versions
|
||||||
|
do
|
||||||
|
if ! `echo ${required_ruby_versions} | grep "${installed_ruby_version}" 1>/dev/null 2>&1`
|
||||||
|
then
|
||||||
|
ynh_print_info --message="Removing of Ruby-$installed_ruby_version"
|
||||||
|
$rbenv_install_dir/bin/rbenv uninstall --force $installed_ruby_version
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
# If no other app uses this version of ruby, remove it.
|
# If none Ruby version is required
|
||||||
if ! grep --quiet "$ruby_version" "$rbenv_install_dir/ynh_app_version"
|
if [[ ! $required_ruby_versions ]]
|
||||||
then
|
then
|
||||||
$rbenv_install_dir/bin/rbenv uninstall --force $ruby_version
|
# Remove rbenv environment configuration
|
||||||
fi
|
ynh_print_info --message="Removing of rbenv-$rbenv_version"
|
||||||
|
ynh_secure_remove --file="$rbenv_install_dir"
|
||||||
# Remove rbenv environment configuration
|
ynh_secure_remove --file="/etc/profile.d/rbenv.sh"
|
||||||
rm /etc/profile.d/rbenv.sh
|
fi
|
||||||
|
|
||||||
# If no other app uses rbenv, remove rbenv and dedicated group
|
|
||||||
if [ ! -s "$rbenv_install_dir/ynh_app_version" ]
|
|
||||||
then
|
|
||||||
ynh_secure_remove "$rbenv_install_dir"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# Returns true if upstream version is up to date
|
|
||||||
#
|
|
||||||
# This helper should be used to avoid an upgrade of the upstream version
|
|
||||||
# when it's not needed (but yet allowing to upgrade other parts of the
|
|
||||||
# YunoHost application (e.g. nginx conf)
|
|
||||||
#
|
|
||||||
# usage: ynh_is_upstream_up_to_date (returns a boolean)
|
|
||||||
ynh_is_upstream_up_to_date () {
|
|
||||||
local version=$(ynh_read_manifest "/etc/yunohost/apps/$YNH_APP_INSTANCE_NAME/manifest.json" "version" || echo 1.0)
|
|
||||||
version="${version/~ynh*/}"
|
|
||||||
local last_version=$(ynh_read_manifest "../manifest.json" "version" || echo 1.0)
|
|
||||||
last_version="${last_version/~ynh*/}"
|
|
||||||
[ "$version" = "$last_version" ]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
# IMPORT GENERIC HELPERS
|
# IMPORT GENERIC HELPERS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
#Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
|
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
|
||||||
source ../settings/scripts/_common.sh
|
source ../settings/scripts/_common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
|
@ -15,7 +15,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
|
||||||
|
|
|
@ -36,9 +36,9 @@ db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd)
|
||||||
unicorn_workers=$(ynh_app_setting_get --app=$app --key=unicorn_workers)
|
unicorn_workers=$(ynh_app_setting_get --app=$app --key=unicorn_workers)
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Backing up the app before changing its url (may take a while)..."
|
ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..."
|
||||||
|
|
||||||
# Backup the current version of the app
|
# Backup the current version of the app
|
||||||
ynh_backup_before_upgrade
|
ynh_backup_before_upgrade
|
||||||
|
@ -46,7 +46,7 @@ ynh_clean_setup () {
|
||||||
# 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"
|
||||||
|
|
||||||
# restore it if the upgrade fails
|
# Restore it if the upgrade fails
|
||||||
ynh_restore_upgradebackup
|
ynh_restore_upgradebackup
|
||||||
}
|
}
|
||||||
# Exit if an error occurs during the execution of the script
|
# Exit if an error occurs during the execution of the script
|
||||||
|
@ -80,19 +80,19 @@ ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app
|
||||||
#=================================================
|
#=================================================
|
||||||
# MODIFY URL IN NGINX CONF
|
# MODIFY URL IN NGINX CONF
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Updating nginx web server configuration..."
|
ynh_script_progression --message="Updating NGINX web server configuration..."
|
||||||
|
|
||||||
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
|
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
|
||||||
|
|
||||||
# Change the path in the nginx config file
|
# Change the path in the NGINX config file
|
||||||
if [ $change_path -eq 1 ]
|
if [ $change_path -eq 1 ]
|
||||||
then
|
then
|
||||||
# Make a backup of the original nginx config file if modified
|
# Make a backup of the original NGINX config file if modified
|
||||||
ynh_backup_if_checksum_is_different --file="$nginx_conf_path"
|
ynh_backup_if_checksum_is_different --file="$nginx_conf_path"
|
||||||
# Set global variables for nginx helper
|
# Set global variables for NGINX helper
|
||||||
domain="$old_domain"
|
domain="$old_domain"
|
||||||
path_url="$new_path"
|
path_url="$new_path"
|
||||||
# Create a dedicated nginx config
|
# Create a dedicated NGINX config
|
||||||
ynh_add_nginx_config
|
ynh_add_nginx_config
|
||||||
# Reference: https://meta.discourse.org/t/subfolder-support-with-docker/30507?u=falco&source_topic_id=54191
|
# Reference: https://meta.discourse.org/t/subfolder-support-with-docker/30507?u=falco&source_topic_id=54191
|
||||||
if [ "$path_url" != "/" ] ; then
|
if [ "$path_url" != "/" ] ; then
|
||||||
|
@ -101,14 +101,14 @@ then
|
||||||
ynh_store_file_checksum --file="/etc/nginx/conf.d/$domain.d/$app.conf"
|
ynh_store_file_checksum --file="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Change the domain for nginx
|
# Change the domain for NGINX
|
||||||
if [ $change_domain -eq 1 ]
|
if [ $change_domain -eq 1 ]
|
||||||
then
|
then
|
||||||
# Delete file checksum for the old conf file location
|
# Delete file checksum for the old conf file location
|
||||||
ynh_delete_file_checksum --file="$nginx_conf_path"
|
ynh_delete_file_checksum --file="$nginx_conf_path"
|
||||||
mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf
|
mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf
|
||||||
# Store file checksum for the new config file location
|
# Store file checksum for the new config file location
|
||||||
ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
|
ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -128,8 +128,9 @@ ynh_store_file_checksum --file="$discourse_config_file"
|
||||||
ynh_psql_connect_as --user=$db_user --password=$db_pwd --database=$db_name <<< "UPDATE site_settings SET value = replace(value, '${old_path%/}/images/', '${new_path%/}/images/');
|
ynh_psql_connect_as --user=$db_user --password=$db_pwd --database=$db_name <<< "UPDATE site_settings SET value = replace(value, '${old_path%/}/images/', '${new_path%/}/images/');
|
||||||
UPDATE site_settings SET value = '${new_path}' WHERE name='long_polling_base_url';"
|
UPDATE site_settings SET value = '${new_path}' WHERE name='long_polling_base_url';"
|
||||||
|
|
||||||
|
ynh_use_ruby
|
||||||
# Remap URLs in forum posts
|
# Remap URLs in forum posts
|
||||||
exec_login_as $app RAILS_ENV=production 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"
|
rake_exec="exec_login_as $app RAILS_ENV=production bin/rake"
|
||||||
|
@ -153,7 +154,7 @@ ynh_systemd_action --service_name=$app --action="start" --log_path="$final_path/
|
||||||
#=================================================
|
#=================================================
|
||||||
# RELOAD NGINX
|
# RELOAD NGINX
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Reloading nginx web server..."
|
ynh_script_progression --message="Reloading NGINX web server..."
|
||||||
|
|
||||||
ynh_systemd_action --service_name=nginx --action=reload
|
ynh_systemd_action --service_name=nginx --action=reload
|
||||||
|
|
||||||
|
|
|
@ -62,6 +62,15 @@ ynh_app_setting_set --app=$app --key=admin --value=$admin
|
||||||
ynh_script_progression --message="Installing dependencies..."
|
ynh_script_progression --message="Installing dependencies..."
|
||||||
|
|
||||||
ynh_install_app_dependencies $pkg_dependencies
|
ynh_install_app_dependencies $pkg_dependencies
|
||||||
|
ynh_install_ruby --ruby_version=$RUBY_VERSION
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# CREATE DEDICATED USER
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Configuring system user..."
|
||||||
|
|
||||||
|
# Create a system user
|
||||||
|
ynh_system_user_create --username=$app --home_dir="$final_path" --use_shell
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CREATE A POSTGRESQL DATABASE
|
# CREATE A POSTGRESQL DATABASE
|
||||||
|
@ -86,11 +95,11 @@ ynh_script_progression --message="Setting up source files..."
|
||||||
|
|
||||||
# Specific actions on ARM architecture
|
# Specific actions on ARM architecture
|
||||||
if [ -n "$(uname -m | grep arm)" ] ; then
|
if [ -n "$(uname -m | grep arm)" ] ; then
|
||||||
# Unapply commit cf9b4a789b855b5199e98a13424e409854a8e848 that breaks ARM
|
# Unapply commit cf9b4a789b855b5199e98a13424e409854a8e848 that breaks ARM
|
||||||
# compatibility by pointing to a recent libv8 version
|
# compatibility by pointing to a recent libv8 version
|
||||||
# This is due to this libv8 issue (https://github.com/cowboyd/libv8/issues/261)
|
# This is due to this libv8 issue (https://github.com/cowboyd/libv8/issues/261)
|
||||||
# that prevents it from being compiled on ARM hence no binary gem is available yet
|
# that prevents it from being compiled on ARM hence no binary gem is available yet
|
||||||
cp ../sources/patches_arm/* ../sources/patches
|
cp ../sources/patches_arm/* ../sources/patches
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
|
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
|
||||||
|
@ -101,35 +110,24 @@ ynh_setup_source --dest_dir="$final_path"
|
||||||
mkdir -p "$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
|
ynh_setup_source --dest_dir="$final_path/plugins/discourse-ldap-auth" --source_id=ldap-auth
|
||||||
|
|
||||||
#=================================================
|
chmod 750 "$final_path"
|
||||||
# INSTALL RUBY
|
chmod -R o-rwx "$final_path"
|
||||||
#=================================================
|
chown -R $app:www-data "$final_path"
|
||||||
ynh_script_progression --message="Installing Ruby..."
|
|
||||||
|
|
||||||
ynh_install_ruby --ruby_version=$RUBY_VERSION
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# NGINX CONFIGURATION
|
# NGINX CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Configuring NGINX web server..."
|
ynh_script_progression --message="Configuring NGINX web server..."
|
||||||
|
|
||||||
# Create a dedicated nginx config
|
# Create a dedicated NGINX config
|
||||||
ynh_add_nginx_config
|
ynh_add_nginx_config
|
||||||
|
|
||||||
# Reference: https://meta.discourse.org/t/subfolder-support-with-docker/30507?u=falco&source_topic_id=54191
|
# Reference: https://meta.discourse.org/t/subfolder-support-with-docker/30507?u=falco&source_topic_id=54191
|
||||||
if [ "$path_url" != "/" ] ; then
|
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"
|
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
|
fi
|
||||||
ynh_store_file_checksum --file="/etc/nginx/conf.d/$domain.d/$app.conf"
|
ynh_store_file_checksum --file="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# CREATE DEDICATED USER
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Configuring system user..."
|
|
||||||
|
|
||||||
# Create a system user
|
|
||||||
ynh_system_user_create --username=$app --home_dir=$final_path --use_shell
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SPECIFIC SETUP
|
# SPECIFIC SETUP
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -188,39 +186,40 @@ echo "svgo: false" > $final_path/.image_optim.yml
|
||||||
ynh_script_progression --message="Setting up Unicorn..."
|
ynh_script_progression --message="Setting up Unicorn..."
|
||||||
|
|
||||||
# Set a secret value
|
# Set a secret value
|
||||||
cp ../conf/secrets.yml "$final_path/config/secrets.yml"
|
secret="$(ynh_string_random)"
|
||||||
ynh_replace_string --match_string="__SECRET__" --replace_string="$(ynh_string_random)" --target_file="$final_path/config/secrets.yml"
|
ynh_add_config --template="../conf/secrets.yml" --destination="$final_path/config/secrets.yml"
|
||||||
# Calculate and store the config file checksum
|
|
||||||
ynh_store_file_checksum --file="$final_path/config/secrets.yml"
|
|
||||||
|
|
||||||
# Set permissions to app files
|
# Set permissions to app files
|
||||||
chown -R $app: $final_path
|
chmod 750 "$final_path"
|
||||||
|
chmod -R o-rwx "$final_path"
|
||||||
|
chown -R $app:www-data "$final_path"
|
||||||
|
|
||||||
pushd "$final_path"
|
pushd "$final_path"
|
||||||
# Install bundler, a gems installer
|
ynh_use_ruby
|
||||||
gem install bundler
|
# Install bundler, a gems installer
|
||||||
# Install without documentation
|
ynh_gem install bundler
|
||||||
exec_as $app echo "gem: --no-ri --no-rdoc" >> "$final_path/.gemrc"
|
# Install without documentation
|
||||||
|
exec_as $app echo "gem: --no-ri --no-rdoc" >> "$final_path/.gemrc"
|
||||||
popd
|
popd
|
||||||
|
|
||||||
# Specific actions on ARM architecture
|
# Specific actions on ARM architecture
|
||||||
if [ -n "$(uname -m | grep arm)" ] ; then
|
if [ -n "$(uname -m | grep arm)" ] ; then
|
||||||
# Define the platform specifically to retrieve binaries
|
# Define the platform specifically to retrieve binaries
|
||||||
# for libv8 because it currently doesn't compile on ARM devices
|
# for libv8 because it currently doesn't compile on ARM devices
|
||||||
exec_login_as $app bundle config specific_platform arm-linux
|
exec_login_as $app bin/bundle config specific_platform arm-linux
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Install dependencies
|
# Install dependencies
|
||||||
exec_login_as $app bundle config set path 'vendor/bundle'
|
exec_login_as $app bin/bundle config set path 'vendor/bundle'
|
||||||
exec_login_as $app bundle config set with 'development'
|
exec_login_as $app bin/bundle config set with 'development'
|
||||||
exec_login_as $app MAKEFLAGS=-j2 bundle install --jobs 2
|
exec_login_as $app MAKEFLAGS=-j2 bin/bundle install --jobs 2
|
||||||
|
|
||||||
# On ARM architecture, replace bundled libpsl by system native libpsl
|
# On ARM architecture, replace bundled libpsl by system native libpsl
|
||||||
# because the provided binary isn't compatible
|
# because the provided binary isn't compatible
|
||||||
if [ -n "$(uname -m | grep arm)" ] ; then
|
if [ -n "$(uname -m | grep arm)" ] ; then
|
||||||
(cd $final_path/vendor/bundle/ruby/*/gems/mini_suffix-*/vendor
|
(cd $final_path/vendor/bundle/ruby/*/gems/mini_suffix-*/vendor
|
||||||
rm libpsl.so
|
rm libpsl.so
|
||||||
ln -s $(ldconfig -p | grep libpsl | awk 'END {print $NF}') libpsl.so)
|
ln -s $(ldconfig -p | grep libpsl | awk 'END {print $NF}') libpsl.so)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -281,7 +280,7 @@ 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="__RBENVROOT__" --replace_string="$RBENV_ROOT" --target_file="../conf/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)
|
||||||
|
@ -317,11 +316,9 @@ mkdir -p "public/forum"
|
||||||
cd public/forum && ln -s ../uploads && ln -s ../backups
|
cd public/forum && ln -s ../uploads && ln -s ../backups
|
||||||
)
|
)
|
||||||
|
|
||||||
# Set permissions to app files
|
chmod 750 "$final_path"
|
||||||
chown -R $app: $final_path
|
chmod -R o-rwx "$final_path"
|
||||||
|
chown -R $app:www-data "$final_path"
|
||||||
# Restrict rights to log directory (needed by logrotate)
|
|
||||||
chmod g-w $final_path/log
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETUP LOGROTATE
|
# SETUP LOGROTATE
|
||||||
|
@ -356,14 +353,13 @@ ynh_script_progression --message="Configuring permissions..."
|
||||||
# Make app public if necessary
|
# Make app public if necessary
|
||||||
if [ $is_public -eq 1 ]
|
if [ $is_public -eq 1 ]
|
||||||
then
|
then
|
||||||
# unprotected_uris allows SSO credentials to be passed anyway.
|
|
||||||
ynh_permission_update --permission="main" --add="visitors"
|
ynh_permission_update --permission="main" --add="visitors"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RELOAD NGINX
|
# RELOAD NGINX
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Reloading nginx web server..."
|
ynh_script_progression --message="Reloading NGINX web server..."
|
||||||
|
|
||||||
ynh_systemd_action --service_name=nginx --action=reload
|
ynh_systemd_action --service_name=nginx --action=reload
|
||||||
|
|
||||||
|
|
|
@ -28,10 +28,10 @@ redis_db=$(ynh_app_setting_get --app=$app --key=redis_db)
|
||||||
# REMOVE SERVICE INTEGRATION IN YUNOHOST
|
# REMOVE SERVICE INTEGRATION IN YUNOHOST
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# Remove the service from the list of services known by Yunohost (added from `yunohost service add`)
|
# Remove the service from the list of services known by YunoHost (added from `yunohost service add`)
|
||||||
if ynh_exec_warn_less yunohost service status $app >/dev/null
|
if ynh_exec_warn_less yunohost service status $app >/dev/null
|
||||||
then
|
then
|
||||||
ynh_script_progression --message="Removing $app service..."
|
ynh_script_progression --message="Removing $app service integration..."
|
||||||
yunohost service remove $app
|
yunohost service remove $app
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -84,9 +84,9 @@ ynh_secure_remove --file="$final_path"
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE NGINX CONFIGURATION
|
# REMOVE NGINX CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Removing nginx web server configuration..."
|
ynh_script_progression --message="Removing NGINX web server configuration..."
|
||||||
|
|
||||||
# Remove the dedicated nginx config
|
# Remove the dedicated NGINX config
|
||||||
ynh_remove_nginx_config
|
ynh_remove_nginx_config
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
# IMPORT GENERIC HELPERS
|
# IMPORT GENERIC HELPERS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
#Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
|
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
|
||||||
source ../settings/scripts/_common.sh
|
source ../settings/scripts/_common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
|
@ -15,7 +15,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
|
||||||
|
@ -24,7 +23,7 @@ ynh_abort_if_errors
|
||||||
#=================================================
|
#=================================================
|
||||||
# LOAD SETTINGS
|
# LOAD SETTINGS
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Loading settings..."
|
ynh_script_progression --message="Loading installation settings..."
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
|
@ -52,10 +51,18 @@ check_memory_requirements
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE THE NGINX CONFIGURATION
|
# RESTORE THE NGINX CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Restoring the nginx configuration..."
|
ynh_script_progression --message="Restoring the NGINX web server configuration..."
|
||||||
|
|
||||||
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# RECREATE THE DEDICATED USER
|
||||||
|
#=================================================
|
||||||
|
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
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE THE APP MAIN DIR
|
# RESTORE THE APP MAIN DIR
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -63,21 +70,9 @@ ynh_script_progression --message="Restoring the app main directory..."
|
||||||
|
|
||||||
ynh_restore_file --origin_path="$final_path"
|
ynh_restore_file --origin_path="$final_path"
|
||||||
|
|
||||||
#=================================================
|
chmod 750 "$final_path"
|
||||||
# RECREATE THE DEDICATED USER
|
chmod -R o-rwx "$final_path"
|
||||||
#=================================================
|
chown -R $app:www-data "$final_path"
|
||||||
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
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# RESTORE USER RIGHTS
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Restoring user rights..."
|
|
||||||
|
|
||||||
# Restore permissions on app files
|
|
||||||
chown -R $app: $final_path
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SPECIFIC RESTORATION
|
# SPECIFIC RESTORATION
|
||||||
|
@ -88,12 +83,6 @@ ynh_script_progression --message="Reinstalling dependencies..."
|
||||||
|
|
||||||
# Define and install dependencies
|
# Define and install dependencies
|
||||||
ynh_install_app_dependencies $pkg_dependencies
|
ynh_install_app_dependencies $pkg_dependencies
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# INSTALL RUBY
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Install Ruby..."
|
|
||||||
|
|
||||||
ynh_install_ruby --ruby_version=$RUBY_VERSION
|
ynh_install_ruby --ruby_version=$RUBY_VERSION
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -101,8 +90,10 @@ ynh_install_ruby --ruby_version=$RUBY_VERSION
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Reinstall Bundle Gem..."
|
ynh_script_progression --message="Reinstall Bundle Gem..."
|
||||||
|
|
||||||
(cd "$final_path"
|
pushd "$final_path"
|
||||||
gem install bundler)
|
ynh_use_ruby
|
||||||
|
ynh_gem install bundler
|
||||||
|
popd
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE THE POSTGRESQL DATABASE
|
# RESTORE THE POSTGRESQL DATABASE
|
||||||
|
@ -124,8 +115,7 @@ ynh_psql_execute_file_as_root --file="./db.sql" --database="$db_name"
|
||||||
ynh_script_progression --message="Restoring the systemd configuration..."
|
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 daemon-reload
|
systemctl enable $app.service --quiet
|
||||||
systemctl enable $app.service
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# INTEGRATE SERVICE IN YUNOHOST
|
# INTEGRATE SERVICE IN YUNOHOST
|
||||||
|
@ -150,7 +140,7 @@ ynh_systemd_action --service_name=$app --action="start" --log_path="$final_path/
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE THE LOGROTATE CONFIGURATION
|
# RESTORE THE LOGROTATE CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Restoring logrotate configuration..."
|
ynh_script_progression --message="Restoring the logrotate configuration..."
|
||||||
|
|
||||||
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
|
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
|
||||||
|
|
||||||
|
@ -159,7 +149,7 @@ ynh_restore_file --origin_path="/etc/logrotate.d/$app"
|
||||||
#=================================================
|
#=================================================
|
||||||
# RELOAD NGINX
|
# RELOAD NGINX
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Reloading nginx web server..."
|
ynh_script_progression --message="Reloading NGINX web server..."
|
||||||
|
|
||||||
ynh_systemd_action --service_name=nginx --action=reload
|
ynh_systemd_action --service_name=nginx --action=reload
|
||||||
|
|
||||||
|
|
108
scripts/upgrade
108
scripts/upgrade
|
@ -69,7 +69,8 @@ ynh_script_progression --message="Backing up the app before upgrading (may take
|
||||||
# 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 () {
|
||||||
# restore it if the upgrade fails
|
ynh_clean_check_starting
|
||||||
|
# Restore it if the upgrade fails
|
||||||
ynh_restore_upgradebackup
|
ynh_restore_upgradebackup
|
||||||
}
|
}
|
||||||
# Exit if an error occurs during the execution of the script
|
# Exit if an error occurs during the execution of the script
|
||||||
|
@ -91,6 +92,14 @@ 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"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# CREATE DEDICATED USER
|
||||||
|
#=================================================
|
||||||
|
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
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -154,17 +163,21 @@ then
|
||||||
ynh_setup_source --dest_dir="$final_path/plugins/discourse-ldap-auth" --source_id=ldap-auth
|
ynh_setup_source --dest_dir="$final_path/plugins/discourse-ldap-auth" --source_id=ldap-auth
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
chmod 750 "$final_path"
|
||||||
|
chmod -R o-rwx "$final_path"
|
||||||
|
chown -R $app:www-data "$final_path"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# NGINX CONFIGURATION
|
# NGINX CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Upgrading nginx web server configuration..."
|
ynh_script_progression --message="Upgrading NGINX web server configuration..."
|
||||||
|
|
||||||
# Create a dedicated nginx config
|
# Create a dedicated NGINX config
|
||||||
ynh_add_nginx_config
|
ynh_add_nginx_config
|
||||||
|
|
||||||
# Reference: https://meta.discourse.org/t/subfolder-support-with-docker/30507?u=falco&source_topic_id=54191
|
# Reference: https://meta.discourse.org/t/subfolder-support-with-docker/30507?u=falco&source_topic_id=54191
|
||||||
if [ "$path_url" != "/" ] ; then
|
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"
|
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
|
fi
|
||||||
ynh_store_file_checksum --file="/etc/nginx/conf.d/$domain.d/$app.conf"
|
ynh_store_file_checksum --file="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||||
|
|
||||||
|
@ -173,22 +186,9 @@ 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"
|
ynh_install_app_dependencies $pkg_dependencies
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# INSTALL RUBY
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Installing Ruby..."
|
|
||||||
|
|
||||||
ynh_install_ruby --ruby_version=$RUBY_VERSION
|
ynh_install_ruby --ruby_version=$RUBY_VERSION
|
||||||
|
ynh_use_ruby
|
||||||
#=================================================
|
|
||||||
# CREATE DEDICATED USER
|
|
||||||
#=================================================
|
|
||||||
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
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SPECIFIC UPGRADE
|
# SPECIFIC UPGRADE
|
||||||
|
@ -259,49 +259,43 @@ then
|
||||||
# Make a backup of the original config file if modified
|
# Make a backup of the original config file if modified
|
||||||
ynh_backup_if_checksum_is_different "$unicorn_config_file"
|
ynh_backup_if_checksum_is_different "$unicorn_config_file"
|
||||||
|
|
||||||
# Calculate and store the config file checksum
|
# Calculate and store the config file checksum
|
||||||
ynh_store_file_checksum --file="$unicorn_config_file"
|
ynh_store_file_checksum --file="$unicorn_config_file"
|
||||||
|
|
||||||
secret_config_file="$final_path/config/secrets.yml"
|
secret="$(ynh_string_random)"
|
||||||
# Make a backup of the original config file if modified
|
ynh_add_config --template="../conf/secrets.yml" --destination="$final_path/config/secrets.yml"
|
||||||
ynh_backup_if_checksum_is_different "$secret_config_file"
|
|
||||||
|
|
||||||
# Set a secret value
|
|
||||||
cp ../conf/secrets.yml "$final_path/config/secrets.yml"
|
|
||||||
ynh_replace_string --match_string="__SECRET__" --replace_string="$(ynh_string_random)" --target_file="$secret_config_file"
|
|
||||||
|
|
||||||
# Calculate and store the config file checksum
|
|
||||||
ynh_store_file_checksum --file="$secret_config_file"
|
|
||||||
|
|
||||||
# Set permissions to app files
|
# Set permissions to app files
|
||||||
chown -R $app: $final_path
|
chmod 750 "$final_path"
|
||||||
|
chmod -R o-rwx "$final_path"
|
||||||
|
chown -R $app:www-data "$final_path"
|
||||||
|
|
||||||
(
|
pushd "$final_path"
|
||||||
cd "$final_path"
|
|
||||||
# Install bundler, a gems installer
|
# Install bundler, a gems installer
|
||||||
gem install bundler
|
ynh_gem install bundler
|
||||||
# Install without documentation
|
# Install without documentation
|
||||||
exec_as $app echo "gem: --no-ri --no-rdoc" >> "$final_path/.gemrc"
|
exec_as $app echo "gem: --no-ri --no-rdoc" >> "$final_path/.gemrc"
|
||||||
)
|
popd
|
||||||
|
|
||||||
# Specific actions on ARM architecture
|
# Specific actions on ARM architecture
|
||||||
if [ -n "$(uname -m | grep arm)" ] ; then
|
if [ -n "$(uname -m | grep arm)" ] ; then
|
||||||
# Define the platform specifically to retrieve binaries
|
# Define the platform specifically to retrieve binaries
|
||||||
# for libv8 because it currently doesn't compile on ARM devices
|
# for libv8 because it currently doesn't compile on ARM devices
|
||||||
exec_login_as $app bundle config specific_platform arm-linux
|
exec_login_as $app bin/bundle config specific_platform arm-linux
|
||||||
fi
|
fi
|
||||||
# Install dependencies
|
# Install dependencies
|
||||||
exec_login_as $app bundle config set path 'vendor/bundle'
|
exec_login_as $app bin/bundle config set path 'vendor/bundle'
|
||||||
exec_login_as $app bundle config set with 'development'
|
exec_login_as $app bin/bundle config set with 'development'
|
||||||
exec_login_as $app MAKEFLAGS=-j2 bundle install --jobs 2
|
exec_login_as $app MAKEFLAGS=-j2 bin/bundle install --jobs 2
|
||||||
|
|
||||||
# On ARM architecture, replace bundled libpsl by system native libpsl
|
# On ARM architecture, replace bundled libpsl by system native libpsl
|
||||||
# because the provided binary isn't compatible
|
# because the provided binary isn't compatible
|
||||||
if [ -n "$(uname -m | grep arm)" ] ; then
|
if [ -n "$(uname -m | grep arm)" ] ; then
|
||||||
(
|
(
|
||||||
cd $final_path/vendor/bundle/ruby/*/gems/mini_suffix-*/vendor
|
cd $final_path/vendor/bundle/ruby/*/gems/mini_suffix-*/vendor
|
||||||
rm libpsl.so
|
rm libpsl.so
|
||||||
ln -s $(ldconfig -p | grep libpsl | awk 'END {print $NF}') libpsl.so
|
ln -s $(ldconfig -p | grep libpsl | awk 'END {print $NF}') libpsl.so
|
||||||
)
|
)
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -338,11 +332,12 @@ fi
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETUP SYSTEMD
|
# SETUP SYSTEMD
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
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="__RBENVROOT__" --replace_string="$RBENV_ROOT" --target_file="../conf/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"
|
ynh_replace_string --match_string="__ADDITIONAL_ENV__" --replace_string="$additional_env" --target_file="../conf/systemd.service"
|
||||||
|
@ -376,9 +371,19 @@ mkdir -p "$final_path/tmp/sockets"
|
||||||
)
|
)
|
||||||
|
|
||||||
# Set permissions to app files
|
# Set permissions to app files
|
||||||
chown -R $app: $final_path
|
chmod 750 "$final_path"
|
||||||
# Restrict rights to log directory (needed by logrotate)
|
chmod -R o-rwx "$final_path"
|
||||||
chmod g-w $final_path/log
|
chown -R $app:www-data "$final_path"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# SETUP LOGROTATE
|
||||||
|
#=================================================
|
||||||
|
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"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# INTEGRATE SERVICE IN YUNOHOST
|
# INTEGRATE SERVICE IN YUNOHOST
|
||||||
|
@ -392,7 +397,6 @@ yunohost service add $app --log "$final_path/log/unicorn.stderr.log" "$final_pat
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Starting a systemd service..."
|
ynh_script_progression --message="Starting a systemd service..."
|
||||||
|
|
||||||
# Wait for discourse to be fully started
|
|
||||||
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"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -405,7 +409,7 @@ ynh_maintenance_mode_OFF
|
||||||
#=================================================
|
#=================================================
|
||||||
# RELOAD NGINX
|
# RELOAD NGINX
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Reloading nginx web server..."
|
ynh_script_progression --message="Reloading NGINX web server..."
|
||||||
|
|
||||||
ynh_systemd_action --service_name=nginx --action=reload
|
ynh_systemd_action --service_name=nginx --action=reload
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue