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

Fix, Cleanup

This commit is contained in:
Fabian Wilkens 2020-12-27 01:28:03 +01:00
parent 23c080814d
commit dd4c4d6f57
12 changed files with 198 additions and 231 deletions

View file

@ -55,7 +55,7 @@ Can the app be used by multiple users? Yes
## Links
* Report a bug: https://github.com/YunoHost-Apps/snweb_ynh/issues
* Report a bug: https://github.com/FabianWilknes/snweb_ynh/issues
* App website: https://standardnotes.org/
* Upstream app repository: https://github.com/standardnotes/web
* YunoHost website: https://yunohost.org/
@ -66,11 +66,11 @@ Developers info
----------------
**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).
Please do your pull request to the [testing branch](https://github.com/FabianWilknes/snweb_ynh/tree/testing).
To try the testing branch, please proceed like that.
```
sudo yunohost app install https://github.com/YunoHost-Apps/snweb_ynh/tree/testing --debug
sudo yunohost app install https://github.com/FabianWilkens/snweb_ynh/tree/testing --debug
or
sudo yunohost app upgrade snweb -u https://github.com/YunoHost-Apps/snweb_ynh/tree/testing --debug
sudo yunohost app upgrade snweb -u https://github.com/FabianWilkens/snweb_ynh/tree/testing --debug
```

View file

@ -6,21 +6,16 @@
;; Test complet
; Manifest
domain="domain.tld" (DOMAIN)
path="/path" (PATH)
admin="john" (USER)
language="en"
is_public=1 (PUBLIC|public=1|private=0)
password="pass"
port="666" (PORT)
; Checks
pkg_linter=1
setup_sub_dir=1
setup_sub_dir=0
setup_root=1
setup_nourl=0
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.
@ -34,7 +29,7 @@
Email=
Notification=none
;;; Upgrade options
; commit=CommitHash
name=Name and date of the commit.
manifest_arg=domain=DOMAIN&path=PATH&admin=USER&language=fr&is_public=1&password=pass&port=666&
; commit=
name=
manifest_arg=domain=DOMAIN&is_public=1

View file

@ -1,41 +1,22 @@
# upload max size
client_max_body_size 25M;
location __PATH__/ {
alias __FINALPATH__/live/public ;
root __FINALPATH__/live/public;
location / {
if ($scheme = http) {
rewrite ^ https://$server_name$request_uri? permanent;
}
proxy_set_header Accept-Encoding "";
try_files $uri @proxy;
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;
proxy_set_header Connection $connection_upgrade;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_buffering off;
# upload max size
client_max_body_size 25M;
# Include SSOWAT user panel.
include conf.d/yunohost_panel.conf.inc;
more_clear_input_headers 'Accept-Encoding';
}
location @proxy {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto https;
proxy_set_header Proxy "";
proxy_pass_header Server;
proxy_pass http://127.0.0.1:__PORT__;
proxy_buffering on;
proxy_redirect off;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
#proxy_cache CACHE;
proxy_cache_valid 200 7d;
proxy_cache_valid 410 24h;
proxy_cache_use_stale error timeout updating http_500 http_502 http_503 http_504;
add_header X-Cached $upstream_cache_status;
add_header Strict-Transport-Security "max-age=31536000";
tcp_nodelay on;
}
error_page 500 501 502 503 504 /500.html;

View file

@ -1,5 +1,5 @@
{
"name": "Standard Notes - Web App",
"name": "Standard Notes",
"id": "snweb",
"packaging_format": 1,
"description": {
@ -36,12 +36,15 @@
{
"name": "is_public",
"type": "boolean",
"help": {
"en": "A public application means that anyone can access this site."
},
"ask": {
"en": "Is it a public application?",
"fr": "Est-ce une application publique ?",
"de": "Ist die Application Öffendlich?"
},
"default": true
"default": false
},
{
"name": "snserver_domain",

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/snweb_ynh%20PR-NUM-%20(USERNAME)/badge/icon)](https://ci-apps-dev.yunohost.org/jenkins/job/snweb_ynh%20PR-NUM-%20(USERNAME)/)

View file

@ -24,7 +24,7 @@ ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..." --weight=2
ynh_print_info "Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME
@ -33,31 +33,24 @@ domain=$(ynh_app_setting_get --app=$app --key=domain)
#=================================================
# STANDARD BACKUP STEPS
#=================================================
# STOP SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Stopping a systemd service..." --weight=1
ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log"
#=================================================
# BACKUP THE APP MAIN DIR
#=================================================
ynh_script_progression --message="Backing up the main app directory..." --weight=1
ynh_print_info "Backing up the main app directory..."
ynh_backup --src_path="$final_path"
#=================================================
# BACKUP THE NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Backing up nginx web server configuration..." --weight=2
ynh_print_info "Backing up nginx web server configuration..."
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# BACKUP FAIL2BAN CONFIGURATION
#=================================================
#ynh_script_progression --message="Backing up fail2ban configuration..." --weight=1
#ynh_print_info "Backing up fail2ban configuration..."
#ynh_backup --src_path="/etc/fail2ban/jail.d/$app.conf"
#ynh_backup --src_path="/etc/fail2ban/filter.d/$app.conf"
@ -67,26 +60,19 @@ ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# BACKUP LOGROTATE
#=================================================
ynh_script_progression --message="Backing up logrotate configuration..." --weight=1
ynh_print_info "Backing up logrotate configuration..."
ynh_backup --src_path="/etc/logrotate.d/$app"
#=================================================
# BACKUP SYSTEMD
#=================================================
ynh_script_progression --message="Backing up systemd configuration..." --weight=1
ynh_print_info "Backing up systemd configuration..."
ynh_backup --src_path="/etc/systemd/system/$app.service"
#=================================================
# START SYSTEMD SERVICE
#=================================================
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"
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." --last
ynh_print_info "Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."

View file

@ -25,7 +25,7 @@ app=$YNH_APP_INSTANCE_NAME
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..." --time --weight=1
ynh_script_progression --message="Loading installation settings..." --weight=1
# Needed for helper "ynh_add_nginx_config"
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
@ -34,7 +34,7 @@ port=$(ynh_app_setting_get --app=$app --key=port)
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
ynh_script_progression --message="Backing up the app before changing its url (may take a while)..." --time --weight=1
ynh_script_progression --message="Backing up the app before changing its url (may take a while)..." --weight=1
# Backup the current version of the app
ynh_backup_before_upgrade
@ -69,14 +69,14 @@ fi
#=================================================
# STOP SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Stopping a systemd service..." --time --weight=1
ynh_script_progression --message="Stopping a systemd service..." --weight=1
ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log"
#=================================================
# MODIFY URL IN NGINX CONF
#=================================================
ynh_script_progression --message="Updating nginx web server configuration..." --time --weight=1
ynh_script_progression --message="Updating nginx web server configuration..." --weight=1
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
@ -107,7 +107,7 @@ fi
#=================================================
config_file="$final_path/live/.env"
ynh_replace_string --match_string="APP_HOST=http://localhost:3001" --replace_string="APP_HOST=https://$domain${path_url%/}" --target_file="$config_file"
ynh_replace_string --match_string="APP_HOST=http://localhost:3001" --replace_string="APP_HOST=https://$new_domain${new_path%/}" --target_file="$config_file"
#=================================================
@ -116,27 +116,20 @@ ynh_replace_string --match_string="APP_HOST=http://localhost:3001" --replace_str
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..." --time --weight=1
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
#=================================================
ynh_script_progression --message="Reloading nginx web server..." --time --weight=1
ynh_script_progression --message="Reloading nginx web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# 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
#=================================================
ynh_script_progression --message="Change of URL completed for $app" --time --last
ynh_script_progression --message="Change of URL completed for $app" --last

View file

@ -108,7 +108,7 @@ ynh_system_user_create --username=$app --home_dir=$final_path
#=================================================
# INSTALLING RUBY AND BUNDLER
#=================================================
ynh_script_progression --message="Installing Ruby..." --weight=212
ynh_script_progression --message="Installing Ruby... ( This may take a while... )" --weight=100 #212
ynh_install_ruby --ruby_version=$RUBY_VERSION
@ -133,20 +133,20 @@ ynh_replace_string --match_string="SF_DEFAULT_SERVER=http://localhost:3000" --re
#=================================================
# BUILDING
#=================================================
ynh_script_progression --message="Building..." --weight=497
ynh_script_progression --message="Building... ( This may take a while... )" --weight=100 #497
ENV_PATH="$ynh_node_load_PATH:/opt/rbenv/versions/$RUBY_VERSION/bin"
chown -R $app: "$final_path"
pushd "$final_path/live"
git submodule update --init --recursive
git submodule update --init --recursive --quiet
ynh_use_nodejs
exec_as $app $ENV_PATH $ynh_npm ci
env PATH=$ENV_PATH /opt/rbenv/versions/$RUBY_VERSION/bin/gem install bundler
env PATH=$ENV_PATH /opt/rbenv/versions/$RUBY_VERSION/bin/bundler install
exec_as $app $ENV_PATH $ynh_npm run bundle
exec_as $app $ENV_PATH /opt/rbenv/versions/$RUBY_VERSION/bin/bundle exec rails assets:precompile
exec_as $app $ENV_PATH $ynh_npm --loglevel=error ci
env PATH=$ENV_PATH /opt/rbenv/versions/$RUBY_VERSION/bin/gem install bundler --quiet
env PATH=$ENV_PATH /opt/rbenv/versions/$RUBY_VERSION/bin/bundler install --quiet
exec_as $app $ENV_PATH $ynh_npm --loglevel=error run bundle
exec_as $app $ENV_PATH /opt/rbenv/versions/$RUBY_VERSION/bin/bundle exec rails assets:precompile --quiet
popd
#=================================================
@ -183,6 +183,8 @@ 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"
mkdir -p "$final_path/live/log"
chown -R $app: "$final_path/live/log"
mkdir -p "$final_path/live/public"
@ -217,7 +219,7 @@ 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

View file

@ -81,7 +81,7 @@ ynh_system_user_create --username=$app --home_dir=$final_path
#=================================================
# REINSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Reinstalling dependencies..." --weight=294
ynh_script_progression --message="Reinstalling dependencies... ( This may take a while... )" --weight=100 #294
# Define and install dependencies
ynh_install_app_dependencies $pkg_dependencies
@ -93,20 +93,21 @@ ynh_install_ruby --ruby_version=$RUBY_VERSION
#=================================================
# BUILDING
#=================================================
ynh_script_progression --message="Reinstalling $app..." --weight=222
ynh_script_progression --message="Reinstalling $app... ( This may take a while... )" --weight=100 #222
ynh_use_nodejs
ENV_PATH="$ynh_node_load_PATH:/opt/rbenv/versions/$RUBY_VERSION/bin"
chown -R $app: "$final_path"
pushd "$final_path/live"
git submodule update --init --recursive
exec_as $app $ENV_PATH $ynh_npm ci
env PATH=$ENV_PATH /opt/rbenv/versions/$RUBY_VERSION/bin/gem install bundler
env PATH=$ENV_PATH /opt/rbenv/versions/$RUBY_VERSION/bin/bundler install
exec_as $app $ENV_PATH $ynh_npm run bundle
exec_as $app $ENV_PATH /opt/rbenv/versions/$RUBY_VERSION/bin/bundle exec rails assets:precompile
git submodule update --init --recursive --quiet
ynh_use_nodejs
exec_as $app $ENV_PATH $ynh_npm --loglevel=error ci
env PATH=$ENV_PATH /opt/rbenv/versions/$RUBY_VERSION/bin/gem install bundler --quiet
env PATH=$ENV_PATH /opt/rbenv/versions/$RUBY_VERSION/bin/bundler install --quiet
exec_as $app $ENV_PATH $ynh_npm --loglevel=error run bundle
exec_as $app $ENV_PATH /opt/rbenv/versions/$RUBY_VERSION/bin/bundle exec rails assets:precompile --quiet
popd
#=================================================
@ -129,13 +130,16 @@ 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"
#=================================================
# RESTORE SYSTEMD
#=================================================
ynh_script_progression --message="Restoring the systemd configuration..." --weight=1
ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
systemctl enable $app.service
systemctl enable $app.service --quiet
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
@ -149,6 +153,7 @@ 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

View file

@ -135,20 +135,19 @@ ynh_system_user_create --username=$app --home_dir=$final_path
#=================================================
# INSTALLING RUBY AND BUNDLER
#=================================================
ynh_script_progression --message="Installing Ruby..." --weight=331
ynh_script_progression --message="Installing Ruby... ( This may take a while... )" --weight=100 #331
ynh_install_ruby --ruby_version=$RUBY_VERSION
#=================================================
# MODIFY A CONFIG FILE
#=================================================
config_file="$final_path/live/.env"
if [ "$upgrade_type" == "UPGRADE_APP" ]
then
ynh_script_progression --message="Modifying a config file..." --weight=2
config_file="$final_path/live/.env"
cp -f ../conf/env.sample $config_file
ynh_replace_string --match_string="RAILS_ENV=development" --replace_string="RAILS_ENV=production" --target_file="$config_file"
ynh_replace_string --match_string="PORT=3001" --replace_string="PORT=$port" --target_file="$config_file"
secret_key=$(ynh_string_random --length=48 | base64)
@ -165,20 +164,20 @@ fi
#=================================================
if [ "$upgrade_type" == "UPGRADE_APP" ]
then
ynh_script_progression --message="Building..." --weight=131
ynh_script_progression --message="Building... ( This may take a while... )" --weight=100 #131
ENV_PATH="$ynh_node_load_PATH:/opt/rbenv/versions/$RUBY_VERSION/bin"
chown -R $app: "$final_path"
pushd "$final_path/live"
git submodule update --init --recursive
git submodule update --init --recursive --quiet
ynh_use_nodejs
exec_as $app $ENV_PATH $ynh_npm ci
env PATH=$ENV_PATH /opt/rbenv/versions/$RUBY_VERSION/bin/gem install bundler
env PATH=$ENV_PATH /opt/rbenv/versions/$RUBY_VERSION/bin/bundler install
exec_as $app $ENV_PATH $ynh_npm run bundle
exec_as $app $ENV_PATH /opt/rbenv/versions/$RUBY_VERSION/bin/bundle exec rails assets:precompile
exec_as $app $ENV_PATH $ynh_npm --loglevel=error ci
env PATH=$ENV_PATH /opt/rbenv/versions/$RUBY_VERSION/bin/gem install bundler --quiet
env PATH=$ENV_PATH /opt/rbenv/versions/$RUBY_VERSION/bin/bundler install --quiet
exec_as $app $ENV_PATH $ynh_npm --loglevel=error run bundle
exec_as $app $ENV_PATH /opt/rbenv/versions/$RUBY_VERSION/bin/bundle exec rails assets:precompile --quiet
popd
fi
@ -213,6 +212,8 @@ 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"
mkdir -p "$final_path/live/log"
chown -R $app: "$final_path/live/log"
mkdir -p "$final_path/live/public"
@ -247,6 +248,7 @@ 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