From e34ef7dbe87c1e771d8142230683acc7b0c32f3c Mon Sep 17 00:00:00 2001 From: bencharp Date: Sat, 1 Jan 2022 16:14:00 +0100 Subject: [PATCH] fix upgrade & some linter warning --- README.md | 85 +++++++++++++++++++++++++++++++--------- README_fr.md | 89 +++++++++++++++++++++++++++++++----------- conf/config.sample.yml | 1 + conf/nginx.conf | 1 - conf/server.js | 2 +- conf/systemd.service | 2 +- manifest.json | 2 +- scripts/change_url | 7 ++-- scripts/install | 60 ++++++++++++---------------- scripts/remove | 10 ++--- scripts/restore | 14 +++---- scripts/upgrade | 80 +++++++++++++++++++------------------ 12 files changed, 220 insertions(+), 133 deletions(-) diff --git a/README.md b/README.md index 4bd7c81..cb30691 100644 --- a/README.md +++ b/README.md @@ -3,17 +3,18 @@ N.B.: This README was automatically generated by https://github.com/YunoHost/app It shall NOT be edited by hand. --> -# Armadietto package 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) +# 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) [![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)* -> *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.* +## Overview + ## Armadietto overview [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 +### 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 + +### :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 -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 -[Click here](https://remotestorage.io/apps/) to see the list of applications that can be used with RemoteStorage. +## TODO +* 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 * Official app website: https://remotestorage.io/ -* Upstream app code repository: https://github.com/remotestorage/armadietto/ -* Report a bug: https://github.com/bencharp/armadietto_ynh/issues +* Upstream app code repository: https://github.com/remotestorage/armadietto +* YunoHost documentation for this app: https://yunohost.org/app_armadietto +* Report a bug: https://github.com/YunoHost-Apps/armadietto_ynh/issues ## 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. ``` -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 -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 \ No newline at end of file diff --git a/README_fr.md b/README_fr.md index 38aef6f..5e3b34a 100644 --- a/README_fr.md +++ b/README_fr.md @@ -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) - -[![Install Armadietto with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=armadietto) +[![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) *[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. -Si vous n'avez pas YunoHost, veuillez consulter [le guide](https://yunohost.org/#/install) pour savoir comment l'installer.* +## Vue d'ensemble ## Aperçu d'Armadietto @@ -16,7 +17,7 @@ Si vous n'avez pas YunoHost, veuillez consulter [le guide](https://yunohost.org/ Armadietto est maintenu par l'équipe remoteStorage [IRC](https://kiwiirc.com/client/irc.freenode.net/#remotestorage). -> ### :warning : WARNING +> ### :warning: WARNING > Veuillez ne pas considérer `armadietto` comme prêt pour la production, ce projet est toujours > comme expérimental. Comme avec toute technologie de stockage en phase alpha, vous > devez vous attendre à ce qu'elle mange vos données et prendre des précautions contre cela. Vous @@ -25,40 +26,82 @@ Armadietto est maintenu par l'équipe remoteStorage [IRC](https://kiwiirc.com/cl **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 - - ![](./doc/screenshots/armadietto.png) - - - +![](./doc/screenshots/armadietto.png) ## 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 -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 -[Cliquez ici](https://remotestorage.io/apps/) pour voir la liste des applications qui peuvent être utilisées avec RemoteStorage. +## TODO +* 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 -* Site Web officiel de l'application : https://remotestorage.io/ -* Dépôt de code de l'application en amont : https://github.com/remotestorage/armadietto/ -* Signalez un bogue : https://github.com/bencharp/armadietto_ynh/issues +* Site officiel de l'app : https://remotestorage.io/ +* Dépôt de code officiel de l'app : https://github.com/remotestorage/armadietto +* 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 -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 -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 \ No newline at end of file diff --git a/conf/config.sample.yml b/conf/config.sample.yml index bf417a5..94a2890 100644 --- a/conf/config.sample.yml +++ b/conf/config.sample.yml @@ -7,4 +7,5 @@ final_path: __FINALPATH__ datadir: __DATADIR__ port: __PORT__ domain: __DOMAIN__ +is_signup: __IS_SIGNUP__ diff --git a/conf/nginx.conf b/conf/nginx.conf index d2b485e..55e8ecd 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -15,6 +15,5 @@ location __PATH__ { # Include SSOWAT user panel. # include conf.d/yunohost_panel.conf.inc; - } \ No newline at end of file diff --git a/conf/server.js b/conf/server.js index 5531073..36a85aa 100644 --- a/conf/server.js +++ b/conf/server.js @@ -19,7 +19,7 @@ server = new Armadietto({ key: '/etc/yunohost/certs/__DOMAIN__/key.pem' }, allow: { - signup: __SIGNUP__ + signup: __IS_SIGNUP__ }, cacheViews: false }); diff --git a/conf/systemd.service b/conf/systemd.service index 4e4f62d..5fc0dcf 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -1,5 +1,5 @@ [Unit] -Description=Armadietto is a remoteStorage server written in nodejs +Description=Armadietto, a remoteStorage server service After=network.target [Service] diff --git a/manifest.json b/manifest.json index 0b0c974..760de92 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "A remoteStorage server written for 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", "upstream": { "license": "MIT", diff --git a/scripts/change_url b/scripts/change_url index e025f6d..5b25c6c 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -24,7 +24,7 @@ app=$YNH_APP_INSTANCE_NAME #================================================= # 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" 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 #================================================= -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 ynh_backup_before_upgrade @@ -72,7 +72,7 @@ fi #================================================= # 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" @@ -138,5 +138,4 @@ ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$ap #================================================= # END OF SCRIPT #================================================= - ynh_script_progression --message="Change of URL completed for $app" --last diff --git a/scripts/install b/scripts/install index 375e92e..890b2ad 100755 --- a/scripts/install +++ b/scripts/install @@ -37,10 +37,8 @@ datadir="/home/yunohost.app/${app}/storage" #================================================= # 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 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 #================================================= -ynh_script_progression --message="Finding an available port..." --weight=1 +ynh_script_progression --message="Finding an available port..." --weight=2 # Find an available port port=$(ynh_find_port --port=8008) 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 #================================================= -ynh_script_progression --message="Installing dependencies..." --weight=4 +ynh_script_progression --message="Installing dependencies..." --weight=23 ynh_install_nodejs --nodejs_version=$NODEJS_VERSION ynh_use_nodejs @@ -105,7 +95,7 @@ mkdir -p "$final_path" #================================================= # 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 @@ -115,7 +105,7 @@ ynh_add_nginx_config #================================================= # 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 ynh_system_user_create --username=$app @@ -123,7 +113,7 @@ ynh_system_user_create --username=$app #================================================= # 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" @@ -133,30 +123,33 @@ chown $app:$app "$final_path/config.yml" #================================================= # 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 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 -modulepath="$node_version_path/$nodejs_version/lib/node_modules/armadietto/lib" +ynh_app_setting_set --app=$app --key=datadir --value=$datadir # 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" -ynh_replace_string --match_string="__DATADIR__" --replace_string="$datadir" --target_file="$final_path/server.js" -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_replace_string --match_string="__SIGNUP__" --replace_string="$is_signup" --target_file="$final_path/server.js" +# Define armadietto module path +module_path="$node_version_path/$nodejs_version/lib/node_modules/armadietto/lib" + +ynh_add_config --template="../conf/server.js" --destination="$final_path/server.js" + +chmod 400 "$final_path/server.js" +chown $app:$app "$final_path/server.js" #================================================= # INSTALL ARMADIETTO @@ -167,8 +160,6 @@ pushd $final_path ynh_npm -g i armadietto popd -ynh_script_progression --message="Armadietto installed..." - #================================================= # GENERIC FINALIZATION #================================================= @@ -186,19 +177,20 @@ ynh_script_progression --message="Secure files and directories" --weight=1 # Set permissions to app files chown -R $app:$app "$final_path" -chmod 0700 $datadir && chown $app:$app $datadir +chmod 0700 "$datadir" +chown $app:$app "$datadir" #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= 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 #================================================= -ynh_script_progression --message="Configuring permissions..." --weight=1 +ynh_script_progression --message="Configuring permissions..." --weight=2 # Make app public if necessary if [ $is_public -eq 1 ] diff --git a/scripts/remove b/scripts/remove index 475bcdf..c9da9b2 100755 --- a/scripts/remove +++ b/scripts/remove @@ -12,7 +12,7 @@ source /usr/share/yunohost/helpers #================================================= # 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 @@ -37,7 +37,7 @@ fi #================================================= # 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 ynh_remove_systemd_config @@ -45,7 +45,7 @@ ynh_remove_systemd_config #================================================= # 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 ynh_remove_logrotate @@ -53,7 +53,7 @@ ynh_remove_logrotate #================================================= # 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 ynh_secure_remove --file="$final_path" @@ -81,7 +81,7 @@ ynh_remove_nginx_config #================================================= # 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 diff --git a/scripts/restore b/scripts/restore index 8b2bdbc..d9bcc3d 100755 --- a/scripts/restore +++ b/scripts/restore @@ -24,7 +24,7 @@ ynh_abort_if_errors #================================================= # 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 @@ -44,7 +44,7 @@ test ! -d $final_path \ #================================================= # 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_use_nodejs @@ -61,7 +61,7 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # 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) ynh_system_user_create --username=$app @@ -76,7 +76,7 @@ ynh_restore_file --origin_path="$final_path" #================================================= # 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" systemctl enable $app.service --quiet @@ -98,8 +98,6 @@ pushd $final_path ynh_npm -g i armadietto popd -ynh_script_progression --message="Armadietto reinstalled..." - #================================================= # GENERIC FINALIZATION #================================================= @@ -122,9 +120,9 @@ chmod 0700 $datadir && chown $app:$app $datadir #================================================= # 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 diff --git a/scripts/upgrade b/scripts/upgrade index adc8b9f..a406661 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -20,11 +20,14 @@ domain=$(ynh_app_setting_get --app=$app --key=domain) port=$(ynh_app_setting_get --app=$app --key=port) final_path=$(ynh_app_setting_get --app=$app --key=final_path) 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 #================================================= +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. ### $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 ### 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_type=$(ynh_check_app_version_changed) #================================================= # 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 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 +# 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* # 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) # -# 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 [ -z "$final_path" ]; then # final_path=/var/www/$app @@ -113,32 +119,37 @@ ynh_use_nodejs #================================================= # 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" chmod 400 "$final_path/config.yml" chown $app:$app "$final_path/config.yml" +#================================================= +# CREATE DATA DIRECTORY +#================================================= +if [ -z "$datadir" ]; then + ynh_script_progression --message="Creating a data directory..." --weight=1 + + ynh_app_setting_set --app=$app --key=datadir --value=$datadir + + # Create app data folder + mkdir -p $datadir +fi + #================================================= # DEFINE ARMADIETTO OPTIONS & CREATE DATA DIRECTORY #================================================= -ynh_script_progression --message="Configuring armadietto as a service..." --weight=1 +ynh_script_progression --message="Configuring armadietto as a service..." --weight=2 # Define armadietto module path -modulepath="$node_version_path/$nodejs_version/lib/node_modules/armadietto/lib" +module_path="$node_version_path/$nodejs_version/lib/node_modules/armadietto/lib" -# Create app data folder -mkdir -p "$datadir" +ynh_add_config --template="../conf/server.js" --destination="$final_path/server.js" -# Using Armadietto as a service in a basic node server -cp -f ../conf/server.js "$final_path/server.js" - -ynh_replace_string --match_string="__MODULE_PATH__" --replace_string="$modulepath" --target_file="$final_path/server.js" -ynh_replace_string --match_string="__DATADIR__" --replace_string="$datadir" --target_file="$final_path/server.js" -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_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 @@ -150,14 +161,17 @@ then pushd $final_path ynh_npm -g i armadietto popd - - ynh_script_progression --message="Armadietto upgraded..." fi #================================================= # 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 ### @@ -182,7 +196,7 @@ ynh_script_progression --message="Updating a configuration file..." --weight=1 #================================================= # 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 ynh_add_systemd_config @@ -192,7 +206,7 @@ ynh_add_systemd_config #================================================= # 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) ynh_use_logrotate @@ -211,19 +225,12 @@ chmod 0700 $datadir && chown $app:$app $datadir #================================================= 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" - -#================================================= -# 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" +yunohost service add $app --description="Armadietto run a remotestorage server as service" --log="/var/log/$app/$app.log" #================================================= # 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 @@ -238,5 +245,4 @@ ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$ap #================================================= # END OF SCRIPT #================================================= - ynh_script_progression --message="Upgrade of $app completed" --last