From 9d1a26dce7bbdd25f2e0adfe63e16f347be63d1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Thu, 8 Oct 2020 18:48:04 +0200 Subject: [PATCH 1/7] Repackage (#8) - Repackage --- README.md | 30 +++++---- README_fr.md | 65 +++++++++++++++++++ YEP.md | 117 --------------------------------- check_process | 33 ++++------ conf/nginx.conf | 16 +++++ conf/nginx.conf.j2 | 17 ----- manifest.json | 8 +-- scripts/_common.sh | 157 +++++++++++++-------------------------------- scripts/backup | 55 +++++++++++++--- scripts/change_url | 105 ++++++++++++++++++++++++++++++ scripts/install | 127 +++++++++++++++++++++++++++--------- scripts/remove | 51 +++++++++++---- scripts/restore | 98 +++++++++++++++++++++------- scripts/upgrade | 120 +++++++++++++++++++++++++--------- 14 files changed, 607 insertions(+), 392 deletions(-) create mode 100644 README_fr.md delete mode 100644 YEP.md create mode 100644 conf/nginx.conf delete mode 100644 conf/nginx.conf.j2 create mode 100644 scripts/change_url diff --git a/README.md b/README.md index 6a46077..f83c0b6 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,11 @@ -# SVG Edit app for YunoHost +# SVG-edit for YunoHost [![Integration level](https://dash.yunohost.org/integration/svgedit.svg)](https://dash.yunohost.org/appci/app/svgedit) ![](https://ci-apps.yunohost.org/ci/badges/svgedit.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/svgedit.maintain.svg) -[![Install SVG Edit with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=svgedit) +[![Install SVG-edit with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=svgedit) -> *This package allow you to install SVG Edit quickly and simply on a YunoHost server. +*[Lire ce readme en français.](./README_fr.md)* + +> *This package allow you to install SVG-edit 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.* ## Overview @@ -11,17 +13,20 @@ SVG-edit is a fast, web-based, javascript-driven SVG drawing editor that works i **Shipped version:** 2.8.1 -**Categories:** Productivity, Drawing - ## Screenshots -![alt text](https://svg-edit.github.io/svgedit/images/logo48x48.svg "svg-edit logo of a pencil") SVG-edit +![](https://raw.githubusercontent.com/SVG-Edit/svgedit/master/docs/screenshot.png) + +## Demo + +* [Official demo](https://svg-edit.github.io/svgedit/dist/editor/index.html) ## Configuration ## Documentation -* YunoHost documentation: There no other documentations, feel free to contribute. +* Official documentation: Link to the official documentation of this app +* YunoHost documentation: If specific documentation is needed, feel free to contribute. ## YunoHost specific features @@ -31,12 +36,12 @@ Not supported. #### Supported architectures -* x86-64b - [![Build Status](https://ci-apps.yunohost.org/jenkins/job/leed%20(Community)/badge/icon)](https://ci-apps.yunohost.org/jenkins/job/svgedit%20(Community)/) -* ARMv8-A - [![Build Status](https://ci-apps.yunohost.org/jenkins/job/leed%20(Community)%20(%7EARM%7E)/badge/icon)](https://ci-apps.yunohost.org/jenkins/job/svgedit%20(Community)%20(%7EARM%7E)/) +* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/svgedit%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/svgedit/) +* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/svgedit%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/svgedit/) ## Limitations -* There is no account management in SVG Edit, but the SSO can protect the access to the app to disallow user without yunohost account. +There is no account management in SVG-edit, but the SSO can protect the access to the app to disallow user without YunoHost account. ## Additionnal informations @@ -48,10 +53,7 @@ Not supported. --- -Developers infos ----------------- - -**Package by:** Luc Didry +## Developers infos Please do your pull request to the [testing branch](https://github.com/YunoHost-Apps/svgedit_ynh/tree/testing). diff --git a/README_fr.md b/README_fr.md new file mode 100644 index 0000000..fdd60e3 --- /dev/null +++ b/README_fr.md @@ -0,0 +1,65 @@ +# SVG-edit pour YunoHost + +[![Niveau d'intégration](https://dash.yunohost.org/integration/svgedit.svg)](https://dash.yunohost.org/appci/app/svgedit) ![](https://ci-apps.yunohost.org/ci/badges/svgedit.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/svgedit.maintain.svg) +[![Installer SVG-edit avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=svgedit) + +*[Read this readme in english.](./README.md)* + +> *Ce package vous permet d'installer SVG-edit rapidement et simplement sur un serveur YunoHost. +Si vous n'avez pas YunoHost, consultez [le guide](https://yunohost.org/#/install) pour apprendre comment l'installer.* + +## Vue d'ensemble +SVG-edit est un éditeur de dessin SVG rapide, basé sur le Web et piloté par JavaScript, qui fonctionne dans n'importe quel navigateur moderne. + +**Version incluse :** 2.8.1 + +## Captures d'écran + +![](https://raw.githubusercontent.com/SVG-Edit/svgedit/master/docs/screenshot.png) + +## Démo + +* [Démo officielle](https://svg-edit.github.io/svgedit/dist/editor/index.html) + +## Configuration + +## 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-utilisateur + +Non supporté. + +#### Architectures supportées + +* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/svgedit%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/svgedit/) +* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/svgedit%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/svgedit/) + +## Limitations + +Il n'y a pas de gestion de compte dans SVG-edit, mais le SSO peut protéger l'accès à l'application pour interdire l'utilisateur sans compte YunoHost. + +## Informations additionnelles + +## Liens + + * Signaler un bug : https://github.com/YunoHost-Apps/svgedit_ynh/issues + * Dépôt de l'application principale : https://github.com/SVG-Edit/svgedit + * Site web YunoHost : https://yunohost.org/ + +--- + +## Informations pour les développeurs + +Merci de faire vos pull request sur la [branche testing](https://github.com/YunoHost-Apps/svgedit_ynh/tree/testing). + +Pour essayer la branche testing, procédez comme suit. +``` +sudo yunohost app install https://github.com/YunoHost-Apps/svgedit_ynh/tree/testing --verbose +or +sudo yunohost app upgrade leed -u https://github.com/YunoHost-Apps/svgedit_ynh/tree/testing --verbose +``` diff --git a/YEP.md b/YEP.md deleted file mode 100644 index 0fb8fbf..0000000 --- a/YEP.md +++ /dev/null @@ -1,117 +0,0 @@ -#### [Level 0](https://github.com/YunoHost/doc/blob/master/packaging_apps_levels_fr.md#niveau-0) -[YEP 1.1 - Nommer son app et son dépot](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-11) -`Validated` -[YEP 1.2 - Inscrire l'app sur un "répertoire" connu](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-12) -`Validated` - -#### [Level 1](https://github.com/YunoHost/doc/blob/master/packaging_apps_levels_fr.md#niveau-1) -[YEP 2.2 - Utiliser bash pour les scripts principaux](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-22) -`Validated` -[YEP 2.5 - Copier correctement des fichiers](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-25) -`Don't know` -[YEP 2.7 - Donner des permissions suffisantes aux instructions bash](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-27) -`Validated` -[YEP 2.15 - Suivre les instructions d'installation de l'application](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-215) -`Validated` - -#### [Level 2](https://github.com/YunoHost/doc/blob/master/packaging_apps_levels_fr.md#niveau-2) -[YEP 1.5 - Mettre à jour régulièrement le statut de l'app](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-11) -`Validated` -[YEP 2.18.2 - Gérer l'installation à la racine d’un nom de domaine](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-2182) -`Validated` - *Automatically verified.* -[YEP 2.18.3 - Gérer l'installation sur un sous-domaine](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-2183) -`Validated` - *Automatically verified.* -[YEP 2.18.4 - Gérer l'installation sur un chemin /path](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-2184) -`Validated` - *Automatically verified.* -[YEP 4.6 - Gère le multi-instance](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-11) -`Validated` - *Automatically verified.* - -#### [Level 3](https://github.com/YunoHost/doc/blob/master/packaging_apps_levels_fr.md#niveau-3) -[YEP 2.3 - Sauvegarder les réponses lors de l'installation](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-23) -`Validated` - -#### [Level 4](https://github.com/YunoHost/doc/blob/master/packaging_apps_levels_fr.md#niveau-4) -[YEP 4.1 - Lier au ldap](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-41) -`Not applicable` -[YEP 4.2 - Lier l'authentification au sso](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-42) -`Validated` - -#### [Level 5](https://github.com/YunoHost/doc/blob/master/packaging_apps_levels_fr.md#niveau-5) -[YEP 1.3 - Indiquer la licence associée au paquet](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-13) -`Validated` -[YEP 2.1 - Respecter le format du manifeste](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-21) -`Validated` - *Automatically verified.* -[YEP 2.12 - Utiliser les commandes pratiques (helpers)](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-212) -`Validated` -[YEP 2.18.1 - Lancer le script d'installation d'une webapp correctement](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-2181) -`Validated` - -#### [Level 6](https://github.com/YunoHost/doc/blob/master/packaging_apps_levels_fr.md#niveau-6) -[YEP 1.4 - Informer sur l'intention de maintenir un paquet](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-14) -`Not yet validated` -[YEP 1.6 - Se tenir informé sur l'évolution du packaging d'apps](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-16) -`Validated` -[YEP 1.7 - Ajouter l'app à l'organisation YunoHost-Apps](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-17) -`Validated` - *Automatically verified.* -[YEP 1.8 - Publier des demandes de test](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-18) -`Not yet validated` -[YEP 1.9 - Documenter l'app](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-19) -`Validated` -[YEP 1.10 - Garder un historique de version propre](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-110) -`Validated` -[YEP 2.9 - Enlever toutes traces de l'app lors de la suppression](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-29) -`Validated` -[YEP 3.3 - Faciliter le contrôle de l'intégrité des sources](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-33) -`Validated` -[YEP 3.5 - Suivre les recommendations de la documentation de l'app](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-35) -`Validated` -[YEP 3.6 - Mettre à jour les versions contenant des CVE](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-36) -`Validated` -[YEP 4.3 - Fournir un script de sauvegarde YunoHost fonctionnel](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-43) -`Validated` - *Automatically verified.* -[YEP 4.4 - Fournir un script de restauration YunoHost fonctionnel](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-44) -`Validated` - *Automatically verified.* - -#### [Level 7](https://github.com/YunoHost/doc/blob/master/packaging_apps_levels_fr.md#niveau-7) -[YEP 2.6 - Annuler l'action si les valeurs d'entrées sont incorrectes](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-26) -`Validated` -[YEP 3.2 - Ouvrir un port correctement](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-32) -`Not applicable` - -#### [Level 8](https://github.com/YunoHost/doc/blob/master/packaging_apps_levels_fr.md#niveau-8) -[YEP 2.4 - Détecter et gérer les erreurs](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-24) -`Validated` -[YEP 2.8 - Modifier correctement une configuration système](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-28) -`Validated` -[YEP 2.16 - Vérifier la disponibilité des dépendances sur ARM, x86 et x64](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-216) -`Not yet validated` - *Automatically verified.* -[YEP 2.18.5 - Gérer la tuile YunoHost pour faciliter la navigation entre les applications](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-2185) -`Validated` -[YEP 3.4 - Isoler l'app](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-34) -`Not validated` -[YEP 4.5 - Utiliser les hooks](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-45) -`Not applicable` - -#### [Level 9](https://github.com/YunoHost/doc/blob/master/packaging_apps_levels_fr.md#niveau-9) -[YEP 2.10 - Configurer les logs de l'application](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-210) -`Not applicable` -[YEP 2.11 - Utiliser une variable plutôt que l'app id directement](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-211) -`Validated` -[YEP 2.13 - Traduire le paquet en anglais](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-213) -`Validated` -[YEP 2.14 - Remplir correctement un fichier de conf](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-214) -`Validated` -[YEP 2.17 - Prendre en compte la version d'origine lors des mises à jour](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-217) -`Validated` -[YEP 4.2.1 - Déconnexion](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-421) -`Not applicable` - -#### Other YEP -[YEP 3.1 - Ne pas demander ou stocker de mot de passe LDAP](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-31) -`Validated` -[YEP 4.7 - Ajouter un module à la CLI](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-47) -`Not applicable` -[YEP 4.8 - Ajouter un module à l'admin web](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-48) -`Not applicable` - -State of each YEP can be one of these: `Validated`, `Partially validated`, `Not yet validated`, `Not applicable`, `Don't know`. diff --git a/check_process b/check_process index 52fb30b..dc07d3b 100644 --- a/check_process +++ b/check_process @@ -1,8 +1,8 @@ ;; Test complet - auto_remove=1 ; Manifest domain="domain.tld" (DOMAIN) path="/path" (PATH) + admin="john" (USER) is_public=1 (PUBLIC|public=1|private=0) ; Checks pkg_linter=1 @@ -12,30 +12,19 @@ setup_private=1 setup_public=1 upgrade=1 - upgrade=1 from_commit=6f3a05b03d60142ad19ee8815f7b5d68adc888a4 backup_restore=1 multi_instance=1 - wrong_user=1 - wrong_path=1 - incorrect_path=1 - corrupt_source=1 - fail_download_source=1 + # incorrect_path=1 port_already_use=0 - final_path_already_use=1 - change_url=0 + change_url=1 ;;; Levels - Level 1=auto - Level 2=auto - Level 3=auto -# SVG edit as no account management, but ssowat is configured (is_public feature) - Level 4=na + # If the level 5 (Package linter) is forced to 1. Please add justifications here. Level 5=auto - Level 6=auto - Level 7=auto - Level 8=0 - Level 9=0 - Level 10=0 +;;; Options +Email= +Notification=none ;;; Upgrade options - ; commit=6f3a05b03d60142ad19ee8815f7b5d68adc888a4 - name=2.8.1 6f3a05b03d60142ad19ee8815f7b5d68adc888a4 - manifest_arg=domain=DOMAIN&path=PATH&is_public=1& + ; commit=CommitHash + name=Name and date of the commit. + manifest_arg=domain=DOMAIN&path=PATH&admin=USER&is_public=1& + diff --git a/conf/nginx.conf b/conf/nginx.conf new file mode 100644 index 0000000..fe8b902 --- /dev/null +++ b/conf/nginx.conf @@ -0,0 +1,16 @@ +#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent; +location __PATH__/ { + + # Path to source + alias __FINALPATH__/ ; + + index svg-editor.html ; + + # Force usage of https + if ($scheme = http) { + rewrite ^ https://$server_name$request_uri? permanent; + } + + # Include SSOWAT user panel. + include conf.d/yunohost_panel.conf.inc; +} diff --git a/conf/nginx.conf.j2 b/conf/nginx.conf.j2 deleted file mode 100644 index b655208..0000000 --- a/conf/nginx.conf.j2 +++ /dev/null @@ -1,17 +0,0 @@ -{% if path_url != "/" %} -rewrite ^{{ path_url }}$ {{ path_url }}/ permanent; -{% else %} -{% set path_url = "" %} -{% endif %} -location {{ path_url }}/ { - alias {{ final_path }}/; - - index svg-editor.html; - - if ($scheme = http) { - rewrite ^ https://$server_name$request_uri? permanent; - } - - # Include SSOWAT user panel. - include conf.d/yunohost_panel.conf.inc; -} diff --git a/manifest.json b/manifest.json index 689e293..5fdc9fd 100644 --- a/manifest.json +++ b/manifest.json @@ -3,11 +3,11 @@ "id": "svgedit", "packaging_format": 1, "description": { - "en": "A fast, web-based, javascript-driven SVG drawing editor that works in any modern browser.", - "fr": "Un outil de manipulation de SVG en ligne, rapide, et écrit en javascript qui fonctionne avec tout navigateur moderne." + "en": "A fast web-based SVG drawing editor that works in any modern browser.", + "fr": "Outil rapide de manipulation de SVG en ligne qui fonctionne avec tout navigateur moderne." }, "url": "https://github.com/SVG-Edit/svgedit", - "version": "2.8.1-1", + "version": "2.8.1~ynh2", "license": "MIT", "maintainer": { "name": "ljf", @@ -18,7 +18,7 @@ "name": "Luc Didry" }, "requirements": { - "yunohost": ">> 2.4.0" + "yunohost": ">> 3.8.1" }, "multi_instance": true, "services": [ diff --git a/scripts/_common.sh b/scripts/_common.sh index 9ee6fc3..0033cd0 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -3,13 +3,19 @@ #================================================= # COMMON VARIABLES #================================================= + +# dependencies used by the app +pkg_dependencies="wget" + # App package root directory should be the parent folder PKG_DIR=$(cd ../; pwd) -pkg_dependencies="wget" +#================================================= +# PERSONAL HELPERS +#================================================= #================================================= -# COMMON HELPERS +# EXPERIMENTAL HELPERS #================================================= ynh_set_default_perm () { local DIRECTORY=$1 @@ -19,7 +25,7 @@ ynh_set_default_perm () { chown -R $user:www-data $DIRECTORY chmod -R 440 $DIRECTORY find $DIRECTORY -type d -print0 | xargs -0 chmod 550 \ - || echo "No file to modify" + || echo "No file to modify" } ynh_export () { @@ -113,80 +119,18 @@ ynh_read_json () { sudo python3 -c "import sys, json;print(json.load(open('$1'))['$2'])" } -ynh_read_manifest () { - if [ -f '../manifest.json' ] ; then - ynh_read_json '../manifest.json' "$1" - else - ynh_read_json '../settings/manifest.json' "$1" - fi -} - ynh_configure () { local TEMPLATE=$1 local DEST=$2 type j2 2>/dev/null || sudo pip install j2cli j2 "${PKG_DIR}/conf/$TEMPLATE.j2" > "${PKG_DIR}/conf/$TEMPLATE" - ynh_backup_if_checksum_is_different "$DEST" + ynh_backup_if_checksum_is_different "$DEST" sudo cp "${PKG_DIR}/conf/$TEMPLATE" "$DEST" ynh_store_file_checksum "$DEST" - sudo chown root: "$DEST" + sudo chown root: "$DEST" } -ynh_add_nginx_config () { - finalnginxconf="/etc/nginx/conf.d/$domain.d/$app.conf" - ynh_configure nginx.conf "$finalnginxconf" - service nginx reload -} - -# Send an email to inform the administrator -# -# usage: ynh_send_readme_to_admin app_message [recipients] -# | arg: app_message - The message to send to the administrator. -# | arg: recipients - The recipients of this email. Use spaces to separate multiples recipients. - default: root -# example: "root admin@domain" -# If you give the name of a YunoHost user, ynh_send_readme_to_admin will find its email adress for you -# example: "root admin@domain user1 user2" -ynh_send_readme_to_admin() { - local app_message="${1:-...No specific information...}" - local recipients="${2:-root}" - - # Retrieve the email of users - find_mails () { - local list_mails="$1" - local mail - local recipients=" " - # Read each mail in argument - for mail in $list_mails - do - # Keep root or a real email address as it is - if [ "$mail" = "root" ] || echo "$mail" | grep --quiet "@" - then - recipients="$recipients $mail" - else - # But replace an user name without a domain after by its email - if mail=$(ynh_user_get_info "$mail" "mail" 2> /dev/null) - then - recipients="$recipients $mail" - fi - fi - done - echo "$recipients" - } - recipients=$(find_mails "$recipients") - - local mail_subject="☁️🆈🅽🅷☁️: \`$app\` was just installed!" - - local mail_message="This is an automated message from your beloved YunoHost server. -Specific information for the application $app. -$app_message ---- -Automatic diagnosis data from YunoHost -$(yunohost tools diagnosis | grep -B 100 "services:" | sed '/services:/d')" - - # Send the email to the recipients - echo "$mail_message" | mail -a "Content-Type: text/plain; charset=UTF-8" -s "$mail_subject" "$recipients" -} # Exit without error if the package is up to date # @@ -199,42 +143,27 @@ $(yunohost tools diagnosis | grep -B 100 "services:" | sed '/services:/d')" # # usage: ynh_abort_if_up_to_date ynh_abort_if_up_to_date () { - local force_upgrade=${YNH_FORCE_UPGRADE:-0} - local package_check=${PACKAGE_CHECK_EXEC:-0} + local force_upgrade=${YNH_FORCE_UPGRADE:-0} + local package_check=${PACKAGE_CHECK_EXEC:-0} - local version=$(ynh_read_json "/etc/yunohost/apps/$YNH_APP_INSTANCE_NAME/manifest.json" "version" || echo 1.0) - local last_version=$(ynh_read_manifest "version" || echo 1.0) - if [ "$version" = "$last_version" ] - then - if [ "$force_upgrade" != "0" ] - then - echo "Upgrade forced by YNH_FORCE_UPGRADE." >&2 - unset YNH_FORCE_UPGRADE - elif [ "$package_check" != "0" ] - then - echo "Upgrade forced for package check." >&2 - else - ynh_die "Up-to-date, nothing to do" 0 - fi - fi + local version=$(ynh_read_json "/etc/yunohost/apps/$YNH_APP_INSTANCE_NAME/manifest.json" "version" || echo 1.0) + local last_version=$(ynh_read_manifest "version" || echo 1.0) + if [ "$version" = "$last_version" ] + then + if [ "$force_upgrade" != "0" ] + then + echo "Upgrade forced by YNH_FORCE_UPGRADE." >&2 + unset YNH_FORCE_UPGRADE + elif [ "$package_check" != "0" ] + then + echo "Upgrade forced for package check." >&2 + else + ynh_die "Up-to-date, nothing to do" 0 + fi + fi } -# Remove any logs for all the following commands. -# -# usage: ynh_print_OFF -# WARNING: You should be careful with this helper, and never forgot to use ynh_print_ON as soon as possible to restore the logging. -ynh_print_OFF () { - set +x -} -# Restore the logging after ynh_print_OFF -# -# usage: ynh_print_ON -ynh_print_ON () { - set -x - # Print an echo only for the log, to be able to know that ynh_print_ON has been called. - echo ynh_print_ON > /dev/null -} ynh_version_gt() { test "$(printf '%s\n' "$@" | sort -V | head -n 1)" != "$1"; } # In upgrade script allow to test if the app is less than or equal a specific version @@ -246,25 +175,25 @@ ynh_version_le() { } ynh_debian_release () { - lsb_release --codename --short + lsb_release --codename --short } is_stretch () { - if [ "$(ynh_debian_release)" == "stretch" ] - then - return 0 - else - return 1 - fi + if [ "$(ynh_debian_release)" == "stretch" ] + then + return 0 + else + return 1 + fi } is_jessie () { - if [ "$(ynh_debian_release)" == "jessie" ] - then - return 0 - else - return 1 - fi + if [ "$(ynh_debian_release)" == "jessie" ] + then + return 0 + else + return 1 + fi } # Reload (or other actions) a service and print a log in case of failure. @@ -279,3 +208,7 @@ ynh_system_reload () { # Reload, restart or start and print the log if the service fail to start or reload systemctl $action $service_name || ( journalctl --lines=20 -u $service_name >&2 && false) } + +#================================================= +# FUTURE OFFICIAL HELPERS +#================================================= diff --git a/scripts/backup b/scripts/backup index 8c7d709..f9e9df9 100755 --- a/scripts/backup +++ b/scripts/backup @@ -1,17 +1,54 @@ #!/bin/bash -# See comments in install script -app=$YNH_APP_INSTANCE_NAME +#================================================= +# GENERIC START +#================================================= +# IMPORT GENERIC HELPERS +#================================================= -# Source YunoHost helpers +#Keep this path for calling _common.sh inside the execution's context of backup and restore scripts +source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers +#================================================= +# MANAGE SCRIPT FAILURE +#================================================= + +ynh_clean_setup () { + true +} +# Exit if an error occurs during the execution of the script ynh_abort_if_errors -# Backup sources & data -# Note: the last argument is where to save this path, see the restore script. -ynh_backup "/var/www/${app}" +#================================================= +# LOAD SETTINGS +#================================================= +ynh_print_info --message="Loading installation settings..." -# Copy NGINX configuration -domain=$(ynh_app_setting_get "$app" domain) -ynh_backup "/etc/nginx/conf.d/${domain}.d/${app}.conf" +app=$YNH_APP_INSTANCE_NAME + +final_path=$(ynh_app_setting_get --app=$app --key=final_path) +domain=$(ynh_app_setting_get --app=$app --key=domain) + +#================================================= +# DECLARE DATA AND CONF FILES TO BACKUP +#================================================= +ynh_print_info --message="Declaring files to be backed up..." + +#================================================= +# BACKUP THE APP MAIN DIR +#================================================= + +ynh_backup --src_path="$final_path" + +#================================================= +# BACKUP THE NGINX CONFIGURATION +#================================================= + +ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_print_info --message="Backup script completed for SVG-edit. (YunoHost will then actually copy those files to the archive)." diff --git a/scripts/change_url b/scripts/change_url new file mode 100644 index 0000000..7134bae --- /dev/null +++ b/scripts/change_url @@ -0,0 +1,105 @@ +#!/bin/bash + +#================================================= +# GENERIC STARTING +#================================================= +# IMPORT GENERIC HELPERS +#================================================= + +source _common.sh +source /usr/share/yunohost/helpers + +#================================================= +# RETRIEVE ARGUMENTS +#================================================= + +old_domain=$YNH_APP_OLD_DOMAIN +old_path=$YNH_APP_OLD_PATH + +new_domain=$YNH_APP_NEW_DOMAIN +new_path=$YNH_APP_NEW_PATH + +app=$YNH_APP_INSTANCE_NAME + +#================================================= +# LOAD SETTINGS +#================================================= +ynh_script_progression --message="Loading installation settings..." --weight=1 + +# Needed for helper "ynh_add_nginx_config" +final_path=$(ynh_app_setting_get --app=$app --key=final_path) + +#================================================= +# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP +#================================================= +ynh_script_progression --message="Backing up SVG-edit before changing its URL (may take a while)..." --weight=1 + +# Backup the current version of the app +ynh_backup_before_upgrade +ynh_clean_setup () { + # Remove the new domain config file, the remove script won't do it as it doesn't know yet its location. + ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" + + # restore it if the upgrade fails + ynh_restore_upgradebackup +} +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors + +#================================================= +# CHECK WHICH PARTS SHOULD BE CHANGED +#================================================= + +change_domain=0 +if [ "$old_domain" != "$new_domain" ] +then + change_domain=1 +fi + +change_path=0 +if [ "$old_path" != "$new_path" ] +then + change_path=1 +fi + +#================================================= +# MODIFY URL IN NGINX CONF +#================================================= +ynh_script_progression --message="Updating NGINX web server configuration..." --weight=1 + +nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf + +# Change the path in the nginx config file +if [ $change_path -eq 1 ] +then + # Make a backup of the original nginx config file if modified + ynh_backup_if_checksum_is_different --file="$nginx_conf_path" + # Set global variables for nginx helper + domain="$old_domain" + path_url="$new_path" + # Create a dedicated nginx config + ynh_add_nginx_config +fi + +# Change the domain for nginx +if [ $change_domain -eq 1 ] +then + # Delete file checksum for the old conf file location + ynh_delete_file_checksum --file="$nginx_conf_path" + mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf + # Store file checksum for the new config file location + ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" +fi + +#================================================= +# RELOAD NGINX +#================================================= +ynh_script_progression --message="Reloading NGINX web server..." --weight=1 + +ynh_systemd_action --service_name=nginx --action=reload + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Change of URL completed for SVG-edit" --last diff --git a/scripts/install b/scripts/install index 104a443..966f630 100755 --- a/scripts/install +++ b/scripts/install @@ -1,55 +1,118 @@ #!/bin/bash -# Source YunoHost helpers -source /usr/share/yunohost/helpers -source _common.sh +#================================================= +# GENERIC START +#================================================= +# IMPORT GENERIC HELPERS +#================================================= +source _common.sh +source /usr/share/yunohost/helpers + +#================================================= +# MANAGE SCRIPT FAILURE +#================================================= + +ynh_clean_setup () { + true +} # Exit if an error occurs during the execution of the script ynh_abort_if_errors -export app=$YNH_APP_INSTANCE_NAME +#================================================= +# RETRIEVE ARGUMENTS FROM THE MANIFEST +#================================================= -# Retrieve arguments -ynh_export domain path_url is_public -export final_path=/var/www/$app +domain=$YNH_APP_ARG_DOMAIN +path_url=$YNH_APP_ARG_PATH +is_public=$YNH_APP_ARG_IS_PUBLIC -# Check if the app can be installed with this args -ynh_final_path_available +app=$YNH_APP_INSTANCE_NAME -# Normalize the url path syntax -path_url=$(ynh_normalize_url_path $path_url) +#================================================= +# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS +#================================================= +ynh_script_progression --message="Validating installation parameters..." --weight=1 + +final_path=/var/www/$app +test ! -e "$final_path" || ynh_die --message="This path already contains a folder" -# Check web path availability -ynh_webpath_available $domain $path_url # Register (book) web path -ynh_webpath_register $app $domain $path_url +ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url -# Save app settings -ynh_save_args is_public final_path path_url +#================================================= +# STORE SETTINGS FROM MANIFEST +#================================================= +ynh_script_progression --message="Storing installation settings..." --weight=1 + +ynh_app_setting_set --app=$app --key=domain --value=$domain +ynh_app_setting_set --app=$app --key=path --value=$path_url +ynh_app_setting_set --app=$app --key=is_public --value=$is_public + +# INSTALL DEPENDENCIES +#================================================= +ynh_script_progression --message="Installing dependencies..." --weight=3 -# Check needed packages ynh_install_app_dependencies $pkg_dependencies -# Copy source files -ynh_setup_source "$final_path" +#================================================= +# DOWNLOAD, CHECK AND UNPACK SOURCE +#================================================= +ynh_script_progression --message="Setting up source files..." --weight=6 + +ynh_app_setting_set --app=$app --key=final_path --value=$final_path +# Download, check integrity, uncompress and patch the source from app.src +ynh_setup_source --dest_dir="$final_path" + +#================================================= +# CREATE DEDICATED USER +#================================================= +ynh_script_progression --message="Configuring system user..." --weight=3 + +# Create a system user +ynh_system_user_create --username=$app + +#================================================= +# NGINX CONFIGURATION +#================================================= +ynh_script_progression --message="Configuring NGINX web server..." --weight=2 + +# Create a dedicated NGINX config +ynh_add_nginx_config + +#================================================= +# CUSTOM INSTRUCTION +#================================================= -# Custom instructions ynh_configure config.js "$final_path/config.js" ynh_configure custom.css "$final_path/custom.css" -# Set permissions to app files -ynh_set_default_perm "$final_path" +#================================================= +# SECURE FILES AND DIRECTORIES +#================================================= -# If app is public, add url to SSOWat conf as skipped_uris -ynh_sso_access "/" +chown -R $app: $final_path -# Modify Nginx configuration file and copy it to Nginx conf directory -ynh_add_nginx_config +#================================================= +# SETUP SSOWAT +#================================================= +ynh_script_progression --message="Configuring SSOwat..." --weight=1 -# Send a readme to the admin -ynh_print_OFF -message="You can now draw this address: https://${domain}${path_url}/ -If you facing an issue or want to improve this app, please open a new issue in this project: https://github.com/YunoHost-Apps/svgedit_ynh" +# Make app public if necessary or protect it +if [ $is_public -eq 1 ] +then + ynh_permission_update --permission "main" --add "visitors" +fi -ynh_send_readme_to_admin "$message" -ynh_print_ON +#================================================= +# RELOAD NGINX +#================================================= +ynh_script_progression --message="Reloading NGINX web server..." --weight=1 + +ynh_systemd_action --service_name=nginx --action=reload + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Installation of SVG-edit completed" --last diff --git a/scripts/remove b/scripts/remove index d2783bd..102f725 100755 --- a/scripts/remove +++ b/scripts/remove @@ -1,21 +1,50 @@ #!/bin/bash -# See comments in install script +#================================================= +# GENERIC START +#================================================= +# IMPORT GENERIC HELPERS +#================================================= + +source _common.sh +source /usr/share/yunohost/helpers + +#================================================= +# LOAD SETTINGS +#================================================= +ynh_script_progression --message="Loading installation settings..." --weight=1 + app=$YNH_APP_INSTANCE_NAME -# Source YunoHost helpers -source /usr/share/yunohost/helpers -source _common.sh +domain=$(ynh_app_setting_get --app=$app --key=domain) +final_path=$(ynh_app_setting_get --app=$app --key=final_path) -# Retrieve app settings -domain=$(ynh_app_setting_get "$app" domain) -final_path=$(ynh_app_setting_get "$app" final_path) +#================================================= +# REMOVE DEPENDENCIES +#================================================= +ynh_script_progression --message="Removing dependencies..." --weight=1 -# Remove dependencies +# Remove metapackage and its dependencies ynh_remove_app_dependencies -# Remove sources -ynh_secure_remove $final_path +#================================================= +# REMOVE APP MAIN DIR +#================================================= +ynh_script_progression --message="Removing SVG-edit main directory..." --weight=3 -# Remove nginx configuration file +# Remove the app directory securely +ynh_secure_remove --file="$final_path" + +#================================================= +# REMOVE NGINX CONFIGURATION +#================================================= +ynh_script_progression --message="Removing NGINX web server configuration..." --weight=1 + +# Remove the dedicated NGINX config ynh_remove_nginx_config + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Removal of SVG-edit completed" --last diff --git a/scripts/restore b/scripts/restore index 143cb38..4139dba 100755 --- a/scripts/restore +++ b/scripts/restore @@ -1,41 +1,91 @@ #!/bin/bash -# Source YunoHost helpers -source /usr/share/yunohost/helpers -source ../settings/scripts/_common.sh +#================================================= +# GENERIC START +#================================================= +# IMPORT GENERIC HELPERS +#================================================= +source ../settings/scripts/_common.sh +source /usr/share/yunohost/helpers + +#================================================= +# MANAGE SCRIPT FAILURE +#================================================= + +ynh_clean_setup () { + true +} # Exit if an error occurs during the execution of the script ynh_abort_if_errors -export app=$YNH_APP_INSTANCE_NAME +#================================================= +# LOAD SETTINGS +#================================================= +ynh_script_progression --message="Loading installation settings..." --weight=1 -# Retrieve old app settings -ynh_get_and_export domain path_url is_public final_path +app=$YNH_APP_INSTANCE_NAME -# Normalize the url path syntax -path_url=$(ynh_normalize_url_path $path_url) +domain=$(ynh_app_setting_get --app=$app --key=domain) +path_url=$(ynh_app_setting_get --app=$app --key=path) +final_path=$(ynh_app_setting_get --app=$app --key=final_path) -# Check web path availability -ynh_webpath_available $domain $path_url -# Check if the app can be installed with this args -ynh_final_path_available +#================================================= +# CHECK IF THE APP CAN BE RESTORED +#================================================= +ynh_script_progression --message="Validating restoration parameters..." --weight=1 + +ynh_webpath_available --domain=$domain --path_url=$path_url \ + || ynh_die --message="Path not available: ${domain}${path_url}" +test ! -d $final_path \ + || ynh_die --message="There is already a directory: $final_path " + +#================================================= +# RESTORE THE NGINX CONFIGURATION +#================================================= + +ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" + +#================================================= +# INSTALL DEPENDENCIES +#================================================= +ynh_script_progression --message="Installing dependencies..." --weight=2 -# Install dependency ynh_install_app_dependencies $pkg_dependencies -# Restore sources & data -ynh_restore +#================================================= +# RESTORE THE APP MAIN DIR +#================================================= +ynh_script_progression --message="Restoring SVG-edit main directory..." --weight=5 -# Restore permissions to app files -ynh_set_default_perm "$final_path" +ynh_restore_file --origin_path="$final_path" -# If app is public, add url to SSOWat conf as skipped_uris -ynh_sso_access "/" +#================================================= +# RECREATE THE DEDICATED USER +#================================================= +ynh_script_progression --message="Recreating the dedicated system user..." --weight=1 -# Restart webserver -systemctl reload nginx +# Create the dedicated user (if not existing) +ynh_system_user_create --username=$app -# Send message to the admin -message="If you facing an issue or want to improve this app, please open a new issue in this project: https://github.com/YunoHost-Apps/svgedit_ynh" +#================================================= +# RESTORE USER RIGHTS +#================================================= -ynh_send_readme_to_admin "$message" +# Restore permissions on app files +chown -R $app: $final_path + +#================================================= +# GENERIC FINALIZATION +#================================================= +# RELOAD NGINX AND PHP-FPM +#================================================= +ynh_script_progression --message="Reloading NGINX web server..." --weight=1 + +ynh_systemd_action --service_name=nginx --action=reload + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Restoration completed for SVG-edit" --last diff --git a/scripts/upgrade b/scripts/upgrade index 9111ce4..a8e29c4 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -1,17 +1,56 @@ #!/bin/bash -# Source YunoHost helpers -source /usr/share/yunohost/helpers +#================================================= +# GENERIC START +#================================================= +# IMPORT GENERIC HELPERS +#================================================= + source _common.sh +source /usr/share/yunohost/helpers -# See comments in install script -export app=$YNH_APP_INSTANCE_NAME +#================================================= +# LOAD SETTINGS +#================================================= +ynh_script_progression --message="Loading installation settings..." --weight=1 -# Retrieve app settings -ynh_get_and_export domain path_url is_public final_path +app=$YNH_APP_INSTANCE_NAME -# Check version -ynh_abort_if_up_to_date +domain=$(ynh_app_setting_get --app=$app --key=domain) +path_url=$(ynh_app_setting_get --app=$app --key=path) +is_public=$(ynh_app_setting_get --app=$app --key=is_public) +final_path=$(ynh_app_setting_get --app=$app --key=final_path) + +#================================================= +# CHECK VERSION +#================================================= + +upgrade_type=$(ynh_check_app_version_changed) + +#================================================= +# ENSURE DOWNWARD COMPATIBILITY +#================================================= +ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 + +# Fix is_public as a boolean value +if [ "$is_public" = "Yes" ]; then + ynh_app_setting_set --app=$app --key=is_public --value=1 + is_public=1 +elif [ "$is_public" = "No" ]; then + ynh_app_setting_set --app=$app --key=is_public --value=0 + is_public=0 +fi + +# If final_path doesn't exist, create it +if [ -z "$final_path" ]; then + final_path=/var/www/$app + ynh_app_setting_set --app=$app --key=final_path --value=$final_path +fi + +#================================================= +# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP +#================================================= +ynh_script_progression --message="Backing up SVG-edit before upgrading..." --weight=1 # Backup the current version of the app ynh_backup_before_upgrade @@ -19,36 +58,57 @@ ynh_clean_setup () { # restore it if the upgrade fails ynh_restore_upgradebackup } - # Exit if an error occurs during the execution of the script ynh_abort_if_errors -# Normalize the url path syntax -path_url=$(ynh_normalize_url_path $path_url) +#================================================= +# UPGRADE DEPENDENCIES +#================================================= +ynh_script_progression --message="Upgrading dependencies..." --weight=6 -# Step migration -version=${version:-2.8.1} -if ynh_version_le "2.8.1" ; then - final_path=${final_path:-/var/www/$app} - ynh_app_setting_set "$app" final_path "$final_path" - - # Install dependency properly - ynh_install_app_dependencies $pkg_dependencies -fi +ynh_install_app_dependencies $pkg_dependencies -# Copy source files -ynh_secure_remove $final_path -ynh_setup_source "$final_path" +#================================================= +# DOWNLOAD, CHECK AND UNPACK SOURCE +#================================================= +ynh_script_progression --message="Setting up source files..." --weight=5 + +ynh_app_setting_set --app=$app --key=final_path --value=$final_path +# Download, check integrity, uncompress and patch the source from app.src +ynh_secure_remove "$final_path" +ynh_setup_source --dest_dir="$final_path" + +#================================================= +# CREATE DEDICATED USER +#================================================= +ynh_script_progression --message="Configuring system user..." --weight=3 + +# Create a system user +ynh_system_user_create --username=$app + +#================================================= +# CUSTOM INSTRUCTION +#================================================= -# Custom instructions ynh_configure config.js "$final_path/config.js" ynh_configure custom.css "$final_path/custom.css" -# Set permissions to app files -ynh_set_default_perm "$final_path" +#================================================= +# SECURE FILES AND DIRECTORIES +#================================================= -# If app is public, add url to SSOWat conf as skipped_uris -ynh_sso_access "/" +# Set permissions on app files +chown -R $app: $final_path -# Set up nginx configuration -ynh_add_nginx_config +#================================================= +# RELOAD NGINX +#================================================= +ynh_script_progression --message="Reloading NGINX web server..." --weight=1 + +ynh_systemd_action --service_name=nginx --action=reload + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Upgrade of SVG-edit completed" --last From 55ff8e1f8139ca78d1dd047604fefcd096bcc2be Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Thu, 8 Oct 2020 20:56:15 +0200 Subject: [PATCH 2/7] Update manifest.json --- manifest.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/manifest.json b/manifest.json index 5fdc9fd..5524f3f 100644 --- a/manifest.json +++ b/manifest.json @@ -3,8 +3,8 @@ "id": "svgedit", "packaging_format": 1, "description": { - "en": "A fast web-based SVG drawing editor that works in any modern browser.", - "fr": "Outil rapide de manipulation de SVG en ligne qui fonctionne avec tout navigateur moderne." + "en": "Web-based SVG drawing editor working on any modern browser.", + "fr": "Édition de SVG en ligne fonctionnent avec tout navigateur moderne." }, "url": "https://github.com/SVG-Edit/svgedit", "version": "2.8.1~ynh2", From 6264c14bf2bf1f0388ba0b1826d10c60fefad575 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Fri, 4 Dec 2020 14:02:39 +0100 Subject: [PATCH 3/7] Update check_process --- check_process | 3 --- 1 file changed, 3 deletions(-) diff --git a/check_process b/check_process index dc07d3b..f462b46 100644 --- a/check_process +++ b/check_process @@ -17,9 +17,6 @@ # incorrect_path=1 port_already_use=0 change_url=1 -;;; Levels - # If the level 5 (Package linter) is forced to 1. Please add justifications here. - Level 5=auto ;;; Options Email= Notification=none From 8bd285cfc7796233192cd7cded9bd3c4e10b50fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Sat, 26 Dec 2020 21:43:26 +0100 Subject: [PATCH 4/7] Set SVG badge --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f83c0b6..24f662a 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # SVG-edit for YunoHost [![Integration level](https://dash.yunohost.org/integration/svgedit.svg)](https://dash.yunohost.org/appci/app/svgedit) ![](https://ci-apps.yunohost.org/ci/badges/svgedit.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/svgedit.maintain.svg) -[![Install SVG-edit with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=svgedit) +[![Install SVG-edit with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=svgedit) *[Lire ce readme en français.](./README_fr.md)* From bdf148a7139c326e52567af016f66263c6e1050b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Sat, 26 Dec 2020 21:44:05 +0100 Subject: [PATCH 5/7] Set SVG badge --- README_fr.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README_fr.md b/README_fr.md index fdd60e3..4035ea1 100644 --- a/README_fr.md +++ b/README_fr.md @@ -1,7 +1,7 @@ # SVG-edit pour YunoHost [![Niveau d'intégration](https://dash.yunohost.org/integration/svgedit.svg)](https://dash.yunohost.org/appci/app/svgedit) ![](https://ci-apps.yunohost.org/ci/badges/svgedit.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/svgedit.maintain.svg) -[![Installer SVG-edit avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=svgedit) +[![Installer SVG-edit avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=svgedit) *[Read this readme in english.](./README.md)* From 65a82b57680c45f1f85446f0eba7e325f785df55 Mon Sep 17 00:00:00 2001 From: YunoHost Bot Date: Fri, 14 May 2021 15:27:00 +0200 Subject: [PATCH 6/7] [autopatch] Update issue and PR templates (#10) Co-authored-by: Yunohost-Bot <> --- .github/ISSUE_TEMPLATE.md | 55 ++++++++++++++++++++++++++++++++ .github/PULL_REQUEST_TEMPLATE.md | 16 ++++++++++ 2 files changed, 71 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE.md create mode 100644 .github/PULL_REQUEST_TEMPLATE.md diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md new file mode 100644 index 0000000..2729a6b --- /dev/null +++ b/.github/ISSUE_TEMPLATE.md @@ -0,0 +1,55 @@ +--- +name: Bug report +about: When creating a bug report, please use the following template to provide all the relevant information and help debugging efficiently. + +--- + +**How to post a meaningful bug report** +1. *Read this whole template first.* +2. *Determine if you are on the right place:* + - *If you were performing an action on the app from the webadmin or the CLI (install, update, backup, restore, change_url...), you are on the right place!* + - *Otherwise, the issue may be due to the app itself. Refer to its documentation or repository for help.* + - *When in doubt, post here and we will figure it out together.* +3. *Delete the italic comments as you write over them below, and remove this guide.* +--- + +### Describe the bug + +*A clear and concise description of what the bug is.* + +### Context + +- Hardware: *VPS bought online / Old laptop or computer / Raspberry Pi at home / Internet Cube with VPN / Other ARM board / ...* +- YunoHost version: x.x.x +- I have access to my server: *Through SSH | through the webadmin | direct access via keyboard / screen | ...* +- Are you in a special context or did you perform some particular tweaking on your YunoHost instance?: *no / yes* + - If yes, please explain: +- Using, or trying to install package version/branch: +- If upgrading, current package version: *can be found in the admin, or with `yunohost app info $app_id`* + +### Steps to reproduce + +- *If you performed a command from the CLI, the command itself is enough. For example:* + ```sh + sudo yunohost app install the_app + ``` +- *If you used the webadmin, please perform the equivalent command from the CLI first.* +- *If the error occurs in your browser, explain what you did:* + 1. *Go to '...'* + 2. *Click on '...'* + 3. *Scroll down to '...'* + 4. *See error* + +### Expected behavior + +*A clear and concise description of what you expected to happen. You can remove this section if the command above is enough to understand your intent.* + +### Logs + +*When an operation fails, YunoHost provides a simple way to share the logs.* +- *In the webadmin, the error message contains a link to the relevant log page. On that page, you will be able to 'Share with Yunopaste'. If you missed it, the logs of previous operations are also available under Tools > Logs.* +- *In command line, the command to share the logs is displayed at the end of the operation and looks like `yunohost log display [log name] --share`. If you missed it, you can find the log ID of a previous operation using `yunohost log list`.* + +*After sharing the log, please copypaste directly the link provided by YunoHost (to help readability, no need to copypaste the entire content of the log here, just the link is enough...)* + +*If applicable and useful, add screenshots to help explain your problem.* diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..ef70e18 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,16 @@ +## Problem + +- *Description of why you made this PR* + +## Solution + +- *And how do you fix that problem* + +## PR Status + +- [ ] Code finished and ready to be reviewed/tested +- [ ] The fix/enhancement were manually tested (if applicable) + +## Automatic tests + +Automatic tests can be triggered on https://ci-apps-dev.yunohost.org/ *after creating the PR*, by commenting "!testme", "!gogogadgetoci" or "By the power of systemd, I invoke The Great App CI to test this Pull Request!". (N.B. : for this to work you need to be a member of the Yunohost-Apps organization) From 31033edd078a3285b1cb1cc8ce3038e95cd92eb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Fri, 14 May 2021 15:27:20 +0200 Subject: [PATCH 7/7] Patch (#11) * fix --- README.md | 4 +- README_fr.md | 4 +- check_process | 10 +-- conf/config-sample.js | 146 +++++++++++++++++++++++++++++++ conf/config.js.j2 | 0 conf/custom.css.j2 | 0 manifest.json | 14 +-- scripts/_common.sh | 197 ------------------------------------------ scripts/install | 12 +-- scripts/restore | 7 -- scripts/upgrade | 39 ++++----- 11 files changed, 173 insertions(+), 260 deletions(-) create mode 100644 conf/config-sample.js delete mode 100644 conf/config.js.j2 delete mode 100644 conf/custom.css.j2 diff --git a/README.md b/README.md index 24f662a..6647afe 100644 --- a/README.md +++ b/README.md @@ -36,8 +36,8 @@ Not supported. #### Supported architectures -* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/svgedit%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/svgedit/) -* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/svgedit%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/svgedit/) +* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/svgedit.svg)](https://ci-apps.yunohost.org/ci/apps/svgedit/) +* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/svgedit.svg)](https://ci-apps-arm.yunohost.org/ci/apps/svgedit/) ## Limitations diff --git a/README_fr.md b/README_fr.md index 4035ea1..e5a866c 100644 --- a/README_fr.md +++ b/README_fr.md @@ -36,8 +36,8 @@ Non supporté. #### Architectures supportées -* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/svgedit%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/svgedit/) -* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/svgedit%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/svgedit/) +* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/svgedit.svg)](https://ci-apps.yunohost.org/ci/apps/svgedit/) +* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/svgedit.svg)](https://ci-apps-arm.yunohost.org/ci/apps/svgedit/) ## Limitations diff --git a/check_process b/check_process index f462b46..80786f9 100644 --- a/check_process +++ b/check_process @@ -1,9 +1,9 @@ ;; Test complet ; Manifest - domain="domain.tld" (DOMAIN) - path="/path" (PATH) - admin="john" (USER) - is_public=1 (PUBLIC|public=1|private=0) + domain="domain.tld" + path="/path" + admin="john" + is_public=1 ; Checks pkg_linter=1 setup_sub_dir=1 @@ -14,8 +14,6 @@ upgrade=1 backup_restore=1 multi_instance=1 - # incorrect_path=1 - port_already_use=0 change_url=1 ;;; Options Email= diff --git a/conf/config-sample.js b/conf/config-sample.js new file mode 100644 index 0000000..6209d21 --- /dev/null +++ b/conf/config-sample.js @@ -0,0 +1,146 @@ +// DO NOT EDIT THIS FILE! +// THIS FILE IS JUST A SAMPLE; TO APPLY, YOU MUST +// CREATE A NEW FILE config.js AND ADD CONTENTS +// SUCH AS SHOWN BELOW INTO THAT FILE. + +/*globals svgEditor*/ +/* +The config.js file is intended for the setting of configuration or + preferences which must run early on; if this is not needed, it is + recommended that you create an extension instead (for greater + reusability and modularity). +*/ + +// CONFIG AND EXTENSION SETTING +/* +See defaultConfig and defaultExtensions in svg-editor.js for a list + of possible configuration settings. + +See svg-editor.js for documentation on using setConfig(). +*/ + +// URL OVERRIDE CONFIG +svgEditor.setConfig({ + /** + To override the ability for URLs to set URL-based SVG content, + uncomment the following: + */ + // preventURLContentLoading: true, + /** + To override the ability for URLs to set other configuration (including + extension config), uncomment the following: + */ + // preventAllURLConfig: true, + /** + To override the ability for URLs to set their own extensions, + uncomment the following (note that if setConfig() is used in + extension code, it will still be additive to extensions, + however): + */ + // lockExtensions: true, +}); + +svgEditor.setConfig({ + /* + Provide default values here which differ from that of the editor but + which the URL can override + */ +}, {allowInitialUserOverride: true}); + +// EXTENSION CONFIG +svgEditor.setConfig({ + extensions: [ + // 'ext-overview_window.js', 'ext-markers.js', 'ext-connector.js', 'ext-eyedropper.js', 'ext-shapes.js', 'ext-imagelib.js', 'ext-grid.js', 'ext-polygon.js', 'ext-star.js', 'ext-panning.js', 'ext-storage.js' + ] + // , noDefaultExtensions: false, // noDefaultExtensions can only be meaningfully used in config.js or in the URL +}); + +// OTHER CONFIG +svgEditor.setConfig({ + // canvasName: 'default', + // canvas_expansion: 3, + // initFill: { + // color: 'FF0000', // solid red + // opacity: 1 + // }, + // initStroke: { + // width: 5, + // color: '000000', // solid black + // opacity: 1 + // }, + // initOpacity: 1, + // colorPickerCSS: null, + // initTool: 'select', + // exportWindowType: 'new', // 'same' + // wireframe: false, + // showlayers: false, + // no_save_warning: false, + // PATH CONFIGURATION + // imgPath: 'images/', + // langPath: 'locale/', + // extPath: 'extensions/', + // jGraduatePath: 'jgraduate/images/', + /* + Uncomment the following to allow at least same domain (embedded) access, + including file:// access. + Setting as `['*']` would allow any domain to access but would be unsafe to + data privacy and integrity. + */ + // allowedOrigins: [window.location.origin || 'null'], // May be 'null' (as a string) when used as a file:// URL + // DOCUMENT PROPERTIES + // dimensions: [640, 480], + // EDITOR OPTIONS + // gridSnapping: false, + // gridColor: '#000', + // baseUnit: 'px', + // snappingStep: 10, + // showRulers: true, + // EXTENSION-RELATED (GRID) + // showGrid: false, // Set by ext-grid.js + // EXTENSION-RELATED (STORAGE) + // noStorageOnLoad: false, // Some interaction with ext-storage.js; prevent even the loading of previously saved local storage + // forceStorage: false, // Some interaction with ext-storage.js; strongly discouraged from modification as it bypasses user privacy by preventing them from choosing whether to keep local storage or not + // emptyStorageOnDecline: true, // Used by ext-storage.js; empty any prior storage if the user declines to store +}); + +// PREF CHANGES +/** +setConfig() can also be used to set preferences in addition to + configuration (see defaultPrefs in svg-editor.js for a list of + possible settings), but at least if you are using ext-storage.js + to store preferences, it will probably be better to let your + users control these. +As with configuration, one may use allowInitialUserOverride, but + in the case of preferences, any previously stored preferences + will also thereby be enabled to override this setting (and at a + higher priority than any URL preference setting overrides). + Failing to use allowInitialUserOverride will ensure preferences + are hard-coded here regardless of URL or prior user storage setting. +*/ +svgEditor.setConfig( + { + // lang: '', // Set dynamically within locale.js if not previously set + // iconsize: '', // Will default to 's' if the window height is smaller than the minimum height and 'm' otherwise + /** + * When showing the preferences dialog, svg-editor.js currently relies + * on curPrefs instead of $.pref, so allowing an override for bkgd_color + * means that this value won't have priority over block auto-detection as + * far as determining which color shows initially in the preferences + * dialog (though it can be changed and saved). + */ + // bkgd_color: '#FFF', + // bkgd_url: '', + // img_save: 'embed', + // Only shows in UI as far as alert notices + // save_notice_done: false, + // export_notice_done: false + } +); +svgEditor.setConfig( + { + // Indicate pref settings here if you wish to allow user storage or URL settings + // to be able to override your default preferences (unless other config options + // have already explicitly prevented one or the other) + }, + {allowInitialUserOverride: true} +); diff --git a/conf/config.js.j2 b/conf/config.js.j2 deleted file mode 100644 index e69de29..0000000 diff --git a/conf/custom.css.j2 b/conf/custom.css.j2 deleted file mode 100644 index e69de29..0000000 diff --git a/manifest.json b/manifest.json index c7a1fb2..4a11711 100644 --- a/manifest.json +++ b/manifest.json @@ -18,7 +18,7 @@ "name": "Luc Didry" }, "requirements": { - "yunohost": ">> 3.8.1" + "yunohost": ">= 4.2.4" }, "multi_instance": true, "services": [ @@ -29,29 +29,17 @@ { "name": "domain", "type": "domain", - "ask": { - "en": "Choose a domain name for SVG-edit", - "fr": "Choisissez un nom de domaine pour SVG-edit" - }, "example": "domain.org" }, { "name": "path", "type": "path", - "ask": { - "en": "Choose a path for SVG-edit", - "fr": "Choisissez un chemin pour SVG-edit" - }, "example": "/svgedit", "default": "/svgedit" }, { "name": "is_public", "type": "boolean", - "ask": { - "en": "Is it a public application?", - "fr": "Est-ce une application publique ?" - }, "help": { "en": "If enabled, SVG-edit will be accessible by people who do not have an account. This can be changed later via the webadmin.", "fr": "Si cette case est cochée, SVG-edit sera accessible aux personnes n’ayant pas de compte. Vous pourrez changer ceci plus tard via la webadmin." diff --git a/scripts/_common.sh b/scripts/_common.sh index 672b052..944a65e 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -4,12 +4,6 @@ # COMMON VARIABLES #================================================= -# dependencies used by the app -pkg_dependencies="wget" - -# App package root directory should be the parent folder -PKG_DIR=$(cd ../; pwd) - #================================================= # PERSONAL HELPERS #================================================= @@ -17,197 +11,6 @@ PKG_DIR=$(cd ../; pwd) #================================================= # EXPERIMENTAL HELPERS #================================================= -ynh_set_default_perm () { - local DIRECTORY=$1 - local user=$YNH_APP_INSTANCE_NAME - id -u $user 2>/dev/null || user=root - # Set permissions - chown -R $user:www-data $DIRECTORY - chmod -R 440 $DIRECTORY - find $DIRECTORY -type d -print0 | xargs -0 chmod 550 \ - || echo "No file to modify" - -} -ynh_export () { - local ynh_arg="" - for var in $@; - do - ynh_arg=$(echo $var | awk '{print toupper($0)}') - if [ "$var" == "path_url" ]; then - ynh_arg="PATH" - fi - ynh_arg="YNH_APP_ARG_$ynh_arg" - export $var=${!ynh_arg} - done -} -ynh_get_and_export () { - local ynh_arg="" - for var in $@; - do - ynh_arg=$var - if [ "$var" == "path_url" ]; then - ynh_arg="path" - fi - export $var=$(ynh_app_setting_get $app $ynh_arg) - done -} - -# Check the path doesn't exist -# usage: ynh_final_path_available PATH -ynh_final_path_available () { - if [ -e "$final_path" ] - then - ynh_die "This path '$final_path' already contains a folder" - fi -} - -# Save listed var in YunoHost app settings -# usage: ynh_save_args VARNAME1 [VARNAME2 [...]] -ynh_save_args () { - for var in $@; - do - local setting_var="$var" - if [ "$var" == "path_url" ]; then - setting_var="path" - fi - ynh_app_setting_set $app $setting_var ${!var} - done -} -ynh_sso_access () { - ynh_app_setting_set $app unprotected_uris "/" - - if [[ $is_public -eq 0 ]]; then - ynh_app_setting_set $app protected_uris "$1" - fi - yunohost app ssowatconf -} - -ynh_exit_if_up_to_date () { - if [ "${version}" = "${last_version}" ]; then - info "Up-to-date, nothing to do" - ynh_die "Up-to-date, nothing to do" 0 - fi -} - -log() { - echo "${1}" -} - -info() { - log "[INFO] ${1}" -} - -warn() { - log "[WARN] ${1}" -} - -err() { - log "[ERR] ${1}" -} - -to_logs() { - - # When yunohost --verbose or bash -x - if $_ISVERBOSE; then - cat - else - cat > /dev/null - fi -} - -ynh_read_json () { - python3 -c "import sys, json;print(json.load(open('$1'))['$2'])" -} - - -ynh_configure () { - local TEMPLATE=$1 - local DEST=$2 - type j2 2>/dev/null || pip install j2cli - j2 "${PKG_DIR}/conf/$TEMPLATE.j2" > "${PKG_DIR}/conf/$TEMPLATE" - ynh_backup_if_checksum_is_different "$DEST" - cp "${PKG_DIR}/conf/$TEMPLATE" "$DEST" - ynh_store_file_checksum "$DEST" - chown root: "$DEST" -} - - -# Exit without error if the package is up to date -# -# This helper should be used to avoid an upgrade of a package -# when it's not needed. -# -# To force an upgrade, even if the package is up to date, -# you have to set the variable YNH_FORCE_UPGRADE before. -# example: YNH_FORCE_UPGRADE=1 yunohost app upgrade MyApp -# -# usage: ynh_abort_if_up_to_date -ynh_abort_if_up_to_date () { - local force_upgrade=${YNH_FORCE_UPGRADE:-0} - local package_check=${PACKAGE_CHECK_EXEC:-0} - - local version=$(ynh_read_json "/etc/yunohost/apps/$YNH_APP_INSTANCE_NAME/manifest.json" "version" || echo 1.0) - local last_version=$(ynh_read_manifest "version" || echo 1.0) - if [ "$version" = "$last_version" ] - then - if [ "$force_upgrade" != "0" ] - then - echo "Upgrade forced by YNH_FORCE_UPGRADE." >&2 - unset YNH_FORCE_UPGRADE - elif [ "$package_check" != "0" ] - then - echo "Upgrade forced for package check." >&2 - else - ynh_die "Up-to-date, nothing to do" 0 - fi - fi -} - - -ynh_version_gt() { test "$(printf '%s\n' "$@" | sort -V | head -n 1)" != "$1"; } - -# In upgrade script allow to test if the app is less than or equal a specific version -# -# usage: ynh_version_le "0.5" -ynh_version_le() { - local version=$(ynh_read_json "/etc/yunohost/apps/$YNH_APP_INSTANCE_NAME/manifest.json" "version" || echo 1.0) - ynh_version_gt "$1" "${version}" -} - -ynh_debian_release () { - lsb_release --codename --short -} - -is_stretch () { - if [ "$(ynh_debian_release)" == "stretch" ] - then - return 0 - else - return 1 - fi -} - -is_jessie () { - if [ "$(ynh_debian_release)" == "jessie" ] - then - return 0 - else - return 1 - fi -} - -# Reload (or other actions) a service and print a log in case of failure. -# -# usage: ynh_system_reload service_name [action] -# | arg: service_name - Name of the service to reload -# | arg: action - Action to perform with systemctl. Default: reload -ynh_system_reload () { - local service_name=$1 - local action=${2:-reload} - - # Reload, restart or start and print the log if the service fail to start or reload - systemctl $action $service_name || ( journalctl --lines=20 -u $service_name >&2 && false) -} #================================================= # FUTURE OFFICIAL HELPERS diff --git a/scripts/install b/scripts/install index 966f630..03034dd 100755 --- a/scripts/install +++ b/scripts/install @@ -47,13 +47,6 @@ ynh_script_progression --message="Storing installation settings..." --weight=1 ynh_app_setting_set --app=$app --key=domain --value=$domain ynh_app_setting_set --app=$app --key=path --value=$path_url -ynh_app_setting_set --app=$app --key=is_public --value=$is_public - -# INSTALL DEPENDENCIES -#================================================= -ynh_script_progression --message="Installing dependencies..." --weight=3 - -ynh_install_app_dependencies $pkg_dependencies #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE @@ -84,8 +77,7 @@ ynh_add_nginx_config # CUSTOM INSTRUCTION #================================================= -ynh_configure config.js "$final_path/config.js" -ynh_configure custom.css "$final_path/custom.css" +ynh_add_config --template="config-sample.js" --destination="$final_path/config.js" #================================================= # SECURE FILES AND DIRECTORIES @@ -101,7 +93,7 @@ ynh_script_progression --message="Configuring SSOwat..." --weight=1 # Make app public if necessary or protect it if [ $is_public -eq 1 ] then - ynh_permission_update --permission "main" --add "visitors" + ynh_permission_update --permission="main" --add="visitors" fi #================================================= diff --git a/scripts/restore b/scripts/restore index 4139dba..50f3fd8 100755 --- a/scripts/restore +++ b/scripts/restore @@ -46,13 +46,6 @@ test ! -d $final_path \ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" -#================================================= -# INSTALL DEPENDENCIES -#================================================= -ynh_script_progression --message="Installing dependencies..." --weight=2 - -ynh_install_app_dependencies $pkg_dependencies - #================================================= # RESTORE THE APP MAIN DIR #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index a8e29c4..7530181 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -18,7 +18,6 @@ app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get --app=$app --key=domain) path_url=$(ynh_app_setting_get --app=$app --key=path) -is_public=$(ynh_app_setting_get --app=$app --key=is_public) final_path=$(ynh_app_setting_get --app=$app --key=final_path) #================================================= @@ -32,21 +31,19 @@ upgrade_type=$(ynh_check_app_version_changed) #================================================= ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 -# Fix is_public as a boolean value -if [ "$is_public" = "Yes" ]; then - ynh_app_setting_set --app=$app --key=is_public --value=1 - is_public=1 -elif [ "$is_public" = "No" ]; then - ynh_app_setting_set --app=$app --key=is_public --value=0 - is_public=0 -fi - # If final_path doesn't exist, create it if [ -z "$final_path" ]; then final_path=/var/www/$app ynh_app_setting_set --app=$app --key=final_path --value=$final_path fi +# Cleaning legacy permissions +if ynh_legacy_permissions_exists; then + ynh_legacy_permissions_delete_all + + ynh_app_setting_delete --app=$app --key=is_public +fi + #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= @@ -61,22 +58,19 @@ ynh_clean_setup () { # Exit if an error occurs during the execution of the script ynh_abort_if_errors -#================================================= -# UPGRADE DEPENDENCIES -#================================================= -ynh_script_progression --message="Upgrading dependencies..." --weight=6 - -ynh_install_app_dependencies $pkg_dependencies - #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= ynh_script_progression --message="Setting up source files..." --weight=5 -ynh_app_setting_set --app=$app --key=final_path --value=$final_path -# Download, check integrity, uncompress and patch the source from app.src -ynh_secure_remove "$final_path" -ynh_setup_source --dest_dir="$final_path" +if [ "$upgrade_type" == "UPGRADE_APP" ] +then + ynh_script_progression --message="Upgrading source files..." --time --weight=1 + + ynh_secure_remove "$final_path" + # Download, check integrity, uncompress and patch the source from app.src + ynh_setup_source --dest_dir="$final_path" +fi #================================================= # CREATE DEDICATED USER @@ -90,8 +84,7 @@ ynh_system_user_create --username=$app # CUSTOM INSTRUCTION #================================================= -ynh_configure config.js "$final_path/config.js" -ynh_configure custom.css "$final_path/custom.css" +ynh_add_config --template="config-sample.js" --destination="$final_path/config.js" #================================================= # SECURE FILES AND DIRECTORIES