mirror of
https://github.com/YunoHost-Apps/mastodon_ynh.git
synced 2024-09-03 19:46:02 +02:00
Merge pull request #253 from YunoHost-Apps/upgrade
Upgrade to 3.3.0~ynh1
This commit is contained in:
commit
d3172db540
14 changed files with 164 additions and 161 deletions
13
README.md
13
README.md
|
@ -1,17 +1,17 @@
|
||||||
# Mastodon for YunoHost
|
# Mastodon for YunoHost
|
||||||
|
|
||||||
[![Integration level](https://dash.yunohost.org/integration/mastodon.svg)](https://dash.yunohost.org/appci/app/mastodon) ![](https://ci-apps.yunohost.org/ci/badges/mastodon.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/mastodon.maintain.svg)
|
[![Integration level](https://dash.yunohost.org/integration/mastodon.svg)](https://dash.yunohost.org/appci/app/mastodon) ![](https://ci-apps.yunohost.org/ci/badges/mastodon.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/mastodon.maintain.svg)
|
||||||
[![Install Mastodon with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=mastodon)
|
[![Install Mastodon with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=mastodon)
|
||||||
|
|
||||||
*[Lire ce readme en français.](./README_fr.md)*
|
*[Lire ce readme en français.](./README_fr.md)*
|
||||||
|
|
||||||
> *This package allow you to install Mastodon quickly and simply on a YunoHost server.
|
> *This package allows you to install Mastodon quickly and simply on a YunoHost server.
|
||||||
If you don't have YunoHost, please see [here](https://yunohost.org/#/install) to know how to install and enjoy it.*
|
If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/install) to learn how to install it.*
|
||||||
|
|
||||||
## Overview
|
## Overview
|
||||||
Mastodon is a free, open-source microblogging social network. It is a decentralized alternative to commercial platforms like Twitter and avoids the risks of a single company monopolizing your communication for commercial purposes.
|
Mastodon is a free, open-source microblogging social network. It is a decentralized alternative to commercial platforms like Twitter and avoids the risks of a single company monopolizing your communication for commercial purposes.
|
||||||
|
|
||||||
**Shipped version:** 3.2.2
|
**Shipped version:** 3.3.0
|
||||||
|
|
||||||
## Important points to read before installing
|
## Important points to read before installing
|
||||||
|
|
||||||
|
@ -70,10 +70,9 @@ LDAP authentication is activated. All YunoHost users can authenticate.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
Developers info
|
## Developer info
|
||||||
----------------
|
|
||||||
|
|
||||||
Please do your pull request to the [testing branch](https://github.com/YunoHost-Apps/mastodon_ynh/tree/testing).
|
Please send your pull request to the [testing branch](https://github.com/YunoHost-Apps/mastodon_ynh/tree/testing).
|
||||||
|
|
||||||
To try the testing branch, please proceed like that.
|
To try the testing branch, please proceed like that.
|
||||||
```
|
```
|
||||||
|
|
15
README_fr.md
15
README_fr.md
|
@ -1,17 +1,17 @@
|
||||||
# Mastodon pour YunoHost
|
# Mastodon pour YunoHost
|
||||||
|
|
||||||
[![Integration level](https://dash.yunohost.org/integration/mastodon.svg)](https://dash.yunohost.org/appci/app/mastodon) ![](https://ci-apps.yunohost.org/ci/badges/mastodon.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/mastodon.maintain.svg)
|
[![Niveau d'intégration](https://dash.yunohost.org/integration/mastodon.svg)](https://dash.yunohost.org/appci/app/mastodon) ![](https://ci-apps.yunohost.org/ci/badges/mastodon.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/mastodon.maintain.svg)
|
||||||
[![Install Mastodon with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=mastodon)
|
[![Installer Mastodon avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=mastodon)
|
||||||
|
|
||||||
*[Read this readme in english.](./README.md)*
|
*[Read this readme in english.](./README.md)*
|
||||||
|
|
||||||
> *Ce package vous permet d'installer Mastodon rapidement et simplement sur un serveur YunoHost.
|
> *Ce package vous permet d'installer Mastodon 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, consultez [le guide](https://yunohost.org/#/install) pour apprendre comment l'installer.*
|
||||||
|
|
||||||
## Vue d'ensemble
|
## Vue d'ensemble
|
||||||
Mastodon est un réseau social de microblog auto-hébergé et open source. C'est une alternative décentralisée aux plates-formes commerciales comme Twitter. Mastodon évite ainsi les risques qu'une seule société monopolise votre communication à des fins commerciales.
|
Mastodon est un réseau social de microblog auto-hébergé et open source. C'est une alternative décentralisée aux plates-formes commerciales comme Twitter. Mastodon évite ainsi les risques qu'une seule société monopolise votre communication à des fins commerciales.
|
||||||
|
|
||||||
**Version incluse:** 3.2.2
|
**Version incluse:** 3.3.0
|
||||||
|
|
||||||
## Points importants à lire avant l'installation
|
## Points importants à lire avant l'installation
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ L'utilisateur admin est créé automatiquement comme : user@domain.tld
|
||||||
|
|
||||||
## Caractéristiques spécifiques YunoHost
|
## Caractéristiques spécifiques YunoHost
|
||||||
|
|
||||||
#### Support multi-utilisateurs
|
#### Support multi-utilisateur
|
||||||
|
|
||||||
L'authentification LDAP est activée. Tous les utilisateurs YunoHost peuvent s'authentifier.
|
L'authentification LDAP est activée. Tous les utilisateurs YunoHost peuvent s'authentifier.
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ L'authentification LDAP est activée. Tous les utilisateurs YunoHost peuvent s'a
|
||||||
* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/mastodon%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/mastodon/)
|
* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/mastodon%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/mastodon/)
|
||||||
* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/mastodon%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/mastodon/)
|
* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/mastodon%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/mastodon/)
|
||||||
|
|
||||||
## Links
|
## Liens
|
||||||
|
|
||||||
* Signaler un bug : https://github.com/YunoHost-Apps/mastodon_ynh/issues
|
* Signaler un bug : https://github.com/YunoHost-Apps/mastodon_ynh/issues
|
||||||
* Site de l'application : https://joinmastodon.org/
|
* Site de l'application : https://joinmastodon.org/
|
||||||
|
@ -71,8 +71,7 @@ L'authentification LDAP est activée. Tous les utilisateurs YunoHost peuvent s'a
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
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/mastodon_ynh/tree/testing).
|
Merci de faire vos pull request sur la [branche testing](https://github.com/YunoHost-Apps/mastodon_ynh/tree/testing).
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
;; Nom du test
|
;; Test complet
|
||||||
auto_remove=1
|
|
||||||
; Manifest
|
; Manifest
|
||||||
domain="domain.tld" (DOMAIN)
|
domain="domain.tld" (DOMAIN)
|
||||||
admin="john" (USER)
|
admin="john" (USER)
|
||||||
|
@ -10,7 +9,7 @@
|
||||||
setup_sub_dir=0
|
setup_sub_dir=0
|
||||||
setup_root=1
|
setup_root=1
|
||||||
setup_nourl=0
|
setup_nourl=0
|
||||||
setup_private=0
|
setup_private=1
|
||||||
setup_public=1
|
setup_public=1
|
||||||
upgrade=1
|
upgrade=1
|
||||||
# 3.1.2~ynh2
|
# 3.1.2~ynh2
|
||||||
|
@ -25,15 +24,12 @@
|
||||||
upgrade=1 from_commit=248b717f373f3c82bdb19c33cf20980494608697
|
upgrade=1 from_commit=248b717f373f3c82bdb19c33cf20980494608697
|
||||||
# 3.2.1~ynh2
|
# 3.2.1~ynh2
|
||||||
upgrade=1 from_commit=74908bf3e70c134bc838c7db3ae8b5aa0938cd75
|
upgrade=1 from_commit=74908bf3e70c134bc838c7db3ae8b5aa0938cd75
|
||||||
|
# 3.2.2~ynh1
|
||||||
|
upgrade=1 from_commit=a233ccc644d97aa89756fac9f0ce68c98d81d27c
|
||||||
backup_restore=1
|
backup_restore=1
|
||||||
multi_instance=1
|
multi_instance=1
|
||||||
# This test is no longer necessary since the version 2.7 (PR: https://github.com/YunoHost/yunohost/pull/304), you can still do it if your app could be installed with this version.
|
|
||||||
# incorrect_path=1
|
|
||||||
port_already_use=0
|
port_already_use=0
|
||||||
change_url=0
|
change_url=0
|
||||||
;;; Levels
|
|
||||||
# If the level 5 (Package linter) is forced to 1. Please add justifications here.
|
|
||||||
Level 5=auto
|
|
||||||
;;; Options
|
;;; Options
|
||||||
Email=yalh@yahoo.com
|
Email=yalh@yahoo.com
|
||||||
Notification=all
|
Notification=all
|
||||||
|
@ -50,3 +46,5 @@ Notification=all
|
||||||
name=3.2.1~ynh1
|
name=3.2.1~ynh1
|
||||||
; commit=74908bf3e70c134bc838c7db3ae8b5aa0938cd75
|
; commit=74908bf3e70c134bc838c7db3ae8b5aa0938cd75
|
||||||
name=3.2.1~ynh2
|
name=3.2.1~ynh2
|
||||||
|
; commit=a233ccc644d97aa89756fac9f0ce68c98d81d27c
|
||||||
|
name=3.2.2~ynh1
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
SOURCE_URL=https://github.com/tootsuite/mastodon/archive/v3.2.2.tar.gz
|
SOURCE_URL=https://github.com/tootsuite/mastodon/archive/v3.3.0.tar.gz
|
||||||
SOURCE_SUM=298396b1bd0065689c3d9225c8466c6651979834acb4eec511057ff1ba630781
|
SOURCE_SUM=ffbaeaf18d9c440ac61c6c5c29fd6581b88c1d2843170f2cb5f0fcf8dcc0ecd6
|
||||||
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_FILENAME=
|
||||||
|
SOURCE_EXTRACT=true
|
||||||
|
|
|
@ -9,7 +9,7 @@ WorkingDirectory=__FINALPATH__/live
|
||||||
Environment="RAILS_ENV=production"
|
Environment="RAILS_ENV=production"
|
||||||
Environment="DB_POOL=25"
|
Environment="DB_POOL=25"
|
||||||
Environment="MALLOC_ARENA_MAX=2"
|
Environment="MALLOC_ARENA_MAX=2"
|
||||||
ExecStart=__RBENV_ROOT__/shims/bundle exec sidekiq -c 25
|
ExecStart=__RBENV_ROOT__/versions/__APP__/bin/bundle exec sidekiq -c 25
|
||||||
TimeoutSec=15
|
TimeoutSec=15
|
||||||
Restart=always
|
Restart=always
|
||||||
StandardError=syslog
|
StandardError=syslog
|
||||||
|
|
|
@ -8,7 +8,7 @@ User=__APP__
|
||||||
WorkingDirectory=__FINALPATH__/live
|
WorkingDirectory=__FINALPATH__/live
|
||||||
Environment="RAILS_ENV=production"
|
Environment="RAILS_ENV=production"
|
||||||
Environment="PORT=__PORT_WEB__"
|
Environment="PORT=__PORT_WEB__"
|
||||||
ExecStart=__RBENV_ROOT__/shims/bundle exec puma -C config/puma.rb
|
ExecStart=__RBENV_ROOT__/versions/__APP__/bin/bundle exec puma -C config/puma.rb
|
||||||
ExecReload=/bin/kill -SIGUSR1 $MAINPID
|
ExecReload=/bin/kill -SIGUSR1 $MAINPID
|
||||||
TimeoutSec=15
|
TimeoutSec=15
|
||||||
Restart=always
|
Restart=always
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
"en": "A libre and federated social network.",
|
"en": "A libre and federated social network.",
|
||||||
"fr": "Un réseau social libre et fédéré."
|
"fr": "Un réseau social libre et fédéré."
|
||||||
},
|
},
|
||||||
"version": "3.2.2~ynh1",
|
"version": "3.3.0~ynh1",
|
||||||
"url": "https://github.com/tootsuite/mastodon",
|
"url": "https://github.com/tootsuite/mastodon",
|
||||||
"license": "AGPL-3.0-or-later",
|
"license": "AGPL-3.0-or-later",
|
||||||
"maintainer": [
|
"maintainer": [
|
||||||
|
|
|
@ -13,6 +13,4 @@
|
||||||
|
|
||||||
## Package_check results
|
## Package_check results
|
||||||
---
|
---
|
||||||
*If you have access to [App Continuous Integration for packagers](https://yunohost.org/#/packaging_apps_ci) you can provide a link to the package_check results like below, replacing '-NUM-' in this link by the PR number and USERNAME by your username on the ci-apps-dev. Or you provide a screenshot or a pastebin of the results*
|
* An automatic package_check will be launch at https://ci-apps-dev.yunohost.org/, when you add a specific comment to your Pull Request: "!testme", "!gogogadgetoci" or "By the power of systemd, I invoke The Great App CI to test this Pull Request!"*
|
||||||
|
|
||||||
[![Build Status](https://ci-apps-dev.yunohost.org/jenkins/job/mastodon_ynh%20PR-NUM-%20(USERNAME)/badge/icon)](https://ci-apps-dev.yunohost.org/jenkins/job/mastodon_ynh%20PR-NUM-%20(USERNAME)/)
|
|
||||||
|
|
|
@ -9,15 +9,9 @@ pkg_dependencies="imagemagick ffmpeg libpq-dev libxml2-dev libxslt1-dev file git
|
||||||
|
|
||||||
MEMORY_NEEDED="2560"
|
MEMORY_NEEDED="2560"
|
||||||
|
|
||||||
if [ "$(lsb_release --codename --short)" = "buster" ]; then
|
RUBY_VERSION="2.7.2"
|
||||||
RUBY_VERSION="2.6.6"
|
BUNDLER_VERSION="1.17.3"
|
||||||
BUNDLER_VERSION="1.17.3"
|
NODEJS_VERSION="12"
|
||||||
NODEJS_VERSION="12"
|
|
||||||
else
|
|
||||||
RUBY_VERSION="2.6.5"
|
|
||||||
BUNDLER_VERSION="1.17.3"
|
|
||||||
NODEJS_VERSION="10"
|
|
||||||
fi
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# PERSONAL HELPERS
|
# PERSONAL HELPERS
|
||||||
|
|
|
@ -54,7 +54,6 @@ ynh_script_progression --message="Storing installation settings..."
|
||||||
ynh_app_setting_set --app=$app --key=domain --value=$domain
|
ynh_app_setting_set --app=$app --key=domain --value=$domain
|
||||||
ynh_app_setting_set --app=$app --key=path --value=$path_url
|
ynh_app_setting_set --app=$app --key=path --value=$path_url
|
||||||
ynh_app_setting_set --app=$app --key=admin --value=$admin
|
ynh_app_setting_set --app=$app --key=admin --value=$admin
|
||||||
ynh_app_setting_set --app=$app --key=is_public --value=$is_public
|
|
||||||
ynh_app_setting_set --app=$app --key=language --value=$language
|
ynh_app_setting_set --app=$app --key=language --value=$language
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -83,9 +82,9 @@ ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ st
|
||||||
#=================================================
|
#=================================================
|
||||||
# CREATE A POSTGRESQL DATABASE
|
# CREATE A POSTGRESQL DATABASE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Creating a MySQL database..."
|
ynh_script_progression --message="Creating a PostgreSQL database..."
|
||||||
|
|
||||||
# Create postgresql database
|
# Create PostgreSQL database
|
||||||
db_name="${app}_production"
|
db_name="${app}_production"
|
||||||
db_user=$app
|
db_user=$app
|
||||||
db_pwd=$(ynh_string_random --length=30)
|
db_pwd=$(ynh_string_random --length=30)
|
||||||
|
@ -145,8 +144,8 @@ ynh_script_progression --message="Installing Ruby..."
|
||||||
|
|
||||||
ynh_install_ruby --ruby_version=$RUBY_VERSION
|
ynh_install_ruby --ruby_version=$RUBY_VERSION
|
||||||
pushd "$final_path/live"
|
pushd "$final_path/live"
|
||||||
gem update --system
|
$RBENV_ROOT/versions/$app/bin/gem update --system
|
||||||
gem install bundler:$BUNDLER_VERSION --no-document
|
$RBENV_ROOT/versions/$app/bin/gem install bundler:$BUNDLER_VERSION --no-document
|
||||||
popd
|
popd
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -189,14 +188,14 @@ chown -R "$app": "$final_path"
|
||||||
|
|
||||||
pushd "$final_path/live"
|
pushd "$final_path/live"
|
||||||
ynh_use_nodejs
|
ynh_use_nodejs
|
||||||
sudo -u $app PATH=$PATH $RBENV_ROOT/shims/bundle config deployment 'true'
|
sudo -u $app PATH=$PATH $RBENV_ROOT/versions/$app/bin/bundle config deployment 'true'
|
||||||
sudo -u $app PATH=$PATH $RBENV_ROOT/shims/bundle config without 'development test'
|
sudo -u $app PATH=$PATH $RBENV_ROOT/versions/$app/bin/bundle config without 'development test'
|
||||||
sudo -u $app PATH=$PATH $RBENV_ROOT/shims/bundle install -j$(getconf _NPROCESSORS_ONLN)
|
sudo -u $app PATH=$PATH $RBENV_ROOT/versions/$app/bin/bundle install -j$(getconf _NPROCESSORS_ONLN)
|
||||||
sudo -u $app PATH=$PATH yarn install --pure-lockfile
|
sudo -u $app PATH=$PATH yarn install --pure-lockfile
|
||||||
echo "SAFETY_ASSURED=1">> $config
|
echo "SAFETY_ASSURED=1">> $config
|
||||||
sudo -u $app RAILS_ENV=production PATH=$PATH bin/bundle exec rails db:setup --quiet
|
sudo -u $app RAILS_ENV=production PATH=$PATH $RBENV_ROOT/versions/$app/bin/bundle exec rails db:setup --quiet
|
||||||
sudo -u $app RAILS_ENV=production PATH=$PATH bin/bundle exec rails assets:precompile --quiet
|
sudo -u $app RAILS_ENV=production PATH=$PATH $RBENV_ROOT/versions/$app/bin/bundle exec rails assets:precompile --quiet
|
||||||
sudo -u $app RAILS_ENV=production PATH=$PATH bin/bundle exec rake mastodon:webpush:generate_vapid_key > key.txt
|
sudo -u $app RAILS_ENV=production PATH=$PATH $RBENV_ROOT/versions/$app/bin/bundle exec rake mastodon:webpush:generate_vapid_key > key.txt
|
||||||
sudo -u $app RAILS_ENV=production PATH=$PATH bin/tootctl accounts create "$admin" --email="$admin_mail" --confirmed --role=admin > /dev/null
|
sudo -u $app RAILS_ENV=production PATH=$PATH bin/tootctl accounts create "$admin" --email="$admin_mail" --confirmed --role=admin > /dev/null
|
||||||
sudo -u $app RAILS_ENV=production PATH=$PATH bin/tootctl accounts modify "$admin" --approve
|
sudo -u $app RAILS_ENV=production PATH=$PATH bin/tootctl accounts modify "$admin" --approve
|
||||||
popd
|
popd
|
||||||
|
@ -253,9 +252,9 @@ chown -R "$app": "$final_path"
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Integrating service in YunoHost..."
|
ynh_script_progression --message="Integrating service in YunoHost..."
|
||||||
|
|
||||||
yunohost service add "$app-web" --description "$app web service" --log_type "systemd"
|
yunohost service add "$app-web" --description "$app web service"
|
||||||
yunohost service add "$app-sidekiq" --description "$app sidekiq service" --log_type "systemd"
|
yunohost service add "$app-sidekiq" --description "$app sidekiq service"
|
||||||
yunohost service add "$app-streaming" --description "$app streaming service" --log_type "systemd"
|
yunohost service add "$app-streaming" --description "$app streaming service"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# START SYSTEMD SERVICE
|
# START SYSTEMD SERVICE
|
||||||
|
@ -269,13 +268,14 @@ ynh_systemd_action --service_name=${app}-streaming --action="start" --log_path=s
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETUP SSOWAT
|
# SETUP SSOWAT
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Configuring SSOwat..."
|
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.
|
# Everyone can access the app.
|
||||||
ynh_app_setting_set --app=$app --key=unprotected_uris --value="/"
|
# The "main" permission is automatically created before the install script.
|
||||||
|
ynh_permission_update --permission="main" --add="visitors"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -32,19 +32,19 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||||
# 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-web" >/dev/null
|
if ynh_exec_warn_less yunohost service status "$app-web" >/dev/null
|
||||||
then
|
then
|
||||||
ynh_script_progression --message="Removing $app-web service..."
|
ynh_script_progression --message="Removing $app-web service integration..."
|
||||||
yunohost service remove "$app-web"
|
yunohost service remove "$app-web"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ynh_exec_warn_less yunohost service status "$app-sidekiq" >/dev/null
|
if ynh_exec_warn_less yunohost service status "$app-sidekiq" >/dev/null
|
||||||
then
|
then
|
||||||
ynh_script_progression --message="Removing $app-sidekiq service..."
|
ynh_script_progression --message="Removing $app-sidekiq service integration..."
|
||||||
yunohost service remove "$app-sidekiq"
|
yunohost service remove "$app-sidekiq"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ynh_exec_warn_less yunohost service status "$app-streaming" >/dev/null
|
if ynh_exec_warn_less yunohost service status "$app-streaming" >/dev/null
|
||||||
then
|
then
|
||||||
ynh_script_progression --message="Removing $app-streaming service..."
|
ynh_script_progression --message="Removing $app-streaming service integration..."
|
||||||
yunohost service remove "$app-streaming"
|
yunohost service remove "$app-streaming"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,6 @@ source /usr/share/yunohost/helpers
|
||||||
#=================================================
|
#=================================================
|
||||||
# MANAGE SCRIPT FAILURE
|
# MANAGE SCRIPT FAILURE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Managing script failure..."
|
|
||||||
|
|
||||||
ynh_clean_setup () {
|
ynh_clean_setup () {
|
||||||
ynh_clean_check_starting
|
ynh_clean_check_starting
|
||||||
|
@ -135,16 +134,16 @@ ynh_script_progression --message="Restoring the systemd configuration..."
|
||||||
ynh_restore_file --origin_path="/etc/systemd/system/$app-web.service"
|
ynh_restore_file --origin_path="/etc/systemd/system/$app-web.service"
|
||||||
ynh_restore_file --origin_path="/etc/systemd/system/$app-sidekiq.service"
|
ynh_restore_file --origin_path="/etc/systemd/system/$app-sidekiq.service"
|
||||||
ynh_restore_file --origin_path="/etc/systemd/system/$app-streaming.service"
|
ynh_restore_file --origin_path="/etc/systemd/system/$app-streaming.service"
|
||||||
systemctl enable "$app-web" "$app-sidekiq" "$app-streaming"
|
systemctl enable "$app-web" "$app-sidekiq" "$app-streaming" --quiet
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# INTEGRATE SERVICE IN YUNOHOST
|
# INTEGRATE SERVICE IN YUNOHOST
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Integrating service in YunoHost..."
|
ynh_script_progression --message="Integrating service in YunoHost..."
|
||||||
|
|
||||||
yunohost service add "$app-web" --description "$app web service" --log_type "systemd"
|
yunohost service add "$app-web" --description "$app web service"
|
||||||
yunohost service add "$app-sidekiq" --description "$app sidekiq service" --log_type "systemd"
|
yunohost service add "$app-sidekiq" --description "$app sidekiq service"
|
||||||
yunohost service add "$app-streaming" --description "$app streaming service" --log_type "systemd"
|
yunohost service add "$app-streaming" --description "$app streaming service"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# START SYSTEMD SERVICE
|
# START SYSTEMD SERVICE
|
||||||
|
@ -167,7 +166,7 @@ ynh_restore_file --origin_path="/etc/cron.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
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,6 @@ app=$YNH_APP_INSTANCE_NAME
|
||||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||||
path_url=$(ynh_app_setting_get --app=$app --key=path)
|
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)
|
||||||
is_public=$(ynh_app_setting_get --app=$app --key=is_public)
|
|
||||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||||
language=$(ynh_app_setting_get --app=$app --key=language)
|
language=$(ynh_app_setting_get --app=$app --key=language)
|
||||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||||
|
@ -37,6 +36,8 @@ otp_secret=$(ynh_app_setting_get --app=$app --key=otp_secret)
|
||||||
vapid_private_key=$(ynh_app_setting_get --app=$app --key=vapid_private_key)
|
vapid_private_key=$(ynh_app_setting_get --app=$app --key=vapid_private_key)
|
||||||
vapid_public_key=$(ynh_app_setting_get --app=$app --key=vapid_public_key)
|
vapid_public_key=$(ynh_app_setting_get --app=$app --key=vapid_public_key)
|
||||||
|
|
||||||
|
config="$final_path/live/.env.production"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CHECK VERSION
|
# CHECK VERSION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -49,39 +50,27 @@ upgrade_type=$(ynh_check_app_version_changed)
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Ensuring downward compatibility..."
|
ynh_script_progression --message="Ensuring downward compatibility..."
|
||||||
|
|
||||||
config="$final_path/live/.env.production"
|
|
||||||
|
|
||||||
# If db_name doesn't exist, create it
|
# Cleaning legacy permissions
|
||||||
if [ -z "$db_name" ]; then
|
if ynh_legacy_permissions_exists; then
|
||||||
db_name="${app}_production"
|
ynh_legacy_permissions_delete_all
|
||||||
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
|
|
||||||
|
ynh_app_setting_delete --app=$app --key=is_public
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# If final_path doesn't exist, create it
|
# If port_web doesn't exist, create it, needed for old install
|
||||||
if [ -z "$final_path" ]; then
|
|
||||||
final_path=/var/www/$app
|
|
||||||
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Check if admin is not null
|
|
||||||
if [[ "$admin" = "" || "$language" = "" ]]; then
|
|
||||||
echo "Unable to upgrade, please contact support"
|
|
||||||
ynh_die
|
|
||||||
fi
|
|
||||||
|
|
||||||
# If port_web doesn't exist, create it, need for old install
|
|
||||||
if [[ -z "$port_web" ]]; then
|
if [[ -z "$port_web" ]]; then
|
||||||
port_web=3000
|
port_web=3000
|
||||||
ynh_app_setting_set --app=$app --key=port_web --value=$port_web
|
ynh_app_setting_set --app=$app --key=port_web --value=$port_web
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# If port_web doesn't exist, create it, need for old install
|
# If port_web doesn't exist, create it, needed for old install
|
||||||
if [[ -z "$port_stream" ]]; then
|
if [[ -z "$port_stream" ]]; then
|
||||||
port_stream=4000
|
port_stream=4000
|
||||||
ynh_app_setting_set --app=$app --key=port_stream --value=$port_stream
|
ynh_app_setting_set --app=$app --key=port_stream --value=$port_stream
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# If db_pwd doesn't exist, create it, need for old install
|
# If db_pwd doesn't exist, create it, needed for old install
|
||||||
if [[ -z "$db_pwd" ]]; then
|
if [[ -z "$db_pwd" ]]; then
|
||||||
db_pwd=$(ynh_string_random)
|
db_pwd=$(ynh_string_random)
|
||||||
ynh_app_setting_set --app=$app --key=db_pwd --value=$db_pwd
|
ynh_app_setting_set --app=$app --key=db_pwd --value=$db_pwd
|
||||||
|
@ -143,18 +132,6 @@ ynh_clean_setup () {
|
||||||
# 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
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# CHECK THE PATH
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
# Normalize the URL path syntax
|
|
||||||
# N.B. : this is for app installations before YunoHost 2.7
|
|
||||||
# where this value might be something like /foo/ or foo/
|
|
||||||
# instead of /foo ....
|
|
||||||
# If nobody installed your app before 2.7, then you may
|
|
||||||
# safely remove this line
|
|
||||||
path_url=$(ynh_normalize_url_path --path_url=$path_url)
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STANDARD UPGRADE STEPS
|
# STANDARD UPGRADE STEPS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -201,6 +178,7 @@ fi
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Upgrading nginx web server configuration..."
|
ynh_script_progression --message="Upgrading nginx web server configuration..."
|
||||||
|
|
||||||
|
# Create a dedicated NGINX config
|
||||||
ynh_add_nginx_config 'port_web port_stream'
|
ynh_add_nginx_config 'port_web port_stream'
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -284,13 +262,13 @@ chown -R "$app": "$final_path"
|
||||||
|
|
||||||
pushd "$final_path/live"
|
pushd "$final_path/live"
|
||||||
ynh_use_nodejs
|
ynh_use_nodejs
|
||||||
sudo -u $app PATH=$PATH $RBENV_ROOT/shims/bundle config deployment 'true'
|
sudo -u $app PATH=$PATH $RBENV_ROOT/versions/$app/bin/bundle config deployment 'true'
|
||||||
sudo -u $app PATH=$PATH $RBENV_ROOT/shims/bundle config without 'development test'
|
sudo -u $app PATH=$PATH $RBENV_ROOT/versions/$app/bin/bundle config without 'development test'
|
||||||
sudo -u $app PATH=$PATH $RBENV_ROOT/shims/bundle install -j$(getconf _NPROCESSORS_ONLN)
|
sudo -u $app PATH=$PATH $RBENV_ROOT/versions/$app/bin/bundle install -j$(getconf _NPROCESSORS_ONLN)
|
||||||
sudo -u $app PATH=$PATH yarn install --pure-lockfile
|
sudo -u $app PATH=$PATH yarn install --pure-lockfile
|
||||||
sudo -u $app RAILS_ENV=production PATH=$PATH bin/bundle exec rails assets:clean
|
sudo -u $app RAILS_ENV=production PATH=$PATH $RBENV_ROOT/versions/$app/bin/bundle exec rails assets:clean
|
||||||
sudo -u $app RAILS_ENV=production PATH=$PATH bin/bundle exec rails assets:precompile
|
sudo -u $app RAILS_ENV=production PATH=$PATH $RBENV_ROOT/versions/$app/bin/bundle exec rails assets:precompile
|
||||||
sudo -u $app RAILS_ENV=production PATH=$PATH bin/bundle exec rails db:migrate
|
sudo -u $app RAILS_ENV=production PATH=$PATH $RBENV_ROOT/versions/$app/bin/bundle exec rails db:migrate
|
||||||
sudo -u $app RAILS_ENV=production PATH=$PATH bin/tootctl cache clear
|
sudo -u $app RAILS_ENV=production PATH=$PATH bin/tootctl cache clear
|
||||||
popd
|
popd
|
||||||
|
|
||||||
|
@ -315,15 +293,6 @@ ynh_add_systemd_config --service="$app-web" --template="mastodon-web.service" --
|
||||||
ynh_add_systemd_config --service="$app-sidekiq" --template="mastodon-sidekiq.service" --others_var="RBENV_ROOT"
|
ynh_add_systemd_config --service="$app-sidekiq" --template="mastodon-sidekiq.service" --others_var="RBENV_ROOT"
|
||||||
ynh_add_systemd_config --service="$app-streaming" --template="mastodon-streaming.service" --others_var="port_stream ynh_node_load_PATH ynh_node"
|
ynh_add_systemd_config --service="$app-streaming" --template="mastodon-streaming.service" --others_var="port_stream ynh_node_load_PATH ynh_node"
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# INTEGRATE SERVICE IN YUNOHOST
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Integrating service in YunoHost..."
|
|
||||||
|
|
||||||
yunohost service add "$app-web" --description "$app web service" --log_type "systemd"
|
|
||||||
yunohost service add "$app-sidekiq" --description "$app sidekiq service" --log_type "systemd"
|
|
||||||
yunohost service add "$app-streaming" --description "$app streaming service" --log_type "systemd"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# GENERIC FINALIZATION
|
# GENERIC FINALIZATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -335,16 +304,13 @@ ynh_script_progression --message="Securing files and directories..."
|
||||||
chown -R $app: $final_path
|
chown -R $app: $final_path
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETUP SSOWAT
|
# INTEGRATE SERVICE IN YUNOHOST
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Upgrading SSOwat configuration..."
|
ynh_script_progression --message="Integrating service in YunoHost..."
|
||||||
|
|
||||||
# Make app public if necessary
|
yunohost service add "$app-web" --description "$app web service"
|
||||||
if [ $is_public -eq 1 ]
|
yunohost service add "$app-sidekiq" --description "$app sidekiq service"
|
||||||
then
|
yunohost service add "$app-streaming" --description "$app streaming service"
|
||||||
# unprotected_uris allows SSO credentials to be passed anyway
|
|
||||||
ynh_app_setting_set --app=$app --key=unprotected_uris --value="/"
|
|
||||||
fi
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# START SYSTEMD SERVICE
|
# START SYSTEMD SERVICE
|
||||||
|
|
|
@ -2,30 +2,41 @@
|
||||||
|
|
||||||
# Need also the helper https://github.com/YunoHost-Apps/Experimental_helpers/blob/master/ynh_handle_getopts_args/ynh_handle_getopts_args
|
# Need also the helper https://github.com/YunoHost-Apps/Experimental_helpers/blob/master/ynh_handle_getopts_args/ynh_handle_getopts_args
|
||||||
|
|
||||||
|
rbenv_version=1.1.2
|
||||||
|
rbenv_rubybuild_version=20201225
|
||||||
|
rbenv_aliases_version=1.1.0
|
||||||
rbenv_install_dir="/opt/rbenv"
|
rbenv_install_dir="/opt/rbenv"
|
||||||
# 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
|
# Install Ruby Version Management
|
||||||
#
|
#
|
||||||
# [internal]
|
# [internal]
|
||||||
#
|
#
|
||||||
# usage: ynh_install_rbenv
|
# usage: ynh_install_rbenv
|
||||||
ynh_install_rbenv () {
|
ynh_install_rbenv () {
|
||||||
echo "Installation of rbenv - ruby version management" >&2
|
ynh_print_info --message="Installation of rbenv - Ruby Version Management - rbenv-${rbenv_version}/ruby-build-${rbenv_rubybuild_version}"
|
||||||
|
|
||||||
# Build an app.src for rbenv
|
# Build an app.src for rbenv
|
||||||
mkdir -p "../conf"
|
mkdir -p "../conf"
|
||||||
echo "SOURCE_URL=https://github.com/rbenv/rbenv/archive/v1.1.2.tar.gz
|
echo "SOURCE_URL=https://github.com/rbenv/rbenv/archive/v${rbenv_version}.tar.gz
|
||||||
SOURCE_SUM=80ad89ffe04c0b481503bd375f05c212bbc7d44ef5f5e649e0acdf25eba86736" > "../conf/rbenv.src"
|
SOURCE_SUM=80ad89ffe04c0b481503bd375f05c212bbc7d44ef5f5e649e0acdf25eba86736" > "../conf/rbenv.src"
|
||||||
# Download and extract rbenv
|
# Download and extract rbenv
|
||||||
ynh_setup_source "$rbenv_install_dir" rbenv
|
ynh_setup_source --dest_dir="$rbenv_install_dir" --source_id=rbenv
|
||||||
|
|
||||||
# Build an app.src for ruby-build
|
# Build an app.src for ruby-build
|
||||||
mkdir -p "../conf"
|
mkdir -p "../conf"
|
||||||
echo "SOURCE_URL=https://github.com/rbenv/ruby-build/archive/v20200520.tar.gz
|
echo "SOURCE_URL=https://github.com/rbenv/ruby-build/archive/v${rbenv_rubybuild_version}.tar.gz
|
||||||
SOURCE_SUM=52be6908a94fbd4a94f5064e8b19d4a3baa4b773269c3884165518d83bcc8922" > "../conf/ruby-build.src"
|
SOURCE_SUM=54cae123c2758e7714c66aca7ef8bc7f29cda8583891191ceb3053c6d098ecf1" > "../conf/ruby-build.src"
|
||||||
# Download and extract ruby-build
|
# Download and extract ruby-build
|
||||||
ynh_setup_source "$rbenv_install_dir/plugins/ruby-build" ruby-build
|
ynh_setup_source --dest_dir="$rbenv_install_dir/plugins/ruby-build" --source_id=ruby-build
|
||||||
|
|
||||||
|
# Build an app.src for ruby-build
|
||||||
|
mkdir -p "../conf"
|
||||||
|
echo "SOURCE_URL=https://github.com/tpope/rbenv-aliases/archive/v${rbenv_aliases_version}.tar.gz
|
||||||
|
SOURCE_SUM=12e89bc4499e85d8babac2b02bc8b66ceb0aa3f8047b26728a3eca8a6030273d" > "../conf/rbenv-aliases.src"
|
||||||
|
# Download and extract ruby-build
|
||||||
|
ynh_setup_source --dest_dir="$rbenv_install_dir/plugins/rbenv-aliases" --source_id=rbenv-aliases
|
||||||
|
|
||||||
(cd $rbenv_install_dir
|
(cd $rbenv_install_dir
|
||||||
./src/configure && make -C src)
|
./src/configure && make -C src)
|
||||||
|
@ -36,12 +47,12 @@ if [ ! -d $rbenv_install_dir/shims ] ; then
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# 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>)
|
# 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
|
# 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)
|
||||||
|
@ -51,38 +62,41 @@ 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.
|
|
||||||
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= )
|
declare -Ar args_array=( [v]=ruby_version= )
|
||||||
# Use rbenv, https://github.com/rbenv/rbenv to manage the ruby versions
|
|
||||||
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
|
# Store ruby_version into the config of this app
|
||||||
|
ynh_app_setting_set --app=$YNH_APP_INSTANCE_NAME --key=ruby_version --value=$ruby_version
|
||||||
|
|
||||||
|
# Create $rbenv_install_dir if doesn't exist already
|
||||||
mkdir -p "$rbenv_install_dir/plugins/ruby-build"
|
mkdir -p "$rbenv_install_dir/plugins/ruby-build"
|
||||||
|
|
||||||
|
# Create the file if doesn't exist already
|
||||||
|
touch "$rbenv_install_dir/ynh_app_version"
|
||||||
|
|
||||||
# Load rbenv path in PATH
|
# Load rbenv path in PATH
|
||||||
CLEAR_PATH="$rbenv_install_dir/bin:$PATH"
|
CLEAR_PATH="$rbenv_install_dir/bin:$PATH"
|
||||||
|
|
||||||
# Remove /usr/local/bin in PATH in case of ruby prior installation
|
# Remove /usr/local/bin in PATH in case of Ruby prior installation
|
||||||
PATH=$(echo $CLEAR_PATH | sed 's@/usr/local/bin:@@')
|
PATH=$(echo $CLEAR_PATH | sed 's@/usr/local/bin:@@')
|
||||||
|
|
||||||
# Move an existing ruby binary, to avoid to block rbenv
|
# Move an existing Ruby binary, to avoid to block rbenv
|
||||||
test -x /usr/bin/ruby && mv /usr/bin/ruby /usr/bin/ruby_rbenv
|
test -x /usr/bin/ruby && mv /usr/bin/ruby /usr/bin/ruby_rbenv
|
||||||
|
|
||||||
# If rbenv is not previously setup, install it
|
# If rbenv is not previously setup, install it
|
||||||
if ! type rbenv > /dev/null 2>&1
|
if ! type rbenv > /dev/null 2>&1
|
||||||
then
|
then
|
||||||
ynh_install_rbenv
|
ynh_install_rbenv
|
||||||
elif dpkg --compare-versions "$($rbenv_install_dir/bin/rbenv --version | cut -d" " -f2)" lt "1.1.2"
|
elif dpkg --compare-versions "$($rbenv_install_dir/bin/rbenv --version | cut -d" " -f2)" lt ${rbenv_version}
|
||||||
then
|
then
|
||||||
ynh_install_rbenv
|
ynh_install_rbenv
|
||||||
elif dpkg --compare-versions "$($rbenv_install_dir/plugins/ruby-build/bin/ruby-build --version | cut -d" " -f2)" lt "20200520"
|
elif dpkg --compare-versions "$($rbenv_install_dir/plugins/ruby-build/bin/ruby-build --version | cut -d" " -f2)" lt ${rbenv_rubybuild_version}
|
||||||
then
|
then
|
||||||
ynh_install_rbenv
|
ynh_install_rbenv
|
||||||
fi
|
fi
|
||||||
|
@ -90,57 +104,92 @@ ynh_install_ruby () {
|
||||||
# Restore /usr/local/bin in PATH (if needed)
|
# Restore /usr/local/bin in PATH (if needed)
|
||||||
PATH=$CLEAR_PATH
|
PATH=$CLEAR_PATH
|
||||||
|
|
||||||
# And replace the old ruby binary
|
# And replace the old Ruby binary
|
||||||
test -x /usr/bin/ruby_rbenv && mv /usr/bin/ruby_rbenv /usr/bin/ruby
|
test -x /usr/bin/ruby_rbenv && mv /usr/bin/ruby_rbenv /usr/bin/ruby
|
||||||
|
|
||||||
# Install the requested version of ruby
|
# Install the requested version of Ruby
|
||||||
|
ynh_print_info --message="Installation of Ruby-"$ruby_version
|
||||||
CONFIGURE_OPTS="--disable-install-doc --with-jemalloc" MAKE_OPTS="-j2" rbenv install --skip-existing $ruby_version
|
CONFIGURE_OPTS="--disable-install-doc --with-jemalloc" MAKE_OPTS="-j2" rbenv install --skip-existing $ruby_version
|
||||||
|
|
||||||
# Store the ID of this app and the version of ruby requested for it
|
# Do not add twice the same line
|
||||||
echo "$YNH_APP_ID:$ruby_version" | tee --append "$rbenv_install_dir/ynh_app_version"
|
if ! grep --quiet "$YNH_APP_INSTANCE_NAME:$ruby_version" "$rbenv_install_dir/ynh_app_version"
|
||||||
|
then
|
||||||
|
|
||||||
# Store ruby_version into the config of this app
|
# Remove previous version
|
||||||
ynh_app_setting_set $app ruby_version $ruby_version
|
if grep --quiet "$YNH_APP_INSTANCE_NAME:" "$rbenv_install_dir/ynh_app_version"
|
||||||
|
then
|
||||||
|
if grep --quiet "$YNH_APP_INSTANCE_NAME" $(rbenv alias --list)
|
||||||
|
then
|
||||||
|
rbenv alias $YNH_APP_INSTANCE_NAME --remove
|
||||||
|
fi
|
||||||
|
sed --in-place "/$YNH_APP_INSTANCE_NAME:/d" "$rbenv_install_dir/ynh_app_version"
|
||||||
|
fi
|
||||||
|
|
||||||
# Set environment for ruby users
|
# Store the ID of this app and the version of Ruby requested for it
|
||||||
|
echo "$YNH_APP_INSTANCE_NAME:$ruby_version" | tee --append "$rbenv_install_dir/ynh_app_version"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Remove no more needed Ruby version
|
||||||
|
installed_ruby_version=$(rbenv versions --bare --skip-aliases | grep -Ev '/')
|
||||||
|
for installed_version in $installed_ruby_version
|
||||||
|
do
|
||||||
|
if ! grep --quiet "$installed_version" "$rbenv_install_dir/ynh_app_version"
|
||||||
|
then
|
||||||
|
ynh_print_info --message="Removing of ruby-"$installed_version
|
||||||
|
$rbenv_install_dir/bin/rbenv uninstall --force $installed_version
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# Set environment for Ruby users
|
||||||
echo "#rbenv
|
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
|
(cd $final_path
|
||||||
rbenv local $ruby_version)
|
rbenv local $ruby_version)
|
||||||
|
|
||||||
|
rbenv alias $YNH_APP_INSTANCE_NAME $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 check if another app uses the same version of Ruby,
|
||||||
# if not, this version of ruby will be removed.
|
# if not, this version of Ruby will be removed.
|
||||||
# If no other app uses ruby, rbenv will be also 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)
|
||||||
|
|
||||||
|
# Load rbenv path in PATH
|
||||||
|
CLEAR_PATH="$rbenv_install_dir/bin:$PATH"
|
||||||
|
|
||||||
|
# Remove /usr/local/bin in PATH in case of Ruby prior installation
|
||||||
|
PATH=$(echo $CLEAR_PATH | sed 's@/usr/local/bin:@@')
|
||||||
|
|
||||||
|
rbenv alias $YNH_APP_INSTANCE_NAME --remove
|
||||||
|
|
||||||
# Remove the line for this app
|
# Remove the line for this app
|
||||||
sed --in-place "/$YNH_APP_ID:$ruby_version/d" "$rbenv_install_dir/ynh_app_version"
|
sed --in-place "/$YNH_APP_INSTANCE_NAME:$ruby_version/d" "$rbenv_install_dir/ynh_app_version"
|
||||||
|
|
||||||
# If no other app uses this version of ruby, remove it.
|
# If no other app uses this version of Ruby, remove it.
|
||||||
if ! grep --quiet "$ruby_version" "$rbenv_install_dir/ynh_app_version"
|
if ! grep --quiet "$ruby_version" "$rbenv_install_dir/ynh_app_version"
|
||||||
then
|
then
|
||||||
|
ynh_print_info --message="Removing of Ruby-"$ruby_version
|
||||||
$rbenv_install_dir/bin/rbenv uninstall --force $ruby_version
|
$rbenv_install_dir/bin/rbenv uninstall --force $ruby_version
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Remove rbenv environment configuration
|
|
||||||
rm /etc/profile.d/rbenv.sh
|
|
||||||
|
|
||||||
# If no other app uses rbenv, remove rbenv and dedicated group
|
# If no other app uses rbenv, remove rbenv and dedicated group
|
||||||
if [ ! -s "$rbenv_install_dir/ynh_app_version" ]
|
if [ ! -s "$rbenv_install_dir/ynh_app_version" ]
|
||||||
then
|
then
|
||||||
ynh_secure_remove "$rbenv_install_dir"
|
ynh_print_info --message="Removing of rbenv"
|
||||||
|
ynh_secure_remove --file="$rbenv_install_dir"
|
||||||
|
# Remove rbenv environment configuration
|
||||||
|
rm /etc/profile.d/rbenv.sh
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue