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

Fix, Cleanup

This commit is contained in:
Fabian Wilkens 2020-12-27 23:18:55 +01:00
parent c4fb0035ea
commit c8d423c4e4
16 changed files with 183 additions and 270 deletions

View file

@ -43,7 +43,7 @@ How to configure this app:
#### Multi-users support
* Are LDAP and HTTP auth supported? No
* Are LDAP and HTTP auth supported? LDAP=No HTTP=Yes
* Can the app be used by multiple users? Yes
#### Supported architectures

View file

@ -1,77 +0,0 @@
# App exemple pour YunoHost
[![Niveau d'intégration](https://dash.yunohost.org/integration/REPLACEBYYOURAPP.svg)](https://dash.yunohost.org/appci/app/REPLACEBYYOURAPP)
[![Installer REPLACEBYYOURAPP avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=REPLACEBYYOURAPP)
*[Read this readme in english.](./README.md)*
> *Ce package vous permet d'installer REPLACEBYYOURAPP 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.*
## Vue d'ensemble
Description rapide de cette application.
**Version incluse:** 1.0
## Captures d'écran
![](Lien vers une capture d'écran pour cette application)
## Démo
* [Démo officielle](Lien vers un site de démonstration pour cette application)
## Configuration
Comment configurer cette application: via le panneau d'administration, un fichier brut en SSH ou tout autre moyen.
## Documentation
* Documentation officielle: Lien vers la documentation officielle de cette application
* Documentation YunoHost: Si une documentation spécifique est nécessaire, n'hésitez pas à contribuer.
## Caractéristiques spécifiques YunoHost
#### Support multi-utilisateurs
L'authentification LDAP et HTTP est-elle prise en charge?
L'application peut-elle être utilisée par plusieurs utilisateurs?
#### Architectures supportées
* x86-64b - [![Build Status](https://ci-apps.yunohost.org/ci/logs/REPLACEBYYOURAPP%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/REPLACEBYYOURAPP/)
* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/REPLACEBYYOURAPP%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/REPLACEBYYOURAPP/)
* Jessie x86-64b - [![Build Status](https://ci-stretch.nohost.me/ci/logs/REPLACEBYYOURAPP%20%28Apps%29.svg)](https://ci-stretch.nohost.me/ci/apps/REPLACEBYYOURAPP/)
## Limitations
* Limitations connues.
## Informations additionnelles
* Autres informations à ajouter sur cette application
**Plus d'informations sur la page de documentation:**
https://yunohost.org/packaging_apps
## Liens
* Signaler un bug: https://github.com/YunoHost-Apps/REPLACEBYYOURAPP_ynh/issues
* Site de l'application: Lien vers le site officiel de cette application
* Dépôt de l'application principale: Lien vers le dépôt officiel de l'application principale
* Site web YunoHost: https://yunohost.org/
---
Informations pour les développeurs
----------------
**Seulement si vous voulez utiliser une branche de test pour le codage, au lieu de fusionner directement dans la banche principale.**
Merci de faire vos pull request sur la [branche testing](https://github.com/YunoHost-Apps/REPLACEBYYOURAPP_ynh/tree/testing).
Pour essayer la branche testing, procédez comme suit.
```
sudo yunohost app install https://github.com/YunoHost-Apps/REPLACEBYYOURAPP_ynh/tree/testing --debug
ou
sudo yunohost app upgrade REPLACEBYYOURAPP -u https://github.com/YunoHost-Apps/REPLACEBYYOURAPP_ynh/tree/testing --debug
```

View file

@ -16,7 +16,7 @@
setup_private=1
setup_public=1
upgrade=1
upgrade=1 from_commit=CommitHash
upgrade=0 from_commit=
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.
@ -30,7 +30,7 @@
Email=wilkens.fabian+github@gmail.com
Notification=all
;;; Upgrade options
; commit=CommitHash
name=Name and date of the commit.
; commit=
name=
manifest_arg=domain=DOMAIN&path=PATH&is_public=1

View file

@ -58,3 +58,6 @@ EMAIL_ATTACHMENT_MAX_SIZE=10485760
# Revisions persistency
REVISIONS_FREQUENCY=300
# Sub-URI
RAILS_RELATIVE_URL_ROOT=/

View file

@ -5,7 +5,7 @@ location __PATH__/ {
rewrite ^ https://$server_name$request_uri? permanent;
}
proxy_pass http://127.0.0.1:__PORT__/;
proxy_pass http://127.0.0.1:__PORT____PATH__/;
proxy_http_version 1.1;
proxy_set_header Host $http_host;
proxy_set_header Upgrade $http_upgrade;
@ -15,4 +15,5 @@ location __PATH__/ {
# Include SSOWAT user panel.
include conf.d/yunohost_panel.conf.inc;
more_clear_input_headers 'Accept-Encoding';
}

View file

@ -19,8 +19,3 @@ RestartSec=15
[Install]
WantedBy=multi-user.target

View file

@ -1,5 +1,5 @@
{
"name": "Standard Notes - Server",
"name": "Standard Notes Server",
"id": "snserver",
"packaging_format": 1,
"description": {

View file

@ -15,4 +15,4 @@
---
*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*
[![Build Status](https://ci-apps-dev.yunohost.org/jenkins/job/REPLACEBYYOURAPP_ynh%20PR-NUM-%20(USERNAME)/badge/icon)](https://ci-apps-dev.yunohost.org/jenkins/job/REPLACEBYYOURAPP_ynh%20PR-NUM-%20(USERNAME)/)
[![Build Status](https://ci-apps-dev.yunohost.org/jenkins/job/snserver_ynh%20PR-NUM-%20(USERNAME)/badge/icon)](https://ci-apps-dev.yunohost.org/jenkins/job/snserver_ynh%20PR-NUM-%20(USERNAME)/)

View file

@ -32,15 +32,6 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path)
domain=$(ynh_app_setting_get --app=$app --key=domain)
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
#=================================================
# STANDARD BACKUP STEPS
#=================================================
# STOP SYSTEMD SERVICE
#=================================================
#ynh_print_info "Stopping a systemd service..."
#ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log"
#=================================================
# BACKUP THE APP MAIN DIR
#=================================================
@ -86,13 +77,6 @@ ynh_print_info "Backing up systemd configuration..."
ynh_backup --src_path="/etc/systemd/system/$app.service"
#=================================================
# START SYSTEMD SERVICE
#=================================================
#ynh_print_info "Starting a systemd service..."
#ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
#=================================================
# END OF SCRIPT
#=================================================

View file

@ -109,7 +109,10 @@ fi
#=================================================
# SPECIFIC MODIFICATIONS
#=================================================
# ...
ynh_script_progression --message="Modifying a config file..." --weight=1
config_file="$final_path/live/.env"
ynh_replace_string --match_string="RAILS_RELATIVE_URL_ROOT=$old_path" --replace_string="RAILS_RELATIVE_URL_ROOT=$new_path" --target_file="$config_file"
#=================================================
#=================================================
@ -120,6 +123,7 @@ fi
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
#=================================================
# RELOAD NGINX
@ -127,15 +131,6 @@ ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$ap
ynh_script_progression --message="Reloading nginx web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload
sleep 10
#=================================================
# STORE SETTINGS
#=================================================
ynh_script_progression --message="Storing settings..." --weight=2
ynh_app_setting_set --app=$app --key=domain --value=$new_domain
ynh_app_setting_set --app=$app --key=path --value=$new_path
#=================================================
# END OF SCRIPT

View file

@ -94,8 +94,7 @@ ynh_setup_source --dest_dir="$final_path/live"
ynh_script_progression --message="Configuring nginx web server..." --weight=3
# Create a dedicated nginx config
ynh_replace_string --match_string="proxy_pass http://127.0.0.1:__PORT__;" --replace_string="proxy_pass http://127.0.0.1:$port;" --target_file="../conf/nginx.conf"
ynh_add_nginx_config
ynh_add_nginx_config "port"
#=================================================
# CREATE DEDICATED USER
@ -134,6 +133,7 @@ ynh_replace_string --match_string="RAILS_ENV=development" --replace_string="RAIL
ynh_replace_string --match_string="DB_DATABASE=standard_notes_db" --replace_string="DB_DATABASE=$db_name" --target_file="$config_file"
ynh_replace_string --match_string="DB_USERNAME=std_notes_user" --replace_string="DB_USERNAME=$db_user" --target_file="$config_file"
ynh_replace_string --match_string="DB_PASSWORD=changeme123" --replace_string="DB_PASSWORD=$db_pwd" --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"
#=================================================
# INSTALLING Standard Notes - Synicing Server
@ -146,7 +146,7 @@ pushd "$final_path/live"
exec_as "$app" env PATH=$PATH /opt/rbenv/versions/$RUBY_VERSION/bin/bundle config set path 'vendor/bundle'
exec_as "$app" env PATH=$PATH /opt/rbenv/versions/$RUBY_VERSION/bin/bundle config set with 'development'
exec_as "$app" env PATH=$PATH /opt/rbenv/versions/$RUBY_VERSION/bin/bundle install
exec_as "$app" env PATH=$PATH RAILS_ENV=production /opt/rbenv/versions/$RUBY_VERSION/bin/bundle exec rails db:create db:migrate
exec_as "$app" env PATH=$PATH RAILS_ENV=production /opt/rbenv/versions/$RUBY_VERSION/bin/bundle exec rails db:create db:migrate --quiet
popd
#=================================================
@ -155,9 +155,10 @@ popd
ynh_script_progression --message="Configuring a systemd service..." --weight=4
# Create a dedicated systemd config
ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="../conf/systemd.service"
ynh_replace_string --match_string="__RUBY_VERSION__" --replace_string="$RUBY_VERSION" --target_file="../conf/systemd.service"
ynh_add_systemd_config --service="$app" --template="systemd.service"
ynh_add_systemd_config --others_var="\
port \
RUBY_VERSION \
"
#=================================================
# STORE THE CONFIG FILE CHECKSUM
@ -179,13 +180,13 @@ ynh_script_progression --message="Securing files and directories..." --weight=1
# Set permissions to app files
chown -R root: $final_path
chown $app: $final_path
mkdir -p $final_path/live/log
chown -R $app: $final_path/live/log/
mkdir -p $final_path/live/tmp
chown -R $app: $final_path/live/tmp/
mkdir -p "$final_path/live/log"
chown -R $app: "$final_path/live/log/"
mkdir -p "$final_path/live/tmp"
chown -R $app: "$final_path/live/tmp/"
mkdir -p /var/log/$app
chown -R $app: /var/log/$app
mkdir -p "/var/log/$app"
chown -R $app: "/var/log/$app"
#=================================================
# SETUP LOGROTATE
@ -229,7 +230,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"
# Wait 10 secends tor server to start
sleep 10
#=================================================

View file

@ -76,12 +76,12 @@ ynh_system_user_create --username=$app --home_dir=$final_path
# Restore permissions on app files
chown -R root: $final_path
chown $app: $final_path
mkdir -p $final_path/live/log
chown -R $app: $final_path/live/log/
mkdir -p $final_path/live/tmp
chown -R $app: $final_path/live/tmp/
mkdir -p /var/log/$app
chown -R $app: /var/log/$app
mkdir -p "$final_path/live/log"
chown -R $app: "$final_path/live/log/"
mkdir -p "$final_path/live/tmp"
chown -R $app: "$final_path/live/tmp/"
mkdir -p "/var/log/$app"
chown -R $app: "/var/log/$app"
#=================================================
# RESTORE FAIL2BAN CONFIGURATION
@ -140,7 +140,6 @@ yunohost service add $app --description "Standard Notes - Syncing Server" --log
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"
# Wait 10 secends tor server to start
sleep 10
#=================================================

View file

@ -163,6 +163,7 @@ then
ynh_replace_string --match_string="DB_DATABASE=standard_notes_db" --replace_string="DB_DATABASE=$db_name" --target_file="$config_file"
ynh_replace_string --match_string="DB_USERNAME=std_notes_user" --replace_string="DB_USERNAME=$db_user" --target_file="$config_file"
ynh_replace_string --match_string="DB_PASSWORD=changeme123" --replace_string="DB_PASSWORD=$db_pwd" --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"
fi
#=================================================
# INSTALLING Standard Notes - Synicing Server
@ -177,7 +178,7 @@ then
exec_as "$app" env PATH=$PATH /opt/rbenv/versions/$RUBY_VERSION/bin/bundle config set path 'vendor/bundle'
exec_as "$app" env PATH=$PATH /opt/rbenv/versions/$RUBY_VERSION/bin/bundle config set with 'development'
exec_as "$app" env PATH=$PATH /opt/rbenv/versions/$RUBY_VERSION/bin/bundle install
exec_as "$app" env PATH=$PATH RAILS_ENV=production /opt/rbenv/versions/$RUBY_VERSION/bin/bundle exec rails db:create db:migrate
exec_as "$app" env PATH=$PATH RAILS_ENV=production /opt/rbenv/versions/$RUBY_VERSION/bin/bundle exec rails db:create db:migrate --quiet
popd
fi
@ -187,9 +188,10 @@ fi
ynh_script_progression --message="Upgrading systemd configuration..." --weight=1
# Create a dedicated systemd config
ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="../conf/systemd.service"
ynh_replace_string --match_string="__RUBY_VERSION__" --replace_string="$RUBY_VERSION" --target_file="../conf/systemd.service"
ynh_add_systemd_config --service="$app" --template="systemd.service"
ynh_add_systemd_config --others_var="\
port \
RUBY_VERSION \
"
#=================================================
# STORE THE CONFIG FILE CHECKSUM
@ -209,13 +211,13 @@ ynh_store_file_checksum --file="/etc/nginx/conf.d/$domain.d/$app.conf"
# Set permissions to app files
chown -R root: $final_path
chown $app: $final_path
mkdir -p $final_path/live/log
chown -R $app: $final_path/live/log/
mkdir -p $final_path/live/tmp
chown -R $app: $final_path/live/tmp/
mkdir -p "$final_path/live/log"
chown -R $app: "$final_path/live/log/"
mkdir -p "$final_path/live/tmp"
chown -R $app: "$final_path/live/tmp/"
mkdir -p /var/log/$app
chown -R $app: /var/log/$app
mkdir -p "/var/log/$app"
chown -R $app: "/var/log/$app"
#=================================================
# SETUP LOGROTATE
@ -260,7 +262,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"
# Wait 10 secends tor server to start
sleep 10
#=================================================

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