1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/armadietto_ynh.git synced 2024-09-03 18:06:18 +02:00

fix upgrade & some linter warning

This commit is contained in:
bencharp 2022-01-01 16:14:00 +01:00
parent c39e823bff
commit e34ef7dbe8
12 changed files with 220 additions and 133 deletions

View file

@ -3,17 +3,18 @@ N.B.: This README was automatically generated by https://github.com/YunoHost/app
It shall NOT be edited by hand. It shall NOT be edited by hand.
--> -->
# Armadietto package for Yunohost # Armadietto for YunoHost
[![Integration level](https://dash.yunohost.org/integration/armadietto.svg)](https://dash.yunohost.org/appci/app/armadietto) ![](https://ci-apps.yunohost.org/ci/badges/armadietto.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/armadietto.maintain.svg) [![Integration level](https://dash.yunohost.org/integration/armadietto.svg)](https://dash.yunohost.org/appci/app/armadietto) ![](https://ci-apps.yunohost.org/ci/badges/armadietto.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/armadietto.maintain.svg)
[![Install Armadietto with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=armadietto) [![Install Armadietto with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=armadietto)
*[Lire ce readme en français.](./README_fr.md)* *[Lire ce readme en français.](./README_fr.md)*
> *This package allows you to install example quickly and simply on a YunoHost server. > *This package allows you to install Armadietto 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.* If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/install) to learn how to install it.*
## Overview
## Armadietto overview ## Armadietto overview
[Armadietto](https://github.com/remotestorage/armadietto/) is a [remoteStorage](https://remotestorage.io) server written for Node.js. [Armadietto](https://github.com/remotestorage/armadietto/) is a [remoteStorage](https://remotestorage.io) server written for Node.js.
@ -29,39 +30,87 @@ Armadietto is maintained by remoteStorage Team [IRC](https://kiwiirc.com/client/
**Shipped version:** 0.1.5 **Shipped version:** 0.1.5
## Screenshots ### Application for remoteStorage
[Click here](https://remotestorage.io/apps/) to see the list of applications that can be used with RemoteStorage.
### Features
- liste des caractéristiques...
**Shipped version:** 0.0.2-beta.10~ynh4
## Screenshots
![](./doc/screenshots/armadietto.png) ![](./doc/screenshots/armadietto.png)
## Disclaimers / important information
## Disclaimers / important information ## Disclaimers / important information
### :warning: WARNING
Armadietto_ynh still in develoment:
* The upgrade process is not yet operational
* Single sign-on or LDAP integration not working?
* Security considerations from [Armadietto](https://github.com/remotestorage/armadietto/) :
> Storage security
>
> In production, we recommend that you restrict access to the files managed by your armadietto server as much as possible. This is particularly true if you host your storage on a machine with other web applications; you need to protect your files in the event that one of those apps is exploited.
>
> You should take these steps to keep your storage safe:
>
> Pick a unique Unix user to run your server process; no other process on the box should run as this user: sudo useradd armadietto --system --no-create-home
>
> Do not run other applications as root, or as any user that could access files owned by your armadietto user
>
> Make sure the directory path/to/storage cannot be read, written or executed by anyone but this user: sudo chmod 0700 /path/to/storage && sudo chown armadietto /path/to/storage
>
> Do not run armadietto as root; if you need to bind to port 80 or 443 use a reverse proxy like nginx, Apache2, caddy, lighttpd or enable bind capability: setcap 'cap_net_bind_service=+ep' `which armadietto`
>
> Ideally, run your storage inside a container or on a dedicated machine
### Important Notes ### Important Notes
RemoteStorage requires a dedicated domain, so obtain one and add it using the YunoHost admin panel. **Domains -> Add domain**. As RemoteStorage uses the full domain and is installed on the root, you can create a subdomain such as remote.domain.tld. Don't forget to update your DNS if you manage them manually.
RemoteStorage requires browser-approved SSL certificates. If you have certificates not issued by [Let's Encrypt](https://letsencrypt.org/), install them manually as usual. - RemoteStorage requires a dedicated domain, so obtain one and add it using the YunoHost admin panel. **Domains -> Add domain**.
- As RemoteStorage uses the full domain and is installed on the root, you can create a subdomain such as remote.domain.tld.
- Don't forget to update your DNS if you manage them manually.
- RemoteStorage requires browser-approved SSL certificates. If you have certificates not issued by [Let's Encrypt](https://letsencrypt.org/), install them manually as usual.
### Application for remoteStorage ## TODO
[Click here](https://remotestorage.io/apps/) to see the list of applications that can be used with RemoteStorage.
* Any known limitations, constraints or non-functioning elements, such as (but not limited to) :
* Unsupported architectures?
* Single sign-on or LDAP integration not working?
* etc...
* Other information that people should know, such as. :
* any specific steps to be performed after installation (like manually terminating the installation, specific admin credentials, ...)
* How to configure / administer the application if it is not obvious.
* Specifics, things to know?
## Documentation and resources ## Documentation and resources
* Official app website: https://remotestorage.io/ * Official app website: https://remotestorage.io/
* Upstream app code repository: https://github.com/remotestorage/armadietto/ * Upstream app code repository: https://github.com/remotestorage/armadietto
* Report a bug: https://github.com/bencharp/armadietto_ynh/issues * YunoHost documentation for this app: https://yunohost.org/app_armadietto
* Report a bug: https://github.com/YunoHost-Apps/armadietto_ynh/issues
## Developer info ## Developer info
Please send your pull request to the [testing branch](https://github.com/bencharp/armadietto_ynh/tree/testing). Please send your pull request to the [testing branch](https://github.com/YunoHost-Apps/armadietto_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/bencharp/armadietto_ynh/tree/testing --debug sudo yunohost app install https://github.com/YunoHost-Apps/armadietto_ynh/tree/testing --debug
or or
sudo yunohost app upgrade armadietto_ynh -u https://github.com/bencharp/armadietto_ynh/tree/testing --debug sudo yunohost app upgrade armadietto -u https://github.com/YunoHost-Apps/armadietto_ynh/tree/testing --debug
``` ```
**More info regarding app packaging:** https://yunohost.org/packaging_apps

View file

@ -1,14 +1,15 @@
# Armadietto package pour Yunohost # Armadietto pour YunoHost
[![Integration level](https://dash.yunohost.org/integration/armadietto.svg)](https://dash.yunohost.org/appci/app/armadietto) ![](https://ci-apps.yunohost.org/ci/badges/armadietto.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/armadietto.maintain.svg) [![Niveau d'intégration](https://dash.yunohost.org/integration/armadietto.svg)](https://dash.yunohost.org/appci/app/armadietto) ![](https://ci-apps.yunohost.org/ci/badges/armadietto.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/armadietto.maintain.svg)
[![Installer Armadietto avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=armadietto)
[![Install Armadietto with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=armadietto)
*[Read this readme in english.](./README.md)* *[Read this readme in english.](./README.md)*
*[Lire ce readme en français.](./README_fr.md)*
> *Ce package vous permet d'installer Armadietto 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.*
> *Ce paquetage vous permet d'installer Armadietto rapidement et simplement sur un serveur YunoHost. ## Vue d'ensemble
Si vous n'avez pas YunoHost, veuillez consulter [le guide](https://yunohost.org/#/install) pour savoir comment l'installer.*
## Aperçu d'Armadietto ## Aperçu d'Armadietto
@ -25,40 +26,82 @@ Armadietto est maintenu par l'équipe remoteStorage [IRC](https://kiwiirc.com/cl
**Version livrée:** 0.1.5 **Version livrée:** 0.1.5
### Application pour remoteStorage
[Cliquez ici](https://remotestorage.io/apps/) pour voir la liste des applications qui peuvent être utilisées avec RemoteStorage.
**Version incluse :** 0.0.2-beta.10~ynh4
## Captures d'écran ## Captures d'écran
![](./doc/screenshots/armadietto.png) ![](./doc/screenshots/armadietto.png)
## Avertissements / informations importantes ## Avertissements / informations importantes
## Avertissements / informations importantes
### :warning: WARNING
Armadietto_ynh still in develoment:
* le processus de mise à niveau n'est pas encore opérationnel
* l'authentification unique ou l'intégration LDAP ne fonctionne pas ?
* Considérations sur la sécurité de [Armadietto](https://github.com/remotestorage/armadietto/) :
> Sécurité du stockage
>
> En production, nous vous recommandons de restreindre autant que possible l'accès aux fichiers gérés par votre serveur armadietto. Ceci est particulièrement vrai si vous hébergez votre stockage sur une machine avec d'autres applications web ; vous devez protéger vos fichiers dans le cas où l'une de ces applications serait exploitée.
>
> Vous devez prendre les mesures suivantes pour assurer la sécurité de votre stockage :
>
> Choisissez un utilisateur Unix unique pour exécuter votre processus serveur ; aucun autre processus sur la machine ne doit être exécuté sous cet utilisateur : sudo useradd armadietto --system --no-create-home
>
> Ne lancez pas d'autres applications en tant que root, ou en tant qu'utilisateur qui pourrait accéder à des fichiers appartenant à votre utilisateur armadietto.
>
> Assurez-vous que le répertoire path/to/storage ne peut être lu, écrit ou exécuté par personne d'autre que cet utilisateur : sudo chmod 0700 /path/to/storage && sudo chown armadietto /path/to/storage
>
> Ne lancez pas armadietto en tant que root ; si vous avez besoin de vous lier au port 80 ou 443, utilisez un reverse proxy comme nginx, Apache2, caddy, lighttpd ou activez la capacité de liaison : setcap 'cap_net_bind_service=+ep' `which armadietto`.
>
> Idéalement, exécutez votre stockage dans un conteneur ou sur une machine dédiée.
Traduit avec www.DeepL.com/Translator (version gratuite)
### Notes importantes ### Notes importantes
RemoteStorage nécessite un domaine dédié, il faut donc en obtenir un et l'ajouter en utilisant le panneau d'administration de YunoHost. **Domaines -> Ajouter un domaine**. Comme RemoteStorage utilise le domaine complet et est installé à la racine, vous pouvez créer un sous-domaine tel que remote.domain.tld. N'oubliez pas de mettre à jour vos DNS si vous les gérez manuellement.
RemoteStorage nécessite des certificats SSL approuvés par le navigateur. Si vous disposez de certificats qui ne sont pas émis par [Let's Encrypt](https://letsencrypt.org/), installez-les manuellement comme d'habitude. - RemoteStorage nécessite un domaine dédié, il faut donc en obtenir un et l'ajouter en utilisant le panneau d'administration de YunoHost. **Domaines -> Ajouter un domaine**.
- Comme RemoteStorage utilise le domaine complet et est installé à la racine, vous pouvez créer un sous-domaine tel que remote.domain.tld.
- N'oubliez pas de mettre à jour vos DNS si vous les gérez manuellement.
- RemoteStorage nécessite des certificats SSL approuvés par le navigateur. Si vous disposez de certificats qui ne sont pas émis par [Let's Encrypt](https://letsencrypt.org/), installez-les manuellement comme d'habitude.
### Application pour remoteStorage ## TODO
[Cliquez ici](https://remotestorage.io/apps/) pour voir la liste des applications qui peuvent être utilisées avec RemoteStorage.
* Toute limitation ou contrainte connue ou tout élément ne fonctionnant pas, tel que (mais non limité à) :
* architectures non prises en charge ?
* L'authentification unique ou l'intégration LDAP ne fonctionnent pas ?
* etc...
* D'autres informations que les gens devraient connaître, comme.. :
* toute étape spécifique à effectuer après l'installation (comme terminer manuellement l'installation, des identifiants d'administration spécifiques, ...)
* Comment configurer / administrer l'application si ce n'est pas évident.
* Spécificités, les choses à savoir ?
## Documentations et ressources ## Documentations et ressources
* Site Web officiel de l'application : https://remotestorage.io/ * Site officiel de l'app : https://remotestorage.io/
* Dépôt de code de l'application en amont : https://github.com/remotestorage/armadietto/ * Dépôt de code officiel de l'app : https://github.com/remotestorage/armadietto
* Signalez un bogue : https://github.com/bencharp/armadietto_ynh/issues * Documentation YunoHost pour cette app : https://yunohost.org/app_armadietto
* Signaler un bug : https://github.com/YunoHost-Apps/armadietto_ynh/issues
## Informations pour les développeurs ## Informations pour les développeurs
Veuillez envoyer votre demande à la [branche de test] (https://github.com/bencharp/armadietto_ynh/tree/testing). Merci de faire vos pull request sur la [branche testing](https://github.com/YunoHost-Apps/armadietto_ynh/tree/testing).
Pour essayer la branche testing, veuillez procéder comme suit. Pour essayer la branche testing, procédez comme suit.
``` ```
sudo yunohost app install https://github.com/bencharp/armadietto_ynh/tree/testing --debug sudo yunohost app install https://github.com/YunoHost-Apps/armadietto_ynh/tree/testing --debug
ou ou
sudo yunohost app upgrade armadietto_ynh -u https://github.com/bencharp/armadietto_ynh/tree/testing --debug sudo yunohost app upgrade armadietto -u https://github.com/YunoHost-Apps/armadietto_ynh/tree/testing --debug
``` ```
**Plus d'infos sur le packaging d'applications :** https://yunohost.org/packaging_apps

View file

@ -7,4 +7,5 @@ final_path: __FINALPATH__
datadir: __DATADIR__ datadir: __DATADIR__
port: __PORT__ port: __PORT__
domain: __DOMAIN__ domain: __DOMAIN__
is_signup: __IS_SIGNUP__

View file

@ -15,6 +15,5 @@ location __PATH__ {
# Include SSOWAT user panel. # Include SSOWAT user panel.
# include conf.d/yunohost_panel.conf.inc; # include conf.d/yunohost_panel.conf.inc;
} }

View file

@ -19,7 +19,7 @@ server = new Armadietto({
key: '/etc/yunohost/certs/__DOMAIN__/key.pem' key: '/etc/yunohost/certs/__DOMAIN__/key.pem'
}, },
allow: { allow: {
signup: __SIGNUP__ signup: __IS_SIGNUP__
}, },
cacheViews: false cacheViews: false
}); });

View file

@ -1,5 +1,5 @@
[Unit] [Unit]
Description=Armadietto is a remoteStorage server written in nodejs Description=Armadietto, a remoteStorage server service
After=network.target After=network.target
[Service] [Service]

View file

@ -6,7 +6,7 @@
"en": "A remoteStorage server written for Node.js.", "en": "A remoteStorage server written for Node.js.",
"fr": "Un serveur remoteStorage écrit pour node.js." "fr": "Un serveur remoteStorage écrit pour node.js."
}, },
"version": "0.0.2-beta.10~ynh3", "version": "0.0.2-beta.10~ynh4",
"url": "https://github.com/remotestorage/armadietto", "url": "https://github.com/remotestorage/armadietto",
"upstream": { "upstream": {
"license": "MIT", "license": "MIT",

View file

@ -24,7 +24,7 @@ app=$YNH_APP_INSTANCE_NAME
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1 ynh_script_progression --message="Loading installation settings..." --weight=2
# Needed for helper "ynh_add_nginx_config" # Needed for helper "ynh_add_nginx_config"
final_path=$(ynh_app_setting_get --app=$app --key=final_path) final_path=$(ynh_app_setting_get --app=$app --key=final_path)
@ -37,7 +37,7 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path)
#================================================= #=================================================
# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP # BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP
#================================================= #=================================================
ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." --weight=1 ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." --weight=3
# Backup the current version of the app # Backup the current version of the app
ynh_backup_before_upgrade ynh_backup_before_upgrade
@ -72,7 +72,7 @@ fi
#================================================= #=================================================
# STOP SYSTEMD SERVICE # STOP SYSTEMD SERVICE
#================================================= #=================================================
ynh_script_progression --message="Stopping a systemd service..." --weight=1 ynh_script_progression --message="Stopping a systemd service..." --weight=2
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"
@ -138,5 +138,4 @@ ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$ap
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Change of URL completed for $app" --last ynh_script_progression --message="Change of URL completed for $app" --last

View file

@ -37,10 +37,8 @@ datadir="/home/yunohost.app/${app}/storage"
#================================================= #=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#================================================= #=================================================
ynh_script_progression --message="Validating installation parameters..." --weight=1 ynh_script_progression --message="Validating installation parameters..." --weight=2
### If the app uses NGINX as web server (written in HTML/PHP in most cases), the final path should be "/var/www/$app".
### If the app provides an internal web server (or uses another application server such as uWSGI), the final path should be "/opt/yunohost/$app"
final_path=/opt/yunohost/$app final_path=/opt/yunohost/$app
test ! -e "$final_path" || ynh_die --message="This path already contains a folder" test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
@ -68,24 +66,16 @@ ynh_app_setting_set --app=$app --key=datadir --value=$datadir
#================================================= #=================================================
# FIND AND OPEN A PORT # FIND AND OPEN A PORT
#================================================= #=================================================
ynh_script_progression --message="Finding an available port..." --weight=1 ynh_script_progression --message="Finding an available port..." --weight=2
# Find an available port # Find an available port
port=$(ynh_find_port --port=8008) port=$(ynh_find_port --port=8008)
ynh_app_setting_set --app=$app --key=port --value=$port ynh_app_setting_set --app=$app --key=port --value=$port
# Optional: Expose this port publicly
# (N.B.: you only need to do this if the app actually needs to expose the port publicly.
# If you do this and the app doesn't actually need you are CREATING SECURITY HOLES IN THE SERVER !)
# Open the port
# ynh_script_progression --message="Configuring firewall..." --weight=1
# ynh_exec_warn_less yunohost firewall allow --no-upnp TCP $port
#================================================= #=================================================
# INSTALL DEPENDENCIES # INSTALL DEPENDENCIES
#================================================= #=================================================
ynh_script_progression --message="Installing dependencies..." --weight=4 ynh_script_progression --message="Installing dependencies..." --weight=23
ynh_install_nodejs --nodejs_version=$NODEJS_VERSION ynh_install_nodejs --nodejs_version=$NODEJS_VERSION
ynh_use_nodejs ynh_use_nodejs
@ -105,7 +95,7 @@ mkdir -p "$final_path"
#================================================= #=================================================
# NGINX CONFIGURATION # NGINX CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Configuring NGINX web server..." --weight=1 ynh_script_progression --message="Configuring NGINX web server..." --weight=2
### `ynh_add_nginx_config` will use the file conf/nginx.conf ### `ynh_add_nginx_config` will use the file conf/nginx.conf
@ -115,7 +105,7 @@ ynh_add_nginx_config
#================================================= #=================================================
# CREATE DEDICATED USER # CREATE DEDICATED USER
#================================================= #=================================================
ynh_script_progression --message="Configuring system user..." --weight=1 ynh_script_progression --message="Configuring system user..." --weight=2
# Create a system user # Create a system user
ynh_system_user_create --username=$app ynh_system_user_create --username=$app
@ -123,7 +113,7 @@ ynh_system_user_create --username=$app
#================================================= #=================================================
# ADD A CONFIGURATION # ADD A CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Adding a configuration file..." ynh_script_progression --message="Adding a configuration file..." --weight=1
ynh_add_config --template="../conf/config.sample.yml" --destination="$final_path/config.yml" ynh_add_config --template="../conf/config.sample.yml" --destination="$final_path/config.yml"
@ -133,30 +123,33 @@ chown $app:$app "$final_path/config.yml"
#================================================= #=================================================
# SETUP SYSTEMD # SETUP SYSTEMD
#================================================= #=================================================
ynh_script_progression --message="Configuring a systemd service..." --weight=1 ynh_script_progression --message="Configuring a systemd service..." --weight=3
# Create a dedicated systemd config # Create a dedicated systemd config
ynh_add_systemd_config ynh_add_systemd_config
#================================================= #=================================================
# SETUP ARMADIETTO AS A SERVICE # CREATE DATA DIRECTORY
#================================================= #=================================================
ynh_script_progression --message="Configuring armadietto as a service..." --weight=1 ynh_script_progression --message="Creating a data directory..." --weight=1
# Define armadietto module path ynh_app_setting_set --app=$app --key=datadir --value=$datadir
modulepath="$node_version_path/$nodejs_version/lib/node_modules/armadietto/lib"
# Create app data folder # Create app data folder
mkdir -p "$datadir" mkdir -p $datadir
# Using Armadietto as a service in a basic node server #=================================================
cp -f ../conf/server.js "$final_path/server.js" # SETUP ARMADIETTO AS A SERVICE
#=================================================
ynh_script_progression --message="Configuring armadietto as a service..." --weight=2
ynh_replace_string --match_string="__MODULE_PATH__" --replace_string="$modulepath" --target_file="$final_path/server.js" # Define armadietto module path
ynh_replace_string --match_string="__DATADIR__" --replace_string="$datadir" --target_file="$final_path/server.js" module_path="$node_version_path/$nodejs_version/lib/node_modules/armadietto/lib"
ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="$final_path/server.js"
ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$final_path/server.js" ynh_add_config --template="../conf/server.js" --destination="$final_path/server.js"
ynh_replace_string --match_string="__SIGNUP__" --replace_string="$is_signup" --target_file="$final_path/server.js"
chmod 400 "$final_path/server.js"
chown $app:$app "$final_path/server.js"
#================================================= #=================================================
# INSTALL ARMADIETTO # INSTALL ARMADIETTO
@ -167,8 +160,6 @@ pushd $final_path
ynh_npm -g i armadietto ynh_npm -g i armadietto
popd popd
ynh_script_progression --message="Armadietto installed..."
#================================================= #=================================================
# GENERIC FINALIZATION # GENERIC FINALIZATION
#================================================= #=================================================
@ -186,19 +177,20 @@ ynh_script_progression --message="Secure files and directories" --weight=1
# Set permissions to app files # Set permissions to app files
chown -R $app:$app "$final_path" chown -R $app:$app "$final_path"
chmod 0700 $datadir && chown $app:$app $datadir chmod 0700 "$datadir"
chown $app:$app "$datadir"
#================================================= #=================================================
# INTEGRATE SERVICE IN YUNOHOST # INTEGRATE SERVICE IN YUNOHOST
#================================================= #=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
yunohost service add $app --description="A short description of the app" --log="/var/log/$app/$app.log" yunohost service add $app --description="Armadietto run a remotestorage server as service" --log="/var/log/$app/$app.log"
#================================================= #=================================================
# SETUP SSOWAT # SETUP SSOWAT
#================================================= #=================================================
ynh_script_progression --message="Configuring permissions..." --weight=1 ynh_script_progression --message="Configuring permissions..." --weight=2
# Make app public if necessary # Make app public if necessary
if [ $is_public -eq 1 ] if [ $is_public -eq 1 ]

View file

@ -12,7 +12,7 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1 ynh_script_progression --message="Loading installation settings..." --weight=2
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
@ -37,7 +37,7 @@ fi
#================================================= #=================================================
# STOP AND REMOVE SERVICE # STOP AND REMOVE SERVICE
#================================================= #=================================================
ynh_script_progression --message="Stopping and removing the systemd service..." --weight=1 ynh_script_progression --message="Stopping and removing the systemd service..." --weight=2
# Remove the dedicated systemd config # Remove the dedicated systemd config
ynh_remove_systemd_config ynh_remove_systemd_config
@ -45,7 +45,7 @@ ynh_remove_systemd_config
#================================================= #=================================================
# REMOVE LOGROTATE CONFIGURATION # REMOVE LOGROTATE CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Removing logrotate configuration..." --time --weight=1 ynh_script_progression --message="Removing logrotate configuration..." --weight=1
# Remove the app-specific logrotate config # Remove the app-specific logrotate config
ynh_remove_logrotate ynh_remove_logrotate
@ -53,7 +53,7 @@ ynh_remove_logrotate
#================================================= #=================================================
# REMOVE APP MAIN DIR # REMOVE APP MAIN DIR
#================================================= #=================================================
ynh_script_progression --message="Removing app main directory..." --weight=1 ynh_script_progression --message="Removing app main directory..." --weight=2
# Remove the app directory securely # Remove the app directory securely
ynh_secure_remove --file="$final_path" ynh_secure_remove --file="$final_path"
@ -81,7 +81,7 @@ ynh_remove_nginx_config
#================================================= #=================================================
# REMOVE DEPENDENCIES # REMOVE DEPENDENCIES
#================================================= #=================================================
ynh_script_progression --message="Removing dependencies..." --weight=1 ynh_script_progression --message="Removing dependencies..." --weight=2
ynh_remove_nodejs --nodejs_version=$NODEJS_VERSION ynh_remove_nodejs --nodejs_version=$NODEJS_VERSION

View file

@ -24,7 +24,7 @@ ynh_abort_if_errors
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1 ynh_script_progression --message="Loading installation settings..." --weight=2
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
@ -44,7 +44,7 @@ test ! -d $final_path \
#================================================= #=================================================
# REINSTALL DEPENDENCIES # REINSTALL DEPENDENCIES
#================================================= #=================================================
ynh_script_progression --message="Reinstalling dependencies..." --weight=4 ynh_script_progression --message="Reinstalling dependencies..." --weight=21
ynh_install_nodejs --nodejs_version=$NODEJS_VERSION ynh_install_nodejs --nodejs_version=$NODEJS_VERSION
ynh_use_nodejs ynh_use_nodejs
@ -61,7 +61,7 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#================================================= #=================================================
# RECREATE THE DEDICATED USER # RECREATE THE DEDICATED USER
#================================================= #=================================================
ynh_script_progression --message="Recreating the dedicated system user..." --weight=1 ynh_script_progression --message="Recreating the dedicated system user..." ---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
@ -76,7 +76,7 @@ ynh_restore_file --origin_path="$final_path"
#================================================= #=================================================
# RESTORE SYSTEMD # RESTORE SYSTEMD
#================================================= #=================================================
ynh_script_progression --message="Restoring the systemd configuration..." --weight=1 ynh_script_progression --message="Restoring the systemd configuration..." --weight=2
ynh_restore_file --origin_path="/etc/systemd/system/$app.service" ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
systemctl enable $app.service --quiet systemctl enable $app.service --quiet
@ -98,8 +98,6 @@ pushd $final_path
ynh_npm -g i armadietto ynh_npm -g i armadietto
popd popd
ynh_script_progression --message="Armadietto reinstalled..."
#================================================= #=================================================
# GENERIC FINALIZATION # GENERIC FINALIZATION
#================================================= #=================================================
@ -122,9 +120,9 @@ chmod 0700 $datadir && chown $app:$app $datadir
#================================================= #=================================================
# INTEGRATE SERVICE IN YUNOHOST # INTEGRATE SERVICE IN YUNOHOST
#================================================= #=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 ynh_script_progression --message="Integrating service in YunoHost..." --weight=2
yunohost service add $app --description="A short description of the app" --log="/var/log/$app/$app.log" yunohost service add $app --description="Armadietto run a remotestorage server as service" --log="/var/log/$app/$app.log"
#================================================= #=================================================
# RELOAD NGINX # RELOAD NGINX

View file

@ -20,11 +20,14 @@ domain=$(ynh_app_setting_get --app=$app --key=domain)
port=$(ynh_app_setting_get --app=$app --key=port) port=$(ynh_app_setting_get --app=$app --key=port)
final_path=$(ynh_app_setting_get --app=$app --key=final_path) final_path=$(ynh_app_setting_get --app=$app --key=final_path)
datadir=$(ynh_app_setting_get --app=$app --key=datadir) datadir=$(ynh_app_setting_get --app=$app --key=datadir)
is_signup=$(ynh_app_setting_get --app=$app --key=signup) is_signup=$(ynh_app_setting_get --app=$app --key=is_signup)
#================================================= #=================================================
# CHECK VERSION # CHECK VERSION
#================================================= #=================================================
ynh_script_progression --message="Checking version..." --weight=1
upgrade_type=$(ynh_check_app_version_changed)
### This helper will compare the version of the currently installed app and the version of the upstream package. ### This helper will compare the version of the currently installed app and the version of the upstream package.
### $upgrade_type can have 2 different values ### $upgrade_type can have 2 different values
@ -32,12 +35,11 @@ is_signup=$(ynh_app_setting_get --app=$app --key=signup)
### - UPGRADE_PACKAGE if only the YunoHost package has changed ### - UPGRADE_PACKAGE if only the YunoHost package has changed
### ynh_check_app_version_changed will stop the upgrade if the app is up to date. ### ynh_check_app_version_changed will stop the upgrade if the app is up to date.
### UPGRADE_APP should be used to upgrade the core app only if there's an upgrade to do. ### UPGRADE_APP should be used to upgrade the core app only if there's an upgrade to do.
upgrade_type=$(ynh_check_app_version_changed)
#================================================= #=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#================================================= #=================================================
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=1 ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=4
# Backup the current version of the app # Backup the current version of the app
ynh_backup_before_upgrade ynh_backup_before_upgrade
@ -62,18 +64,22 @@ ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app
#================================================= #=================================================
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
# Cleaning legacy permissions
if ynh_legacy_permissions_exists; then
ynh_legacy_permissions_delete_all
ynh_app_setting_delete --app=$app --key=is_public
fi
# Remove old log file
ynh_secure_remove --file="/var/log/$app/"
# #
# N.B. : the followings setting migrations snippets are provided as *EXAMPLES* # N.B. : the followings setting migrations snippets are provided as *EXAMPLES*
# of what you may want to do in some cases (e.g. a setting was not defined on # of what you may want to do in some cases (e.g. a setting was not defined on
# some legacy installs and you therefore want to initiaze stuff during upgrade) # some legacy installs and you therefore want to initiaze stuff during upgrade)
# #
# 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=/var/www/$app
@ -113,7 +119,7 @@ ynh_use_nodejs
#================================================= #=================================================
# ADD A CONFIGURATION # ADD A CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Adding a configuration file..." ynh_script_progression --message="Adding a configuration file..." --weight=2
ynh_add_config --template="../conf/config.sample.yml" --destination="$final_path/config.yml" ynh_add_config --template="../conf/config.sample.yml" --destination="$final_path/config.yml"
@ -121,24 +127,29 @@ chmod 400 "$final_path/config.yml"
chown $app:$app "$final_path/config.yml" chown $app:$app "$final_path/config.yml"
#================================================= #=================================================
# DEFINE ARMADIETTO OPTIONS & CREATE DATA DIRECTORY # CREATE DATA DIRECTORY
#================================================= #=================================================
ynh_script_progression --message="Configuring armadietto as a service..." --weight=1 if [ -z "$datadir" ]; then
ynh_script_progression --message="Creating a data directory..." --weight=1
# Define armadietto module path ynh_app_setting_set --app=$app --key=datadir --value=$datadir
modulepath="$node_version_path/$nodejs_version/lib/node_modules/armadietto/lib"
# Create app data folder # Create app data folder
mkdir -p "$datadir" mkdir -p $datadir
fi
# Using Armadietto as a service in a basic node server #=================================================
cp -f ../conf/server.js "$final_path/server.js" # DEFINE ARMADIETTO OPTIONS & CREATE DATA DIRECTORY
#=================================================
ynh_script_progression --message="Configuring armadietto as a service..." --weight=2
ynh_replace_string --match_string="__MODULE_PATH__" --replace_string="$modulepath" --target_file="$final_path/server.js" # Define armadietto module path
ynh_replace_string --match_string="__DATADIR__" --replace_string="$datadir" --target_file="$final_path/server.js" module_path="$node_version_path/$nodejs_version/lib/node_modules/armadietto/lib"
ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="$final_path/server.js"
ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$final_path/server.js" ynh_add_config --template="../conf/server.js" --destination="$final_path/server.js"
ynh_replace_string --match_string="__SIGNUP__" --replace_string="$is_signup" --target_file="$final_path/server.js"
chmod 400 "$final_path/server.js"
chown $app:$app "$final_path/server.js"
#================================================= #=================================================
# UPGRADE ARMADIETTO # UPGRADE ARMADIETTO
@ -150,14 +161,17 @@ then
pushd $final_path pushd $final_path
ynh_npm -g i armadietto ynh_npm -g i armadietto
popd popd
ynh_script_progression --message="Armadietto upgraded..."
fi fi
#================================================= #=================================================
# UPDATE A CONFIG FILE # UPDATE A CONFIG FILE
#================================================= #=================================================
ynh_script_progression --message="Updating a configuration file..." --weight=1 ynh_script_progression --message="Updating a configuration file..." --weight=2
ynh_add_config --template="../conf/config.sample.yml" --destination="$final_path/config.yml"
chmod 400 "$final_path/config.yml"
chown $app:$app "$final_path/config.yml"
### Same as during install ### Same as during install
### ###
@ -182,7 +196,7 @@ ynh_script_progression --message="Updating a configuration file..." --weight=1
#================================================= #=================================================
# SETUP SYSTEMD # SETUP SYSTEMD
#================================================= #=================================================
ynh_script_progression --message="Upgrading systemd configuration..." --weight=1 ynh_script_progression --message="Upgrading systemd configuration..." --weight=3
# Create a dedicated systemd config # Create a dedicated systemd config
ynh_add_systemd_config ynh_add_systemd_config
@ -192,7 +206,7 @@ ynh_add_systemd_config
#================================================= #=================================================
# SETUP LOGROTATE # SETUP LOGROTATE
#================================================= #=================================================
ynh_script_progression --message="Configuring log rotation..." --weight=1 ynh_script_progression --message="Configuring log rotation..." --weight=2
# Use logrotate to manage application logfile(s) # Use logrotate to manage application logfile(s)
ynh_use_logrotate ynh_use_logrotate
@ -211,19 +225,12 @@ chmod 0700 $datadir && chown $app:$app $datadir
#================================================= #=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
yunohost service add $app --description="A short description of the app" --log="/var/log/$app/$app.log" yunohost service add $app --description="Armadietto run a remotestorage server as service" --log="/var/log/$app/$app.log"
#=================================================
# 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"
#================================================= #=================================================
# RELOAD NGINX # RELOAD NGINX
#================================================= #=================================================
ynh_script_progression --message="Reloading NGINX web server..." --weight=1 ynh_script_progression --message="Reloading NGINX web server..." --weight=2
ynh_systemd_action --service_name=nginx --action=reload ynh_systemd_action --service_name=nginx --action=reload
@ -238,5 +245,4 @@ ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$ap
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Upgrade of $app completed" --last ynh_script_progression --message="Upgrade of $app completed" --last