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

Merge pull request #8 from YunoHost-Apps/testing

3.6.8~ynh1
This commit is contained in:
Fabian Wilkens 2021-05-13 09:07:03 +02:00 committed by GitHub
commit 4cd4dfcf8b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
22 changed files with 684 additions and 322 deletions

56
.github/ISSUE_TEMPLATE.md vendored Normal file
View file

@ -0,0 +1,56 @@
---
name: Bug report
about: When creating a bug report, please use the following template to provide all the relevant information and help debugging efficiently.
---
**How to post a meaningful bug report**
1. *Read this whole template first.*
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!*
- *Otherwise, the issue may be due to the app itself. Refer to its documentation or repository for help.*
- *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.*
---
### Describe the bug
*A clear and concise description of what the bug is.*
### Context
- Hardware: *VPS bought online / Old laptop or computer / Raspberry Pi at home / Internet Cube with VPN / Other ARM board / ...*
- YunoHost version: x.x.x
- I have access to my server: *Through SSH | through the webadmin | direct access via keyboard / screen | ...*
- Are you in a special context or did you perform some particular tweaking on your YunoHost instance?: *no / yes*
- If yes, please explain:
- Using, or trying to install package version/branch:
- If upgrading, current package version: *can be found in the admin, or with `yunohost app info $app_id`*
### Steps to reproduce
- *If you performed a command from the CLI, the command itself is enough. For example:*
```sh
sudo yunohost app install the_app
```
- *If you used the webadmin, please perform the equivalent command from the CLI first.*
- *If the error occurs in your browser, explain what you did:*
1. *Go to '...'*
2. *Click on '...'*
3. *Scroll down to '...'*
4. *See error*
### Expected behavior
*A clear and concise description of what you expected to happen. You can remove this section if the command above is enough to understand your intent.*
### Logs
*When an operation fails, YunoHost provides a simple way to share the logs.*
- *In the webadmin, the error message contains a link to the relevant log page. On that page, you will be able to 'Share with Yunopaste'. If you missed it, the logs of previous operations are also available under Tools > Logs.*
- *In command line, the command to share the logs is displayed at the end of the operation and looks like `yunohost log display [log name] --share`. If you missed it, you can find the log ID of a previous operation using `yunohost log list`.*
*After sharing the log, please copypaste directly the link provided by YunoHost (to help readability, no need to copypaste the entire content of the log here, just the link is enough...)*
*If applicable and useful, add screenshots to help explain your problem.*

17
.github/PULL_REQUEST_TEMPLATE.md vendored Normal file
View file

@ -0,0 +1,17 @@
## Problem
- *Description of why you made this PR*
## Solution
- *And how do you fix that problem*
## PR Status
- [ ] Code finished and ready to be reviewed/tested
- [ ] The fix/enhancement were manually tested (if applicable)
## Automatic tests
Automatic tests can be triggered on https://ci-apps-dev.yunohost.org/ *after creating the PR*, by commenting "!testme", "!gogogadgetoci" or "By the power of systemd, I invoke The Great App CI to test this Pull Request!". (N.B. : for this to work you need to be a member of the Yunohost-Apps organization)

126
README.md
View file

