mirror of
https://github.com/YunoHost-Apps/snweb_ynh.git
synced 2024-09-03 20:26:22 +02:00
Updatet scripts. Cleanup
This commit is contained in:
parent
dd56ebb120
commit
7543c864ac
10 changed files with 201 additions and 242 deletions
77
README.md
77
README.md
|
@ -1,72 +1,63 @@
|
||||||
# Usage of this package (REMOVE THIS SECTION BEFORE RELEASE)
|
# Standard Notes Web App for YunoHost
|
||||||
- Copy this app before working on it.
|
|
||||||
- Edit `conf/nginx.conf` file to match application prerequisites.
|
|
||||||
- Edit `manifest.json` with application specific information.
|
|
||||||
- Edit the `install`, `upgrade`, `remove`, `backup`, and `restore` scripts.
|
|
||||||
- Using the [script helpers documentation.](https://helpers.yunohost.org/)
|
|
||||||
- Add a `LICENSE` file for the package.
|
|
||||||
- Edit `README.md` and README_fr.md.
|
|
||||||
|
|
||||||
# Example app for YunoHost
|
[](https://dash.yunohost.org/appci/app/snweb)
|
||||||
|
[](https://install-app.yunohost.org/?app=snweb)
|
||||||
|
|
||||||
[](https://dash.yunohost.org/appci/app/REPLACEBYYOURAPP)
|
> *This package allow you to install snweb quickly and simply on a YunoHost server.
|
||||||
[](https://install-app.yunohost.org/?app=REPLACEBYYOURAPP)
|
|
||||||
|
|
||||||
*[Lire ce readme en français.](./README_fr.md)*
|
|
||||||
|
|
||||||
> *This package allow you to install REPLACEBYYOURAPP 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 see [here](https://yunohost.org/#/install) to know how to install and enjoy it.*
|
||||||
|
|
||||||
## Overview
|
## Overview
|
||||||
Quick description of this app.
|
Standard Notes
|
||||||
|
|
||||||
**Shipped version:** 1.0
|
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.5.11
|
||||||
|
* 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/FabianWilkens/snweb_ynh
|
||||||
|
|
||||||
## Screenshots
|
## Screenshots
|
||||||
|
|
||||||

|

|
||||||
|
Extensions, Editors, Themes: https://standardnotes.org/extensions
|
||||||
|
|
||||||
|
|
||||||
## Demo
|
## Demo
|
||||||
|
|
||||||
* [Official demo](Link to a demo site for this app)
|
* [Official demo - Web App](https://standardnotes.org/demo)
|
||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
|
|
||||||
How to configure this app: by an admin panel, a plain file with SSH, or any other way.
|
How to configure this app:
|
||||||
|
* The config-file is stored under "/opt/yunohost/$app/live/.env"
|
||||||
|
|
||||||
## Documentation
|
## Documentation
|
||||||
|
|
||||||
* Official documentation: Link to the official documentation of this app
|
* Official Help & Support: https://standardnotes.org/help
|
||||||
* YunoHost documentation: If specific documentation is needed, feel free to contribute.
|
* Official documentation: https://docs.standardnotes.org (Only delevopment documentation)
|
||||||
|
|
||||||
## YunoHost specific features
|
## YunoHost specific features
|
||||||
|
|
||||||
#### Multi-users support
|
#### Multi-users support
|
||||||
|
|
||||||
Are LDAP and HTTP auth supported?
|
Are LDAP and HTTP auth supported? LDAP -> NO, HTTP auth -> Yes
|
||||||
Can the app be used by multiple users?
|
|
||||||
|
Can the app be used by multiple users? Yes
|
||||||
|
|
||||||
#### Supported architectures
|
#### Supported architectures
|
||||||
|
|
||||||
* x86-64b - [](https://ci-apps.yunohost.org/ci/apps/REPLACEBYYOURAPP/)
|
* x86-64b - [](https://ci-apps.yunohost.org/ci/apps/snweb/)
|
||||||
* ARMv8-A - [](https://ci-apps-arm.yunohost.org/ci/apps/REPLACEBYYOURAPP/)
|
* ARMv8-A - [](https://ci-apps-arm.yunohost.org/ci/apps/snweb/)
|
||||||
|
|
||||||
## Limitations
|
|
||||||
|
|
||||||
* Any known limitations.
|
|
||||||
|
|
||||||
## Additional information
|
|
||||||
|
|
||||||
* Other information you would add about this application
|
|
||||||
|
|
||||||
**More information on the documentation page:**
|
|
||||||
https://yunohost.org/packaging_apps
|
|
||||||
|
|
||||||
## Links
|
## Links
|
||||||
|
|
||||||
* Report a bug: https://github.com/YunoHost-Apps/REPLACEBYYOURAPP_ynh/issues
|
* Report a bug: https://github.com/YunoHost-Apps/snweb_ynh/issues
|
||||||
* App website: Link to the official website of this app
|
* App website: https://standardnotes.org/
|
||||||
* Upstream app repository: Link to the official repository of the upstream app
|
* Upstream app repository: https://github.com/standardnotes/web
|
||||||
* YunoHost website: https://yunohost.org/
|
* YunoHost website: https://yunohost.org/
|
||||||
|
|
||||||
---
|
---
|
||||||
|
@ -75,11 +66,11 @@ Developers info
|
||||||
----------------
|
----------------
|
||||||
|
|
||||||
**Only if you want to use a testing branch for coding, instead of merging directly into master.**
|
**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/REPLACEBYYOURAPP_ynh/tree/testing).
|
Please do 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.
|
To try the testing branch, please proceed like that.
|
||||||
```
|
```
|
||||||
sudo yunohost app install https://github.com/YunoHost-Apps/REPLACEBYYOURAPP_ynh/tree/testing --debug
|
sudo yunohost app install https://github.com/YunoHost-Apps/snweb_ynh/tree/testing --debug
|
||||||
or
|
or
|
||||||
sudo yunohost app upgrade REPLACEBYYOURAPP -u https://github.com/YunoHost-Apps/REPLACEBYYOURAPP_ynh/tree/testing --debug
|
sudo yunohost app upgrade snweb -u https://github.com/YunoHost-Apps/snweb_ynh/tree/testing --debug
|
||||||
```
|
```
|
||||||
|
|
77
README_fr.md
77
README_fr.md
|
@ -1,77 +0,0 @@
|
||||||
# App exemple pour YunoHost
|
|
||||||
|
|
||||||
[](https://dash.yunohost.org/appci/app/REPLACEBYYOURAPP)
|
|
||||||
[](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
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
## 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 - [](https://ci-apps.yunohost.org/ci/apps/REPLACEBYYOURAPP/)
|
|
||||||
* ARMv8-A - [](https://ci-apps-arm.yunohost.org/ci/apps/REPLACEBYYOURAPP/)
|
|
||||||
* Jessie x86-64b - [](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
|
|
||||||
```
|
|
|
@ -1,5 +0,0 @@
|
||||||
SOURCE_URL=https://github.com/standardnotes/web/archive/3.5.11.tar.gz
|
|
||||||
SOURCE_SUM=6f3cbc638c9ba357696da52be2b9cbfadcc1d0b75d62355b182047b527086b09
|
|
||||||
SOURCE_SUM_PRG=sha256sum
|
|
||||||
SOURCE_FORMAT=tar.gz
|
|
||||||
SOURCE_IN_SUBDIR=true
|
|
|
@ -3,9 +3,9 @@
|
||||||
"id": "snweb",
|
"id": "snweb",
|
||||||
"packaging_format": 1,
|
"packaging_format": 1,
|
||||||
"description": {
|
"description": {
|
||||||
"en": "Standard Notes Web App. An end-to-end encrypted note-taking app. Web, Mac, Windows, Linux, iOS, and Android."
|
"en": "The Standard Notes Web App. An end-to-end encrypted note-taking app. Web, Mac, Windows, Linux, iOS, and Android."
|
||||||
},
|
},
|
||||||
"version": "3.0.14~ynh1",
|
"version": "3.5.11~ynh1",
|
||||||
"url": "https://github.com/standardnotes/web",
|
"url": "https://github.com/standardnotes/web",
|
||||||
"license": "free",
|
"license": "free",
|
||||||
"maintainer": {
|
"maintainer": {
|
||||||
|
@ -14,7 +14,7 @@
|
||||||
"url": "https://github.com/FabianWilkens/snweb_ynh"
|
"url": "https://github.com/FabianWilkens/snweb_ynh"
|
||||||
},
|
},
|
||||||
"requirements": {
|
"requirements": {
|
||||||
"yunohost": ">= 3.5"
|
"yunohost": ">= 4.0"
|
||||||
},
|
},
|
||||||
"multi_instance": true,
|
"multi_instance": true,
|
||||||
"services": [
|
"services": [
|
||||||
|
@ -63,16 +63,6 @@
|
||||||
},
|
},
|
||||||
"default": true
|
"default": true
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"name": "language",
|
|
||||||
"type": "string",
|
|
||||||
"ask": {
|
|
||||||
"en": "Choose the application language",
|
|
||||||
"fr": "Choisissez la langue de l'application",
|
|
||||||
"de": "Wähle die Application Sprache"
|
|
||||||
},
|
|
||||||
"default": "en"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"name": "snserver_domain",
|
"name": "snserver_domain",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# dependencies used by the app
|
# dependencies used by the app
|
||||||
#pkg_dependencies="libsqlite3-dev default-libmysqlclient-dev"
|
|
||||||
pkg_dependencies="\
|
pkg_dependencies="\
|
||||||
zlib1g-dev \
|
zlib1g-dev \
|
||||||
libssl-dev \
|
libssl-dev \
|
||||||
|
|
|
@ -30,7 +30,6 @@ app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STANDARD BACKUP STEPS
|
# STANDARD BACKUP STEPS
|
||||||
|
@ -55,20 +54,13 @@ ynh_script_progression --message="Backing up nginx web server configuration..."
|
||||||
|
|
||||||
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# BACKUP THE MYSQL DATABASE
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Backing up the MySQL database..." --time --weight=1
|
|
||||||
|
|
||||||
ynh_mysql_dump_db --database="$db_name" > db.sql
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP FAIL2BAN CONFIGURATION
|
# BACKUP FAIL2BAN CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Backing up fail2ban configuration..." --time --weight=1
|
#ynh_script_progression --message="Backing up fail2ban configuration..." --time --weight=1
|
||||||
|
|
||||||
ynh_backup --src_path="/etc/fail2ban/jail.d/$app.conf"
|
#ynh_backup --src_path="/etc/fail2ban/jail.d/$app.conf"
|
||||||
ynh_backup --src_path="/etc/fail2ban/filter.d/$app.conf"
|
#ynh_backup --src_path="/etc/fail2ban/filter.d/$app.conf"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SPECIFIC BACKUP
|
# SPECIFIC BACKUP
|
||||||
|
|
|
@ -108,7 +108,10 @@ fi
|
||||||
#=================================================
|
#=================================================
|
||||||
# SPECIFIC MODIFICATIONS
|
# SPECIFIC MODIFICATIONS
|
||||||
#=================================================
|
#=================================================
|
||||||
# ...
|
|
||||||
|
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"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -123,8 +123,7 @@ ynh_replace_string --match_string="RAILS_ENV=development" --replace_string="RAIL
|
||||||
ynh_replace_string --match_string="PORT=3001" --replace_string="PORT=$port" --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)
|
secret_key=$(ynh_string_random --length=48 | base64)
|
||||||
ynh_replace_string --match_string="SECRET_KEY_BASE=test" --replace_string="SECRET_KEY_BASE=$secret_key" --target_file="$config_file"
|
ynh_replace_string --match_string="SECRET_KEY_BASE=test" --replace_string="SECRET_KEY_BASE=$secret_key" --target_file="$config_file"
|
||||||
|
ynh_replace_string --match_string="APP_HOST=http://localhost:3001" --replace_string="APP_HOST=https://$domain${path_url%/}" --target_file="$config_file"
|
||||||
|
|
||||||
if [ "$snserver_domain" = "" ]; then
|
if [ "$snserver_domain" = "" ]; then
|
||||||
snserver_domain="sync.standardnotes.org"
|
snserver_domain="sync.standardnotes.org"
|
||||||
fi
|
fi
|
||||||
|
@ -142,7 +141,6 @@ chown -R $app: "$final_path"
|
||||||
pushd "$final_path/live"
|
pushd "$final_path/live"
|
||||||
git submodule update --init --recursive
|
git submodule update --init --recursive
|
||||||
ynh_use_nodejs
|
ynh_use_nodejs
|
||||||
#exec_as $app $ENV_PATH $ynh_npm run setup
|
|
||||||
exec_as $app $ENV_PATH $ynh_npm ci
|
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/gem install bundler
|
||||||
env PATH=$ENV_PATH /opt/rbenv/versions/$RUBY_VERSION/bin/bundler install
|
env PATH=$ENV_PATH /opt/rbenv/versions/$RUBY_VERSION/bin/bundler install
|
||||||
|
@ -202,14 +200,14 @@ ynh_script_progression --message="Configuring log rotation..."
|
||||||
|
|
||||||
# Use logrotate to manage application logfile(s)
|
# Use logrotate to manage application logfile(s)
|
||||||
ynh_use_logrotate --logfile="$final_path/live/log/production.log"
|
ynh_use_logrotate --logfile="$final_path/live/log/production.log"
|
||||||
ynh_use_logrotate --logfile="/var/log/$app/snweb.log"
|
ynh_use_logrotate --logfile="/var/log/$app/$app.log"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# 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 --description "Standard Notes - Web Frontend"
|
yunohost service add $app --description "Standard Notes" --log "/var/log/$app/$app.log"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# START SYSTEMD SERVICE
|
# START SYSTEMD SERVICE
|
||||||
|
@ -217,7 +215,8 @@ yunohost service add $app --description "Standard Notes - Web Frontend"
|
||||||
ynh_script_progression --message="Starting a systemd service..."
|
ynh_script_progression --message="Starting a systemd service..."
|
||||||
|
|
||||||
# Start a systemd service
|
# Start a systemd service
|
||||||
ynh_systemd_action --service_name=$app --action="start"
|
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
|
||||||
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETUP SSOWAT
|
# SETUP SSOWAT
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
|
|
||||||
#Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
|
#Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
|
||||||
source ../settings/scripts/_common.sh
|
source ../settings/scripts/_common.sh
|
||||||
|
source ../settings/scripts/ynh_install_ruby
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -31,8 +32,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)
|
||||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
|
||||||
db_user=$db_name
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CHECK IF THE APP CAN BE RESTORED
|
# CHECK IF THE APP CAN BE RESTORED
|
||||||
|
@ -65,16 +64,24 @@ ynh_restore_file --origin_path="$final_path"
|
||||||
ynh_script_progression --message="Recreating the dedicated system user..." --time --weight=1
|
ynh_script_progression --message="Recreating the dedicated system user..." --time --weight=1
|
||||||
|
|
||||||
# Create the dedicated user (if not existing)
|
# Create the dedicated user (if not existing)
|
||||||
ynh_system_user_create --username=$app
|
ynh_system_user_create --username=$app --home_dir=$final_path
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE USER RIGHTS
|
# RESTORE USER RIGHTS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# Restore permissions on app files
|
# Restore permissions on app files
|
||||||
chown -R "$app":"$app" $final_path
|
chown -R root:root "$final_path"
|
||||||
mkdir -p "/var/log/$app"
|
chown $app: "$final_path"
|
||||||
chown -R "$app":"$app" /var/log/$app
|
mkdir -p $app: "$final_path/.config"
|
||||||
|
chown $app: "$final_path/.config"
|
||||||
|
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"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE FAIL2BAN CONFIGURATION
|
# RESTORE FAIL2BAN CONFIGURATION
|
||||||
|
@ -94,15 +101,9 @@ ynh_script_progression --message="Reinstalling dependencies..." --time --weight=
|
||||||
|
|
||||||
# Define and install dependencies
|
# Define and install dependencies
|
||||||
ynh_install_app_dependencies $pkg_dependencies
|
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"
|
||||||
# RESTORE THE MYSQL DATABASE
|
ynh_install_ruby --ruby_version=$RUBY_VERSION
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Restoring the MySQL database..." --time --weight=1
|
|
||||||
|
|
||||||
db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
|
|
||||||
ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
|
|
||||||
ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE SYSTEMD
|
# RESTORE SYSTEMD
|
||||||
|
@ -116,7 +117,7 @@ systemctl enable $app.service
|
||||||
# INTEGRATE SERVICE IN YUNOHOST
|
# INTEGRATE SERVICE IN YUNOHOST
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
yunohost service add $app --description "A short description of the app" --log "/var/log/$app/$app.log"
|
yunohost service add $app --description "Standard Notes" --log "/var/log/$app/$app.log"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# START SYSTEMD SERVICE
|
# START SYSTEMD SERVICE
|
||||||
|
@ -134,11 +135,10 @@ ynh_restore_file --origin_path="/etc/logrotate.d/$app"
|
||||||
#=================================================
|
#=================================================
|
||||||
# GENERIC FINALIZATION
|
# GENERIC FINALIZATION
|
||||||
#=================================================
|
#=================================================
|
||||||
# RELOAD NGINX AND PHP-FPM
|
# RELOAD NGINX
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Reloading nginx web server and php-fpm..." --time --weight=1
|
ynh_script_progression --message="Reloading nginx web server..." --time --weight=1
|
||||||
|
|
||||||
ynh_systemd_action --service_name=php7.0-fpm --action=reload
|
|
||||||
ynh_systemd_action --service_name=nginx --action=reload
|
ynh_systemd_action --service_name=nginx --action=reload
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
195
scripts/upgrade
195
scripts/upgrade
|
@ -7,6 +7,7 @@
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
source _common.sh
|
source _common.sh
|
||||||
|
source ynh_install_ruby
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -18,11 +19,8 @@ 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)
|
|
||||||
is_public=$(ynh_app_setting_get --app=$app --key=is_public)
|
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)
|
|
||||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CHECK VERSION
|
# CHECK VERSION
|
||||||
|
@ -50,15 +48,9 @@ elif [ "$is_public" = "No" ]; then
|
||||||
is_public=0
|
is_public=0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# If db_name doesn't exist, create it
|
|
||||||
if [ -z "$db_name" ]; then
|
|
||||||
db_name=$(ynh_sanitize_dbid --db_name=$app)
|
|
||||||
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
|
|
||||||
fi
|
|
||||||
|
|
||||||
# If final_path doesn't exist, create it
|
# If final_path doesn't exist, create it
|
||||||
if [ -z "$final_path" ]; then
|
if [ -z "$final_path" ]; then
|
||||||
final_path=/var/www/$app
|
final_path=/opt/yunohost/$app
|
||||||
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
|
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -76,18 +68,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
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -97,16 +77,39 @@ ynh_script_progression --message="Stopping a systemd service..." --time --weight
|
||||||
|
|
||||||
ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log"
|
ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# UPGRADE DEPENDENCIES
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Upgrading dependencies..." --time --weight=1
|
||||||
|
|
||||||
|
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"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
||||||
then
|
then
|
||||||
ynh_script_progression --message="Upgrading source files..." --time --weight=1
|
ynh_script_progression --message="Upgrading source files..." --time --weight=1
|
||||||
|
|
||||||
# Download, check integrity, uncompress and patch the source from app.src
|
# Backup files to keep
|
||||||
ynh_setup_source --dest_dir="$final_path"
|
tmpdir=$(mktemp -d)
|
||||||
|
if [ -d $final_path/live/log ] ; then
|
||||||
|
cp -Rp $final_path/live/log $tmpdir
|
||||||
|
fi
|
||||||
|
# Remove destination directory
|
||||||
|
ynh_secure_remove --file=$final_path
|
||||||
|
# Download
|
||||||
|
mkdir -p "$final_path"
|
||||||
|
git clone $SOURCE "$final_path/live" --quiet
|
||||||
|
pushd "$final_path/live"
|
||||||
|
git checkout $COMMIT --quiet
|
||||||
|
popd
|
||||||
|
# Restore files
|
||||||
|
if [ -d $tmpdir/log ] ; then
|
||||||
|
cp -Rp $tmpdir/log $final
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -115,14 +118,8 @@ fi
|
||||||
ynh_script_progression --message="Upgrading nginx web server configuration..." --time --weight=1
|
ynh_script_progression --message="Upgrading nginx web server configuration..." --time --weight=1
|
||||||
|
|
||||||
# Create a dedicated nginx config
|
# Create a dedicated nginx config
|
||||||
ynh_add_nginx_config
|
ynh_add_nginx_config "port"
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# UPGRADE DEPENDENCIES
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Upgrading dependencies..." --time --weight=1
|
|
||||||
|
|
||||||
ynh_install_app_dependencies $pkg_dependencies
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CREATE DEDICATED USER
|
# CREATE DEDICATED USER
|
||||||
|
@ -130,31 +127,59 @@ ynh_install_app_dependencies $pkg_dependencies
|
||||||
ynh_script_progression --message="Making sure dedicated system user exists..." --time --weight=1
|
ynh_script_progression --message="Making sure dedicated system user exists..." --time --weight=1
|
||||||
|
|
||||||
# Create a dedicated user (if not existing)
|
# Create a dedicated user (if not existing)
|
||||||
ynh_system_user_create --username=$app
|
ynh_system_user_create --username=$app --home_dir=$final_path
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SPECIFIC UPGRADE
|
# SPECIFIC UPGRADE
|
||||||
#=================================================
|
#=================================================
|
||||||
# ...
|
# INSTALLING RUBY AND BUNDLER
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Installing Ruby..." --weight=331
|
||||||
|
|
||||||
|
ynh_install_ruby --ruby_version=$RUBY_VERSION
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STORE THE CONFIG FILE CHECKSUM
|
# MODIFY A CONFIG FILE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
||||||
|
then
|
||||||
|
ynh_script_progression --message="Modifying a config file..." --time --weight=2
|
||||||
|
|
||||||
### Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script.
|
config_file="$final_path/live/.env"
|
||||||
### And create a backup of this file if the checksum is different. So the file will be backed up if the admin had modified it.
|
cp -f ../conf/env.sample $config_file
|
||||||
ynh_backup_if_checksum_is_different --file="$final_path/CONFIG_FILE"
|
|
||||||
# Recalculate and store the checksum of the file for the next upgrade.
|
ynh_replace_string --match_string="RAILS_ENV=development" --replace_string="RAILS_ENV=production" --target_file="$config_file"
|
||||||
ynh_store_file_checksum --file="$final_path/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)
|
||||||
|
ynh_replace_string --match_string="SECRET_KEY_BASE=test" --replace_string="SECRET_KEY_BASE=$secret_key" --target_file="$config_file"
|
||||||
|
ynh_replace_string --match_string="APP_HOST=http://localhost:3001" --replace_string="APP_HOST=https://$domain${path_url%/}" --target_file="$config_file"
|
||||||
|
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"
|
||||||
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETUP LOGROTATE
|
# BUILDING
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Upgrading logrotate configuration..." --time --weight=1
|
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
||||||
|
then
|
||||||
|
ynh_script_progression --message="Building..."
|
||||||
|
|
||||||
# Use logrotate to manage app-specific logfile(s)
|
ENV_PATH="$ynh_node_load_PATH:/opt/rbenv/versions/$RUBY_VERSION/bin"
|
||||||
ynh_use_logrotate --non-append
|
|
||||||
|
chown -R $app: "$final_path"
|
||||||
|
|
||||||
|
pushd "$final_path/live"
|
||||||
|
git submodule update --init --recursive
|
||||||
|
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
|
||||||
|
popd
|
||||||
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETUP SYSTEMD
|
# SETUP SYSTEMD
|
||||||
|
@ -162,24 +187,73 @@ ynh_use_logrotate --non-append
|
||||||
ynh_script_progression --message="Upgrading systemd configuration..." --time --weight=1
|
ynh_script_progression --message="Upgrading systemd configuration..." --time --weight=1
|
||||||
|
|
||||||
# Create a dedicated systemd config
|
# Create a dedicated systemd config
|
||||||
ynh_add_systemd_config
|
ynh_add_systemd_config --others_var="\
|
||||||
|
port \
|
||||||
|
ENV_PATH \
|
||||||
|
RUBY_VERSION \
|
||||||
|
"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# STORE THE CONFIG FILE CHECKSUM
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_store_file_checksum --file="$config_file"
|
||||||
|
ynh_store_file_checksum --file="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# GENERIC FINALIZATION
|
# GENERIC FINALIZATION
|
||||||
#=================================================
|
|
||||||
# UPGRADE FAIL2BAN
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Reconfiguring fail2ban..." --time --weight=1
|
|
||||||
|
|
||||||
# Create a dedicated fail2ban config
|
|
||||||
ynh_add_fail2ban_config --logpath="/var/log/nginx/${domain}-error.log" --failregex="Regex to match into the log for a failed login"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SECURE FILES AND DIRECTORIES
|
# SECURE FILES AND DIRECTORIES
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Securing files and directories..."
|
||||||
|
|
||||||
# Set permissions on app files
|
# Set permissions to app files
|
||||||
chown -R root: $final_path
|
chown -R root:root "$final_path"
|
||||||
|
chown $app: "$final_path"
|
||||||
|
mkdir -p $app: "$final_path/.config"
|
||||||
|
chown $app: "$final_path/.config"
|
||||||
|
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"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# SETUP LOGROTATE
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Upgrading logrotate configuration..."
|
||||||
|
|
||||||
|
# Use logrotate to manage application logfile(s)
|
||||||
|
ynh_use_logrotate --logfile="$final_path/live/log/production.log"
|
||||||
|
ynh_use_logrotate --logfile="/var/log/$app/$app.log"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# INTEGRATE SERVICE IN YUNOHOST
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Integrating service in YunoHost..."
|
||||||
|
|
||||||
|
yunohost service add $app --description "Standard Notes" --log "/var/log/$app/$app.log"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# START SYSTEMD SERVICE
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Starting a systemd service..."
|
||||||
|
|
||||||
|
# Start a systemd service
|
||||||
|
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# UPGRADE FAIL2BAN
|
||||||
|
#=================================================
|
||||||
|
#ynh_script_progression --message="Reconfiguring fail2ban..." --time --weight=1
|
||||||
|
|
||||||
|
# Create a dedicated fail2ban config
|
||||||
|
#ynh_add_fail2ban_config --logpath="/var/log/nginx/${domain}-error.log" --failregex="Regex to match into the log for a failed login"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETUP SSOWAT
|
# SETUP SSOWAT
|
||||||
|
@ -189,17 +263,10 @@ ynh_script_progression --message="Upgrading SSOwat configuration..." --time --we
|
||||||
# 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
|
# Create the visitors permission if needed
|
||||||
ynh_app_setting_set --app=$app --key=unprotected_uris --value="/"
|
ynh_permission_update --permission "main" --add "visitors"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# START SYSTEMD SERVICE
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Starting a systemd service..." --time --weight=1
|
|
||||||
|
|
||||||
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RELOAD NGINX
|
# RELOAD NGINX
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
Loading…
Add table
Reference in a new issue