@ -1,72 +1,68 @@
# Standard Notes Web App for YunoHost
[![Integration level](https://dash.yunohost.org/integration/snweb.svg)](https://dash.yunohost.org/appci/app/snweb)
[![Install snweb with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=snweb)
> *This package allow you to install snweb 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.*
## Overview
Standard Notes
A safe and private place for your life's work.
Standard Notes is a simple and private notes app available on most platforms, including Web, Mac, Windows, Linux, iOS, and Android. It focuses on simplicity, and encrypts data locally before it ever touches a cloud. This means no one can read your notes but you (not even us).
**Shipped version:** 3.6.2
* Apps available for free. https://standardnotes.org/
* Desktop (Windows, Mac, Linux)
* Mobile (Android and iOS)
* Web https://app.standardnotes.org/
* Self-Hosted Yunohost - Syncing Server https://github.com/YunoHost-Apps/snweb_ynh
## Screenshots
![](https://camo.githubusercontent.com/ca3744729c6c33f2f42d7917a4e7167c12a786615e14d1719f7d1ec6ed77aae8/68747470733a2f2f7374616e646172646e6f7465732e6f72672f6173736574732f686f6d65706167652d6865726f2e706e67)
Extensions, Editors, Themes: https://standardnotes.org/extensions
## Demo
* [Official demo - Web App](https://standardnotes.org/demo)
## Configuration
How to configure this app:
* The config-file is stored under "/opt/yunohost/$app/live/.env"
## Documentation
* Official Help & Support: https://standardnotes.org/help
* Official documentation: https://docs.standardnotes.org (Only delevopment documentation)
## YunoHost specific features
#### Multi-users support
Are LDAP and HTTP auth supported? LDAP -> NO, HTTP auth -> Yes
Can the app be used by multiple users? Yes
#### Supported architectures
* x86-64b - [![Build Status](https://ci-apps.yunohost.org/ci/logs/snweb%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/snweb/)
* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/snweb%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/snweb/)
## Links
* Report a bug: https://github.com/YunoHost-Apps/snweb_ynh/issues
* App website: https://standardnotes.org/
* Upstream app repository: https://github.com/standardnotes/web
* YunoHost website: https://yunohost.org/
---
Developers info
----------------
<!--
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.
-->
**Only if you want to use a testing branch for coding, instead of merging directly into master.**
Please do your pull request to the [testing branch](https://github.com/YunoHost-Apps/snweb_ynh/tree/testing).
# Standard Notes for YunoHost
[![Integration level](https://dash.yunohost.org/integration/snweb.svg)](https://dash.yunohost.org/appci/app/snweb) ![](https://ci-apps.yunohost.org/ci/badges/snweb.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/snweb.maintain.svg)
[![Install snweb with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=snweb)
*[Lire ce readme en français.](./README_fr.md)*
> *This package allows you to install snweb 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.*
## Overview
The Standard Notes Web App. An end-to-end encrypted note-taking app. Web, Mac, Windows, Linux, iOS, and Android.
**Shipped version:** 3.22.8~ynh2
**Demo:** https://standardnotes.org/demo
## Screenshots
![](./doc/screenshots/standard_notes.png)
## Disclaimers / important information
* Any known limitations, constrains or stuff not working, such as (but not limited to):
* No single-sign on or LDAP integration
* The app requires up 1500MB of RAM to install
* The app requires at least 80MB of RAM to work properly.
* The app requires around 1000MB of disk.
* A dedicated domain is requierd if you want to use extensions.
notes.your-domain.tld/ -> Extension Manager is working
your-domain.tld/notes/ -> Extension Manager is not working
* Other infos that people should be aware of, such as:
* The config-file is stored under "/opt/yunohost/$app/live/.env"
* You can find additional config features under https://your-domain.tld/yunohost/admin/#/apps/$app/config-panel
## Documentation and resources
* Official app website: https://standardnotes.org/
* Official user documentation: https://standardnotes.org/help
* Official admin documentation: https://docs.standardnotes.org/
* Upstream app code repository: https://github.com/standardnotes/web
* YunoHost documentation for this app: https://yunohost.org/app_snweb
* Report a bug: https://github.com/YunoHost-Apps/snweb_ynh/issues
## Developer info
Please send your pull request to the [testing branch](https://github.com/YunoHost-Apps/snweb_ynh/tree/testing).
To try the testing branch, please proceed like that.
```
@ -74,3 +70,5 @@ sudo yunohost app install https://github.com/YunoHost-Apps/snweb_ynh/tree/testin
or
sudo yunohost app upgrade snweb -u https://github.com/YunoHost-Apps/snweb_ynh/tree/testing --debug
```
**More info regarding app packaging:** https://yunohost.org/packaging_apps

66
README_fr.md Normal file
View file

@ -0,0 +1,66 @@
# Standard Notes pour YunoHost
[![Niveau d'intégration](https://dash.yunohost.org/integration/snweb.svg)](https://dash.yunohost.org/appci/app/snweb) ![](https://ci-apps.yunohost.org/ci/badges/snweb.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/snweb.maintain.svg)
[![Installer snweb avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=snweb)
*[Read this readme in english.](./README.md)*
*[Lire ce readme en français.](./README_fr.md)*
> *This package allows you to install snweb 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.*
## Vue d'ensemble
**Version incluse:** 3.22.8~ynh2
**Démo:** https://standardnotes.org/demo
## Captures d'écran
![](./doc/screenshots/standard_notes.png)
## Avertissements / informations importantes
* Any known limitations, constrains or stuff not working, such as (but not limited to):
* No single-sign on or LDAP integration
* The app requires up 1500MB of RAM to install
* The app requires at least 80MB of RAM to work properly.
* The app requires around 1000MB of disk.
* A dedicated domain is requierd if you want to use extensions.
notes.your-domain.tld/ -> Extension Manager is working
your-domain.tld/notes/ -> Extension Manager is not working
* Other infos that people should be aware of, such as:
* The config-file is stored under "/opt/yunohost/$app/live/.env"
* You can find additional config features under https://your-domain.tld/yunohost/admin/#/apps/$app/config-panel
## Documentations et ressources
* Site official de l'app : https://standardnotes.org/
* Documentation officielle utilisateur: https://standardnotes.org/help
* Documentation officielle de l'admin: https://docs.standardnotes.org/
* Dépôt de code officiel de l'app: https://github.com/standardnotes/web
* Documentation YunoHost pour cette app: https://yunohost.org/app_snweb
* Signaler un bug: https://github.com/YunoHost-Apps/snweb_ynh/issues
## Informations pour les développeurs
Merci de faire vos pull request sur la [branche testing](https://github.com/YunoHost-Apps/snweb_ynh/tree/testing).
Pour essayer la branche testing, procédez comme suit.
```
sudo yunohost app install https://github.com/YunoHost-Apps/snweb_ynh/tree/testing --debug
or
sudo yunohost app upgrade snweb -u https://github.com/YunoHost-Apps/snweb_ynh/tree/testing --debug
```
**Plus d'infos sur le packaging d'applications:** https://yunohost.org/packaging_apps

View file

@ -5,32 +5,32 @@
;; Test complet
; Manifest
domain="domain.tld" (DOMAIN)
is_public=1 (PUBLIC|public=1|private=0)
domain="domain.tld"
path="/path"
is_public=1
; Checks
pkg_linter=1
setup_sub_dir=0
setup_sub_dir=1
setup_root=1
setup_nourl=0
setup_private=1
setup_public=1
upgrade=1
# 3.6.2~yhn1
#upgrade=1 from_commit=0459e279ab1ac0624203b710619bfe3f22686908
# 3.5.11~ynh1
upgrade=1 from_commit=2c82b25537bc09b99c1daeced8ca38fe9b1bae8b
#upgrade=1 from_commit=2c82b25537bc09b99c1daeced8ca38fe9b1bae8b
backup_restore=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
change_url=1
;;; Levels
# If the level 5 (Package linter) is forced to 1. Please add justifications here.
Level 5=auto
;;; Options
Email=
Notification=none
;;; Upgrade options
; commit=2c82b25537bc09b99c1daeced8ca38fe9b1bae8b
name=3.5.11~ynh1
; commit=0459e279ab1ac0624203b710619bfe3f22686908
name=3.6.2~ynh1
manifest_arg=domain=DOMAIN&is_public=1

View file

@ -17,3 +17,6 @@ DATADOG_ENABLED=false
DEV_DEFAULT_SYNC_SERVER=https://sync.standardnotes.org
DEV_EXTENSIONS_MANAGER_LOCATION=public/extensions/extensions-manager/dist/index.html
DEV_BATCH_MANAGER_LOCATION=public/extensions/batch-manager/dist/index.min.html
# Sub-URI
RAILS_RELATIVE_URL_ROOT=/

View file

@ -8,7 +8,7 @@ User=__APP__
Group=__APP__
EnvironmentFile=__FINALPATH__/live/.env
WorkingDirectory=__FINALPATH__/live/
ExecStart=/opt/rbenv/versions/__RUBY_VERSION__/bin/bundle exec puma -C config/puma.rb -p __PORT__ -e production
ExecStart=__RBENV_INSTALL_DIR__/versions/__APP__/bin/bundle exec puma -C config/puma.rb -p __PORT__ -e production
StandardOutput=append:/var/log/__APP__/snweb.log
StandardError=append:/var/log/__APP__/snweb.log
SyslogIdentifier=__APP__

0
doc/.gitkeep Normal file
View file

12
doc/DISCLAIMER.md Normal file
View file

@ -0,0 +1,12 @@
* Any known limitations, constrains or stuff not working, such as (but not limited to):
* No single-sign on or LDAP integration
* The app requires up 1500MB of RAM to install
* The app requires at least 80MB of RAM to work properly.
* The app requires around 1000MB of disk.
* A dedicated domain is requierd if you want to use extensions.
notes.your-domain.tld/ -> Extension Manager is working
your-domain.tld/notes/ -> Extension Manager is not working
* Other infos that people should be aware of, such as:
* The config-file is stored under "/opt/yunohost/$app/live/.env"
* You can find additional config features under https://your-domain.tld/yunohost/admin/#/apps/$app/config-panel

0
doc/screenshots/.gitkeep Normal file
View file

Binary file not shown.

After

Width:  |  Height:  |  Size: 602 KiB

View file

@ -5,15 +5,23 @@
"description": {
"en": "The Standard Notes Web App. An end-to-end encrypted note-taking app. Web, Mac, Windows, Linux, iOS, and Android."
},
"version": "3.6.2~ynh1",
"version": "3.6.8~ynh1",
"url": "https://github.com/standardnotes/web",
"upstream": {
"license": "AGPL-3.0-or-later",
"website": "https://standardnotes.org/",
"demo": "https://standardnotes.org/demo",
"admindoc": "https://docs.standardnotes.org/",
"userdoc": "https://standardnotes.org/help",
"code": "https://github.com/standardnotes/web"
},
"license": "AGPL-3.0-or-later",
"maintainer": {
"name": "Fabian Wilkens",
"email": "46000361+FabianWilkens@users.noreply.github.com"
},
"requirements": {
"yunohost": ">= 4.1.2"
"yunohost": ">= 4.2.4"
},
"multi_instance": true,
"services": [
@ -26,6 +34,15 @@
"type": "domain",
"example": "example.com"
},
{
"name": "path",
"type": "path",
"example": "/notes",
"default": "/",
"help": {
"en": "You can use extensions only without a path url."
}
},
{
"name": "is_public",
"type": "boolean",

View file

@ -1,16 +0,0 @@
## Problem
- *Description of why you made this PR*
## Solution
- *And how do you fix that problem*
## PR Status
- [ ] Code finished.
- [ ] Tested with Package_check.
- [ ] Fix or enhancement tested.
- [ ] Upgrade from last version tested.
- [ ] Can be reviewed and tested.
## Package_check 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!"*

View file

@ -12,35 +12,27 @@ pkg_dependencies="\
git \
"
RUBY_VERSION="2.7.2"
RUBY_VERSION="2.7.3"
NODEJS_VERSION="15.11.0"
SOURCE="https://github.com/standardnotes/web"
COMMIT="22da9ea942dbb9f7fe66af0bf43290b06b7fb482"
COMMIT="bc855b0a1722d2f4ac534ea4d4035299acb7a40a"
#=================================================
# PERSONAL HELPERS
#=================================================
# Execute a command as another user with login
# (hence in user home dir, with prior loading of .profile, etc.)
# usage: exec_login_as USER COMMAND [ARG ...]
exec_login_as() {
local user=$1
shift 1
exec_as $user --login "$@"
}
# Execute a command as another user
# usage: exec_as USER COMMAND [ARG ...]
exec_as() {
local user=$1
shift 1
if [[ $user = $(whoami) ]]; then
eval "$@"
else
sudo -u "$user" "$@"
fi
# Check if service is ready
is_service_ready() {
for ((i = 0 ; i < 15 ; i++))
do
if [ "200" -eq $(curl --silent --insecure --resolve $domain:443:127.0.0.1 https://$domain$path_url/ -o /dev/null --write-out "%{http_code}") ]
then
break
else
sleep 2
fi
done
}
#================================================

View file

@ -17,8 +17,7 @@ old_domain=$YNH_APP_OLD_DOMAIN
old_path=$YNH_APP_OLD_PATH
new_domain=$YNH_APP_NEW_DOMAIN
#new_path=$YNH_APP_NEW_PATH
new_path="/"
new_path=$YNH_APP_NEW_PATH
app=$YNH_APP_INSTANCE_NAME
@ -89,7 +88,7 @@ then
domain="$old_domain"
path_url="$new_path"
# Create a dedicated nginx config
ynh_add_nginx_config "port"
ynh_add_nginx_config
fi
# Change the domain for nginx
@ -108,6 +107,7 @@ fi
config_file="$final_path/live/.env"
ynh_replace_string --match_string="APP_HOST=http://localhost:3001" --replace_string="APP_HOST=https://$new_domain${new_path%/}" --target_file="$config_file"
ynh_replace_string --match_string="RAILS_RELATIVE_URL_ROOT=$old_path" --replace_string="RAILS_RELATIVE_URL_ROOT=$new_path" --target_file="$config_file"
#=================================================
@ -119,7 +119,6 @@ ynh_replace_string --match_string="APP_HOST=http://localhost:3001" --replace_str
ynh_script_progression --message="Starting a systemd service..." --weight=1
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
sleep 10
#=================================================
# RELOAD NGINX
@ -128,6 +127,15 @@ ynh_script_progression --message="Reloading nginx web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# WAITING FOR SERVICE
#=================================================
ynh_script_progression --message="Waiting for service..." --weight=1
domain=$new_domain
path_url=$new_path
is_service_ready
#=================================================
# END OF SCRIPT
#=================================================

View file

@ -7,7 +7,7 @@
#=================================================
source _common.sh
source ynh_install_ruby
source ynh_install_ruby__2
source /usr/share/yunohost/helpers
#=================================================
@ -25,8 +25,7 @@ ynh_abort_if_errors
#=================================================
domain=$YNH_APP_ARG_DOMAIN
#path_url=$YNH_APP_ARG_PATH
path_url="/"
path_url=$YNH_APP_ARG_PATH
is_public=$YNH_APP_ARG_IS_PUBLIC
app=$YNH_APP_INSTANCE_NAME
snserver_domain=$YNH_APP_ARG_SNSERVER_DOMAIN
@ -74,6 +73,7 @@ ynh_script_progression --message="Installing dependencies..." --weight=30
ynh_install_app_dependencies $pkg_dependencies
ynh_install_nodejs --nodejs_version=$NODEJS_VERSION
ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg"
ynh_install_ruby --ruby_version=$RUBY_VERSION
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
@ -87,13 +87,21 @@ pushd "$final_path/live"
git submodule update --init --recursive --quiet
popd
# Apply Patch
if [ -f "$YNH_CWD/../sources/patches/app-00-add-path-url.patch" ]
then
pushd "$final_path/live"
patch --strip=1 < "$YNH_CWD/../sources/patches/app-00-add-path-url.patch"
popd
fi
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Configuring nginx web server..." --weight=3
# Create a dedicated nginx config
ynh_add_nginx_config "port"
ynh_add_nginx_config
#=================================================
# CREATE DEDICATED USER
@ -110,9 +118,11 @@ ynh_system_user_create --username=$app --home_dir=$final_path
#=================================================
ynh_script_progression --message="Installing Ruby... ( This may take a while... )" --weight=100 #212
ynh_install_ruby --ruby_version=$RUBY_VERSION
/opt/rbenv/versions/$RUBY_VERSION/bin/gem update --system --no-document --quiet
/opt/rbenv/versions/$RUBY_VERSION/bin/gem install bundler --no-document --quiet
pushd "$final_path/live"
ynh_use_ruby
ynh_gem update --system --no-document --quiet
ynh_gem install bundler --no-document --quiet
popd
#=================================================
# MODIFY A CONFIG FILE
@ -131,6 +141,7 @@ if [ "$snserver_domain" = "" ]; then
snserver_domain="sync.standardnotes.org"
fi
ynh_replace_string --match_string="SF_DEFAULT_SERVER=http://localhost:3000" --replace_string="SF_DEFAULT_SERVER=https://$snserver_domain" --target_file="$config_file"
ynh_replace_string --match_string="RAILS_RELATIVE_URL_ROOT=.*$" --replace_string="RAILS_RELATIVE_URL_ROOT=$path_url" --target_file="$config_file"
#=================================================
# BUILDING
@ -141,12 +152,12 @@ chown -R $app: "$final_path"
pushd "$final_path/live"
ynh_use_nodejs
exec_as $app /opt/rbenv/versions/$RUBY_VERSION/bin/bundle config set --local path 'vendor/bundle'
exec_as $app /opt/rbenv/versions/$RUBY_VERSION/bin/bundle config set with 'development'
exec_as $app /opt/rbenv/versions/$RUBY_VERSION/bin/bundle install -j$(getconf _NPROCESSORS_ONLN) --quiet
exec_as $app env PATH=$ynh_node_load_PATH yarn install --pure-lockfile
exec_as $app env PATH=$ynh_node_load_PATH yarn bundle
exec_as $app /opt/rbenv/versions/$RUBY_VERSION/bin/bundle exec rails assets:precompile --quiet
ynh_exec_as $app $ynh_ruby_load_path bin/bundle config set --local path 'vendor/bundle'
ynh_exec_as $app $ynh_ruby_load_path bin/bundle config set with 'development'
ynh_exec_warn_less "ynh_exec_as $app $ynh_ruby_load_path bin/bundle install -j$(getconf _NPROCESSORS_ONLN) --quiet"
ynh_exec_warn_less "ynh_exec_as $app env PATH=$ynh_node_load_PATH yarn install --pure-lockfile"
ynh_exec_warn_less "ynh_exec_as $app env PATH=$ynh_node_load_PATH yarn bundle"
ynh_exec_warn_less "ynh_exec_as $app $ynh_ruby_load_path bin/bundle exec rails assets:precompile --quiet"
popd
#=================================================
@ -156,10 +167,7 @@ ynh_script_progression --message="Configuring a systemd service..." --weight=3
# Create a dedicated systemd config
ynh_add_systemd_config --others_var="\
port \
RUBY_VERSION \
"
ynh_add_systemd_config
#=================================================
# STORE THE CONFIG FILE CHECKSUM
@ -178,19 +186,16 @@ ynh_store_file_checksum --file="/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_script_progression --message="Securing files and directories..." --weight=1
# Set permissions to app files
chown -R root:root "$final_path"
chown $app: "$final_path"
mkdir -p $app: "$final_path/.config"
chown $app: "$final_path/.config"
mkdir -p $app: "$final_path/.cache"
chown $app: "$final_path/.cache"
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app: "$final_path"
mkdir -p "$final_path/live/log"
chown -R $app: "$final_path/live/log"
mkdir -p "$final_path/live/public"
chown -R $app: "$final_path/live/public"
mkdir -p "$final_path/live/tmp"
chown -R $app: "$final_path/live/tmp"
chown $app: "$final_path/live/Gemfile.lock"
mkdir -p "/var/log/$app"
chown -R $app: "/var/log/$app"
@ -218,7 +223,6 @@ ynh_script_progression --message="Starting a systemd service..." --weight=1
# Start a systemd service
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
sleep 10
#=================================================
# SETUP SSOWAT
@ -240,6 +244,13 @@ ynh_script_progression --message="Reloading nginx web server..." --weight=2
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# WAITING FOR SERVICE
#=================================================
ynh_script_progression --message="Waiting for service..." --weight=1
is_service_ready
#=================================================
# END OF SCRIPT
#=================================================

View file

@ -7,7 +7,7 @@
#=================================================
source _common.sh
source ynh_install_ruby
source ynh_install_ruby__2
source /usr/share/yunohost/helpers
#=================================================

View file

@ -8,7 +8,7 @@
#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/ynh_install_ruby
source ../settings/scripts/ynh_install_ruby__2
source /usr/share/yunohost/helpers
#=================================================
@ -88,28 +88,27 @@ ynh_install_app_dependencies $pkg_dependencies
ynh_install_nodejs --nodejs_version=$NODEJS_VERSION
ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg"
ynh_install_ruby --ruby_version=$RUBY_VERSION
/opt/rbenv/versions/$RUBY_VERSION/bin/gem update --system --no-document --quiet
/opt/rbenv/versions/$RUBY_VERSION/bin/gem install bundler --no-document --quiet
pushd "$final_path/live"
ynh_use_ruby
ynh_gem update --system --no-document --quiet
ynh_gem install bundler --no-document --quiet
popd
#=================================================
# RESTORE USER RIGHTS
#=================================================
# Restore permissions on app files
chown -R root:root "$final_path"
chown $app: "$final_path"
chown $app: "$final_path/live"
mkdir -p $app: "$final_path/.config"
chown $app: "$final_path/.config"
mkdir -p $app: "$final_path/.cache"
chown $app: "$final_path/.cache"
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app: "$final_path"
mkdir -p "$final_path/live/log"
chown -R $app: "$final_path/live/log"
mkdir -p "$final_path/live/public"
chown -R $app: "$final_path/live/public"
mkdir -p "$final_path/live/tmp"
chown -R $app: "$final_path/live/tmp"
chown $app: "$final_path/live/Gemfile.lock"
mkdir -p "/var/log/$app"
chown -R $app: "/var/log/$app"
@ -134,7 +133,6 @@ yunohost service add $app --description "Standard Notes" --log "/var/log/$app/$a
ynh_script_progression --message="Starting a systemd service..." --weight=2
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
sleep 10
#=================================================
# RESTORE THE LOGROTATE CONFIGURATION
@ -151,6 +149,13 @@ ynh_script_progression --message="Reloading nginx web server..." --weight=2
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# WAITING FOR SERVICE
#=================================================
ynh_script_progression --message="Waiting for service..." --weight=1
is_service_ready
#=================================================
# END OF SCRIPT
#=================================================

View file

@ -7,7 +7,7 @@
#=================================================
source _common.sh
source ynh_install_ruby
source ynh_install_ruby__2
source /usr/share/yunohost/helpers
#=================================================
@ -53,6 +53,24 @@ if [ -z "$final_path" ]; then
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
fi
if ynh_compare_current_package_version --comparison lt --version "3.6.8~ynh1"
then
# Add variables to .env config file
echo -e "\
\n# Sub-URI\
\nRAILS_RELATIVE_URL_ROOT=/\
" >> "$config_file"
# Apply Patch
if [ -f "$YNH_CWD/../sources/patches/app-00-add-path-url.patch" ]
then
pushd "$final_path/live"
patch --strip=1 < "$YNH_CWD/../sources/patches/app-00-add-path-url.patch"
popd
fi
fi
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
@ -84,6 +102,7 @@ ynh_script_progression --message="Upgrading dependencies..." --weight=37
ynh_install_app_dependencies $pkg_dependencies
ynh_install_nodejs --nodejs_version=$NODEJS_VERSION
ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg"
ynh_install_ruby --ruby_version=$RUBY_VERSION
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
@ -117,8 +136,7 @@ fi
ynh_script_progression --message="Upgrading nginx web server configuration..." --weight=3
# Create a dedicated nginx config
ynh_add_nginx_config "port"
ynh_add_nginx_config
#=================================================
# CREATE DEDICATED USER
@ -135,9 +153,11 @@ ynh_system_user_create --username=$app --home_dir=$final_path
#=================================================
ynh_script_progression --message="Installing Ruby... ( This may take a while... )" --weight=100 #331
ynh_install_ruby --ruby_version=$RUBY_VERSION
/opt/rbenv/versions/$RUBY_VERSION/bin/gem update --system --no-document --quiet
/opt/rbenv/versions/$RUBY_VERSION/bin/gem install bundler --no-document --quiet
pushd "$final_path/live"
ynh_use_ruby
ynh_gem update --system --no-document --quiet
ynh_gem install bundler --no-document --quiet
popd
#=================================================
# MODIFY A CONFIG FILE
@ -170,12 +190,12 @@ then
pushd "$final_path/live"
ynh_use_nodejs
exec_as $app /opt/rbenv/versions/$RUBY_VERSION/bin/bundle config set --local path 'vendor/bundle'
exec_as $app /opt/rbenv/versions/$RUBY_VERSION/bin/bundle config set with 'development'
exec_as $app /opt/rbenv/versions/$RUBY_VERSION/bin/bundle install -j$(getconf _NPROCESSORS_ONLN) --quiet
exec_as $app env PATH=$ynh_node_load_PATH yarn install --pure-lockfile
exec_as $app env PATH=$ynh_node_load_PATH yarn bundle
exec_as $app /opt/rbenv/versions/$RUBY_VERSION/bin/bundle exec rails assets:precompile --quiet
ynh_exec_as $app $ynh_ruby_load_path bin/bundle config set --local path 'vendor/bundle'
ynh_exec_as $app $ynh_ruby_load_path bin/bundle config set with 'development'
ynh_exec_warn_less "ynh_exec_as $app $ynh_ruby_load_path bin/bundle install -j$(getconf _NPROCESSORS_ONLN) --quiet"
ynh_exec_warn_less "ynh_exec_as $app env PATH=$ynh_node_load_PATH yarn install --pure-lockfile"
ynh_exec_warn_less "ynh_exec_as $app env PATH=$ynh_node_load_PATH yarn bundle"
ynh_exec_warn_less "ynh_exec_as $app $ynh_ruby_load_path bin/bundle exec rails assets:precompile --quiet"
popd
fi
@ -185,10 +205,7 @@ fi
ynh_script_progression --message="Upgrading systemd configuration..." --weight=4
# Create a dedicated systemd config
ynh_add_systemd_config --others_var="\
port \
RUBY_VERSION \
"
ynh_add_systemd_config
#=================================================
# STORE THE CONFIG FILE CHECKSUM
@ -205,19 +222,16 @@ ynh_store_file_checksum --file="/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_script_progression --message="Securing files and directories..." --weight=2
# Set permissions to app files
chown -R root:root "$final_path"
chown $app: "$final_path"
mkdir -p $app: "$final_path/.config"
chown $app: "$final_path/.config"
mkdir -p $app: "$final_path/.cache"
chown $app: "$final_path/.cache"
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app: "$final_path"
mkdir -p "$final_path/live/log"
chown -R $app: "$final_path/live/log"
mkdir -p "$final_path/live/public"
chown -R $app: "$final_path/live/public"
mkdir -p "$final_path/live/tmp"
chown -R $app: "$final_path/live/tmp"
chown $app: "$final_path/live/Gemfile.lock"
mkdir -p "/var/log/$app"
chown -R $app: "/var/log/$app"
@ -245,7 +259,6 @@ ynh_script_progression --message="Starting a systemd service..." --weight=2
# Start a systemd service
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
sleep 10
#=================================================
# UPGRADE FAIL2BAN
@ -262,6 +275,13 @@ ynh_script_progression --message="Reloading nginx web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# WAITING FOR SERVICE
#=================================================
ynh_script_progression --message="Waiting for service..." --weight=1
is_service_ready
#=================================================
# END OF SCRIPT
#=================================================

View file

@ -1,143 +0,0 @@
#!/bin/bash
# Need also the helper https://github.com/YunoHost-Apps/Experimental_helpers/blob/master/ynh_handle_getopts_args/ynh_handle_getopts_args
rbenv_install_dir="/opt/rbenv"
# RBENV_ROOT is the directory of rbenv, it needs to be loaded as a environment variable.
export RBENV_ROOT="$rbenv_install_dir"
# Install ruby version management
#
# [internal]
#
# usage: ynh_install_rbenv
ynh_install_rbenv () {
echo "Installation of rbenv - ruby version management" >&2
# Build an app.src for rbenv
mkdir -p "../conf"
echo "SOURCE_URL=https://github.com/rbenv/rbenv/archive/v1.1.2.tar.gz
SOURCE_SUM=80ad89ffe04c0b481503bd375f05c212bbc7d44ef5f5e649e0acdf25eba86736" > "../conf/rbenv.src"
# Download and extract rbenv
ynh_setup_source "$rbenv_install_dir" rbenv
# Build an app.src for ruby-build
mkdir -p "../conf"
echo "SOURCE_URL=https://github.com/rbenv/ruby-build/archive/v20201210.tar.gz
SOURCE_SUM=256c7c29afe9ec01850e788ce4e4f496a215ab10083ea7cc9cad6dd8f03b6c5e" > "../conf/ruby-build.src"
# Download and extract ruby-build
ynh_setup_source "$rbenv_install_dir/plugins/ruby-build" ruby-build
(cd $rbenv_install_dir
./src/configure && make -C src)
# Create shims directory if needed
if [ ! -d $rbenv_install_dir/shims ] ; then
mkdir $rbenv_install_dir/shims
fi
}
# Install a specific version of ruby
#
# 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
# for every LOGIN user, hence your user must have a defined shell (as opposed to /usr/sbin/nologin)
#
# Don't forget to execute ruby-dependent command in a login environment
# (e.g. sudo --login option)
# When not possible (e.g. in systemd service definition), please use direct path
# to rbenv shims (e.g. $RBENV_ROOT/shims/bundle)
#
# usage: ynh_install_ruby ruby_version user
# | 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 () {
# Declare an array to define the options of this helper.
declare -Ar args_array=( [v]=ruby_version= )
# Use rbenv, https://github.com/rbenv/rbenv to manage the ruby versions
local ruby_version
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
# Create $rbenv_install_dir
mkdir -p "$rbenv_install_dir/plugins/ruby-build"
# 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:@@')
# Move an existing ruby binary, to avoid to block rbenv
test -x /usr/bin/ruby && mv /usr/bin/ruby /usr/bin/ruby_rbenv
# If rbenv is not previously setup, install it
if ! type rbenv > /dev/null 2>&1
then
ynh_install_rbenv
elif dpkg --compare-versions "$(/opt/rbenv/bin/rbenv --version | cut -d" " -f2)" lt "1.1.2"
then
ynh_install_rbenv
fi
# Restore /usr/local/bin in PATH (if needed)
PATH=$CLEAR_PATH
# And replace the old ruby binary
test -x /usr/bin/ruby_rbenv && mv /usr/bin/ruby_rbenv /usr/bin/ruby
# Install the requested version of ruby
CONFIGURE_OPTS="--disable-install-doc" MAKE_OPTS="-j2" rbenv install --skip-existing $ruby_version
# 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"
# Store ruby_version into the config of this app
ynh_app_setting_set $app ruby_version $ruby_version
# Set environment for ruby users
echo "#rbenv
export RBENV_ROOT=$rbenv_install_dir
export PATH=\"$rbenv_install_dir/bin:$PATH\"
eval \"\$(rbenv init -)\"
#rbenv" > /etc/profile.d/rbenv.sh
# Load the right environment for the Installation
eval "$(rbenv init -)"
(cd $final_path
rbenv local $ruby_version)
}
# Remove the version of ruby used by the app.
#
# This helper will check if another app uses the same version of ruby,
# if not, this version of ruby will be removed.
# If no other app uses ruby, rbenv will be also removed.
#
# usage: ynh_remove_ruby
ynh_remove_ruby () {
ruby_version=$(ynh_app_setting_get $app ruby_version)
# Remove the line for this app
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 ! grep --quiet "$ruby_version" "$rbenv_install_dir/ynh_app_version"
then
$rbenv_install_dir/bin/rbenv uninstall --force $ruby_version
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"
# Remove rbenv environment configuration
rm /etc/profile.d/rbenv.sh
fi
}

304
scripts/ynh_install_ruby__2 Normal file
View file

@ -0,0 +1,304 @@
#!/bin/bash
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"
ruby_version_path="$rbenv_install_dir/versions"
# RBENV_ROOT is the directory of rbenv, it needs to be loaded as a environment variable.
export RBENV_ROOT="$rbenv_install_dir"
# Load the version of Ruby for an app, and set variables.
#
# 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.
#
# To use gem or Ruby, use the alias `ynh_gem` and `ynh_ruby`
# Those alias will use the correct version installed for the app
# For example: use `ynh_gem install` instead of `gem install`
#
# With `sudo` or `ynh_exec_as`, use instead the fallback variables `$ynh_gem` and `$ynh_ruby`
# And propagate $PATH to sudo with $ynh_ruby_load_path
# Exemple: `ynh_exec_as $app $ynh_ruby_load_path $ynh_gem install`
#
# $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 3.2.2 or higher.
ynh_use_ruby () {
ruby_version=$(ynh_app_setting_get --app=$app --key=ruby_version)
# Get the absolute path of this version of Ruby
ruby_path="$ruby_version_path/$YNH_APP_INSTANCE_NAME/bin"
# Allow alias to be used into bash script
shopt -s expand_aliases
# Create an alias for the specific version of Ruby and a variable as fallback
ynh_ruby="$ruby_path/ruby"
alias ynh_ruby="$ynh_ruby"
# 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
#
# ynh_install_ruby will install the version of Ruby provided as argument by using 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)
#
# Don't forget to execute ruby-dependent command in a login environment
# (e.g. sudo --login option)
# When not possible (e.g. in systemd service definition), please use direct path
# to rbenv shims (e.g. $RBENV_ROOT/shims/bundle)
#
# usage: ynh_install_ruby --ruby_version=ruby_version
# | arg: -v, --ruby_version= - Version of ruby to install.
#
# Requires YunoHost version 3.2.2 or higher.
ynh_install_ruby () {
# Declare an array to define the options of this helper.
local legacy_args=v
local -A args_array=( [v]=ruby_version= )
local ruby_version
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
# Load rbenv path in PATH
local 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:@@')
# Move an existing Ruby binary, to avoid to block rbenv
test -x /usr/bin/ruby && mv /usr/bin/ruby /usr/bin/ruby_rbenv
# Install or update 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
ruby_build="$(command -v "$rbenv_install_dir"/plugins/*/bin/rbenv-install rbenv-install | head -1)"
if [ -n "$ruby_build" ]; then
ynh_print_info --message="\`rbenv install' command already available in \`$ruby_build'."
pushd "${ruby_build%/*/*}"
if git remote -v 2>/dev/null | grep "https://github.com/rbenv/ruby-build.git"; then
ynh_print_info --message="Trying to update rbenv with git..."
git pull -q origin master
fi
popd
else
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
rbenv_alias="$(command -v "$rbenv_install_dir"/plugins/*/bin/rbenv-alias rbenv-alias | head -1)"
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
rbenv_latest="$(command -v "$rbenv_install_dir"/plugins/*/bin/rbenv-latest rbenv-latest | head -1)"
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
# Enable caching
mkdir -p "${rbenv_install_dir}/cache"
# Create shims directory if needed
mkdir -p "${rbenv_install_dir}/shims"
# Restore /usr/local/bin in PATH
PATH=$CLEAR_PATH
# And replace the old Ruby binary
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 PATH=\"$rbenv_install_dir/bin:$PATH\"
eval \"\$(rbenv init -)\"
#rbenv" > /etc/profile.d/rbenv.sh
# Load the environment
eval "$(rbenv init -)"
}
# Remove the version of Ruby used by the app.
#
# This helper will also cleanup Ruby versions
#
# usage: ynh_remove_ruby
ynh_remove_ruby () {
local ruby_version=$(ynh_app_setting_get --app=$YNH_APP_INSTANCE_NAME --key=ruby_version)
# Load rbenv path in PATH
local CLEAR_PATH="$rbenv_install_dir/bin:$PATH"
# 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
ynh_app_setting_delete --app=$YNH_APP_INSTANCE_NAME --key=ruby_version
# Cleanup Ruby versions
ynh_cleanup_ruby
}
# Remove no more needed versions of Ruby used by the app.
#
# This helper will check what Ruby version are no more required,
# and uninstall them
# If no app uses Ruby, rbenv will be also removed.
#
# usage: ynh_cleanup_ruby
ynh_cleanup_ruby () {
# List required Ruby versions
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 none Ruby version is required
if [[ ! $required_ruby_versions ]]
then
# Remove rbenv environment configuration
ynh_print_info --message="Removing of rbenv-$rbenv_version"
ynh_secure_remove --file="$rbenv_install_dir"
ynh_secure_remove --file="/etc/profile.d/rbenv.sh"
fi
}

View file

@ -0,0 +1,12 @@
diff --git a/config.ru b/config.ru
index bd83b25..6b1bb50 100644
--- a/config.ru
+++ b/config.ru
@@ -1,4 +1,6 @@
# This file is used by Rack-based servers to start the application.
require ::File.expand_path('../config/environment', __FILE__)
-run Rails.application
+map ENV['RAILS_RELATIVE_URL_ROOT'] || '/' do
+ run Rails.application
+end