Ver código fonte

Merge pull request #46 from YunoHost-Apps/upgrade

Apply example_ynh
yalh76 3 anos atrás
pai
commit
f60a7cf379
18 arquivos alterados com 389 adições e 360 exclusões
  1. 10 0
      CHANGELOG.md
  2. 24 35
      README.md
  3. 25 39
      README_fr.md
  4. 40 40
      check_process
  5. 2 2
      conf/app.src
  6. 0 0
      doc/.gitkeep
  7. 6 0
      doc/DESCRIPTION.md
  8. 5 0
      doc/DESCRIPTION_fr.md
  9. 10 0
      doc/DISCLAIMER.md
  10. 10 0
      doc/DISCLAIMER_fr.md
  11. 0 0
      doc/screenshots/.gitkeep
  12. 7 2
      manifest.json
  13. 134 130
      scripts/_common.sh
  14. 6 2
      scripts/backup
  15. 29 30
      scripts/install
  16. 10 9
      scripts/remove
  17. 13 14
      scripts/restore
  18. 58 57
      scripts/upgrade

+ 10 - 0
CHANGELOG.md

@@ -4,6 +4,16 @@ Changelog
 ## Unreleased
 - Nothing for now...
 
+## [1.3.2~ynh1]() - 2022-01-25
+
+#### Fixed
+- [Fix tar symlink for apps - archivist 1.3.2]()
+
+## [1.3.1~ynh1](https://github.com/YunoHost-Apps/archivist_ynh/commit/a9070b11e13d37908cf246804c0d331a57fea115) - 2021-11-07
+
+#### Fixed
+- [Fix multimedia hook killing hard drives - archivist 1.3.1](https://github.com/YunoHost-Apps/archivist_ynh/commit/a9070b11e13d37908cf246804c0d331a57fea115)
+
 ## [1.3~ynh1](https://github.com/YunoHost-Apps/archivist_ynh/pull/40) - 2021-05-27
 
 #### Fixed

+ 24 - 35
README.md

@@ -1,70 +1,59 @@
+<!--
+N.B.: This README was automatically generated by https://github.com/YunoHost/apps/tree/master/tools/README-generator
+It shall NOT be edited by hand.
+-->
+
 # Archivist for YunoHost
 
-[![Integration level](https://dash.yunohost.org/integration/archivist.svg)](https://dash.yunohost.org/appci/app/archivist) ![](https://ci-apps.yunohost.org/ci/badges/archivist.status.svg) [![](https://ci-apps.yunohost.org/ci/badges/archivist.maintain.svg)](https://github.com/YunoHost/Apps/#what-to-do-if-i-cant-maintain-my-app-anymore-)  
-[![Install archivist with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=archivist)
+[![Integration level](https://dash.yunohost.org/integration/archivist.svg)](https://dash.yunohost.org/appci/app/archivist) ![Working status](https://ci-apps.yunohost.org/ci/badges/archivist.status.svg) ![Maintenance status](https://ci-apps.yunohost.org/ci/badges/archivist.maintain.svg)  
+[![Install Archivist with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=archivist)
 
 *[Lire ce readme en français.](./README_fr.md)*
 
-> *This package allow you to install archivist 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.*
+> *This package allows you to install Archivist 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
+
 Archivist is an automatic backup system for your server.  
 It able to makes backups of your YunoHost core and your apps by using the YunoHost backup command.  
 It can also makes backups of specified directories.  
 Your backups can be send to many other places, local or distant.  
 Archivist is automatically launched periodicaly to update your backups and send the modifications to the other places.
 
-**Shipped version:** 1.3.1
 
-## Screenshots
 
-## Demo
-
-No demo available.
+**Shipped version:** 1.3.2~ynh2
+## Disclaimers / important information
 
 ## Configuration
 
 The configuration of archivist can be changed in the file /opt/yunohost/archivist/Backup_list.conf  
 Please read the [documentation](https://github.com/maniackcrudelis/archivist/blob/master/Configuration.md) about the configuration of archivist for more informations.
 
-## Documentation
-
- * YunoHost documentation: There no specific documentations, feel free to contribute.
-
-## YunoHost specific features
-
-#### Multi-users support
-
-Not relevant.
-
-#### Supported architectures
-
-* x86-64b - [![Build Status](https://ci-apps.yunohost.org/ci/logs/archivist%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/archivist/)
-* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/archivist%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/archivist/)
-* Buster x86-64b - [![Build Status](https://ci-buster.nohost.me/ci/logs/archivist%20%28Apps%29.svg)](https://ci-buster.nohost.me/ci/apps/archivist/)
-
 ## Limitations
 
 * Encfs, which be used to encrypt the data, is not fully secured.  
 Have a look to the [security audit](https://defuse.ca/audits/encfs.htm) to have more informations.
 
-## Links
 
- * Report a bug: https://github.com/YunoHost-Apps/archivist_ynh/issues
- * archivist website: https://github.com/maniackcrudelis/archivist
- * YunoHost website: https://yunohost.org/
+## Documentation and resources
 
----
+* Official app website: <https://github.com/maniackcrudelis/archivist>
+* Upstream app code repository: <https://github.com/maniackcrudelis/archivist>
+* YunoHost documentation for this app: <https://yunohost.org/app_archivist>
+* Report a bug: <https://github.com/YunoHost-Apps/archivist_ynh/issues>
 
-Developers infos
-----------------
+## Developer info
 
-Please do your pull request to the [testing branch](https://github.com/YunoHost-Apps/archivist_ynh/tree/testing).
+Please send your pull request to the [testing branch](https://github.com/YunoHost-Apps/archivist_ynh/tree/testing).
 
 To try the testing branch, please proceed like that.
-```
-sudo yunohost app install https://github.com/YunoHost-Apps/archivist_ynh/tree/testing --force --debug
+
+``` bash
+sudo yunohost app install https://github.com/YunoHost-Apps/archivist_ynh/tree/testing --debug
 or
 sudo yunohost app upgrade archivist -u https://github.com/YunoHost-Apps/archivist_ynh/tree/testing --debug
 ```
+
+**More info regarding app packaging:** <https://yunohost.org/packaging_apps>

+ 25 - 39
README_fr.md

@@ -1,72 +1,58 @@
+<!--
+N.B.: This README was automatically generated by https://github.com/YunoHost/apps/tree/master/tools/README-generator
+It shall NOT be edited by hand.
+-->
+
 # Archivist pour YunoHost
 
-[![Niveau d'intégration](https://dash.yunohost.org/integration/archivist.svg)](https://dash.yunohost.org/appci/app/archivist) ![](https://ci-apps.yunohost.org/ci/badges/archivist.status.svg) [![](https://ci-apps.yunohost.org/ci/badges/archivist.maintain.svg)](https://github.com/YunoHost/Apps/#what-to-do-if-i-cant-maintain-my-app-anymore-)  
-[![Installer archivist avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=archivist)
+[![Niveau d'intégration](https://dash.yunohost.org/integration/archivist.svg)](https://dash.yunohost.org/appci/app/archivist) ![Statut du fonctionnement](https://ci-apps.yunohost.org/ci/badges/archivist.status.svg) ![Statut de maintenance](https://ci-apps.yunohost.org/ci/badges/archivist.maintain.svg)  
+[![Installer Archivist avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=archivist)
 
 *[Read this readme in english.](./README.md)*
 
-> *Ce package vous permet d'installer archivist rapidement et simplement sur un serveur YunoHost.  
-Si vous n'avez pas YunoHost, merci de regarder [ici](https://yunohost.org/#/install_fr) pour savoir comment l'installer et en profiter.*
+> *Ce package vous permet d'installer Archivist rapidement et simplement sur un serveur YunoHost.
+Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour savoir comment l'installer et en profiter.*
+
+## Vue d'ensemble
 
-## Résumé
 Archivist est un système de sauvegarde automatique pour votre serveur.  
 Il est capable de faire des sauvegardes de votre noyau YunoHost et de vos applications en utilisant la commande de backup de YunoHost.  
 Il peut également faire des sauvegardes de répertoires spécifiques.  
 Vos sauvegardes peuvent être envoyées à de nombreux autres endroits, locaux ou distants.  
 Archivist est automatiquement lancé périodiquement pour mettre à jour vos sauvegardes et envoyer les modifications aux autres emplacements.
 
-**Version embarquée:** 1.3.1
-
-## Captures d'écran
-
-## Démo
 
-Aucune démo pour cette application.
+**Version incluse :** 1.3.2~ynh2
+## Avertissements / informations importantes
 
 ## Configuration
 
 La configuration d'archivist peut être modifiée dans le fichier /opt/yunohost/archivist/Backup_list.conf  
 Veuillez lire la [documentation](https://github.com/maniackcrudelis/archivist/blob/master/Configuration_fr.md) sur la configuration d'archivist pour plus d'informations.
 
-## Documentation
-
- * Documentation YunoHost: Il n'y a pas d'autre documentation, n'hésitez pas à contribuer.
-
-## Fonctionnalités spécifiques à YunoHost
-
-#### Support multi-utilisateurs
-
-Non applicable
-
-#### Architectures supportées.
-
-* x86-64b - [![Build Status](https://ci-apps.yunohost.org/ci/logs/archivist%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/archivist/)
-* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/archivist%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/archivist/)
-* Buster x86-64b - [![Build Status](https://ci-buster.nohost.me/ci/logs/archivist%20%28Apps%29.svg)](https://ci-buster.nohost.me/ci/apps/archivist/)
-
 ## Limitations
 
 * Encfs, qui est utilisé pour chiffrer les données, n'est pas parfaitement sécurisé.  
 Consultez l'[audit de sécurité](https://defuse.ca/audits/encfs.htm) pour avoir plus d'informations.
 
-## Informations additionnelles
-
-## Liens
 
- * Reporter un bug: https://github.com/YunoHost-Apps/archivist_ynh/issues
- * Site de archivist: https://github.com/maniackcrudelis/archivist
- * Site de YunoHost: https://yunohost.org/
+## Documentations et ressources
 
----
+* Site officiel de l'app : <https://github.com/maniackcrudelis/archivist>
+* Dépôt de code officiel de l'app : <https://github.com/maniackcrudelis/archivist>
+* Documentation YunoHost pour cette app : <https://yunohost.org/app_archivist>
+* Signaler un bug : <https://github.com/YunoHost-Apps/archivist_ynh/issues>
 
-Informations à l'intention des développeurs
-----------------
+## Informations pour les développeurs
 
 Merci de faire vos pull request sur la [branche testing](https://github.com/YunoHost-Apps/archivist_ynh/tree/testing).
 
-Pour tester la branche testing, merci de procéder ainsi.
-```
-sudo yunohost app install https://github.com/YunoHost-Apps/archivist_ynh/tree/testing --force --debug
+Pour essayer la branche testing, procédez comme suit.
+
+``` bash
+sudo yunohost app install https://github.com/YunoHost-Apps/archivist_ynh/tree/testing --debug
 ou
 sudo yunohost app upgrade archivist -u https://github.com/YunoHost-Apps/archivist_ynh/tree/testing --debug
 ```
+
+**Plus d'infos sur le packaging d'applications :** <https://yunohost.org/packaging_apps>

+ 40 - 40
check_process

@@ -1,47 +1,47 @@
 ;; Test complet
-    ; Manifest
-        encrypt=1
-        encryption_pwd="password"
-        core_backup=1
-        apps_backup=1
-        frequency="Weekly"
-    ; Config_panel
-        main.encryption.encrypt=1|0
-        main.encryption.encryption_pwd=password1|password2
-        main.backup_types.core_backup=1|0
-        main.backup_types.apps_backup=1|0
-        main.backup_options.frequency=Daily|Each 3 days|Weekly|Biweekly|Monthly
-        main.backup_options.max_size=1000
-        main.overwrite_files.overwrite_cron=1|0
-        main.global_config.email_type=1|0
-    ; Checks
-        pkg_linter=1
-        setup_sub_dir=0
-        setup_root=0
-        setup_nourl=1
-        setup_private=0
-        setup_public=0
-        upgrade=1
-        upgrade=1	from_commit=2b2793737d5e1374659cbb74838d10162a2147e6
-        backup_restore=1
-        multi_instance=1
-        port_already_use=0
-        change_url=0
-        config_panel=0
+	; Manifest
+		encrypt=1
+		encryption_pwd="password"
+		core_backup=1
+		apps_backup=1
+		frequency="Weekly"
+	; Config_panel
+		main.encryption.encrypt=1|0
+		main.encryption.encryption_pwd=password1|password2
+		main.backup_types.core_backup=1|0
+		main.backup_types.apps_backup=1|0
+		main.backup_options.frequency=Daily|Each 3 days|Weekly|Biweekly|Monthly
+		main.backup_options.max_size=1000
+		main.overwrite_files.overwrite_cron=1|0
+		main.global_config.email_type=1|0
+	; Checks
+		pkg_linter=1
+		setup_sub_dir=0
+		setup_root=0
+		setup_nourl=1
+		setup_private=0
+		setup_public=0
+		upgrade=1
+		upgrade=1	from_commit=2b2793737d5e1374659cbb74838d10162a2147e6
+		backup_restore=1
+		multi_instance=1
+		port_already_use=0
+		change_url=0
+		config_panel=0
 ;; Test actions without encryption
 # Actions can't be tested with the encryption on, because LXC does not support fuse.
-    ; Manifest
-        encrypt=0
-        encryption_pwd=""
-        core_backup=1
-        apps_backup=1
-    ; Checks
-        setup_nourl=1
-        actions=1
+	; Manifest
+		encrypt=0
+		encryption_pwd=""
+		core_backup=1
+		apps_backup=1
+	; Checks
+		setup_nourl=1
+		actions=1
 ;;; Options
 Email=
 Notification=change
 ;;; Upgrade options
-    ; commit=2b2793737d5e1374659cbb74838d10162a2147e6
-        name=03 Nov 2017 2b2793737d5e1374659cbb74838d10162a2147e6
-        manifest_arg=encrypt=1&encryption_pwd="password"&core_backup=1&apps_backup=1&frequency="Weekly"&
+	; commit=2b2793737d5e1374659cbb74838d10162a2147e6
+		name=03 Nov 2017 2b2793737d5e1374659cbb74838d10162a2147e6
+		manifest_arg=encrypt=1&encryption_pwd="password"&core_backup=1&apps_backup=1&frequency="Weekly"&

+ 2 - 2
conf/app.src

@@ -1,5 +1,5 @@
-SOURCE_URL=https://github.com/maniackcrudelis/archivist/archive/refs/tags/v1.3.1.tar.gz
-SOURCE_SUM=1333254f3c2713aec5c802ba661788b12ca9261bce204476a0715a9205c74ec9
+SOURCE_URL=https://github.com/maniackcrudelis/archivist/archive/refs/tags/v1.3.2.tar.gz
+SOURCE_SUM=b87fa47d999a35c7d583cf4fb0cdfe9648ff58a69dec031789482886c2e3e5c4
 SOURCE_SUM_PRG=sha256sum
 SOURCE_FORMAT=tar.gz
 SOURCE_IN_SUBDIR=true

+ 0 - 0
doc/.gitkeep


+ 6 - 0
doc/DESCRIPTION.md

@@ -0,0 +1,6 @@
+Archivist is an automatic backup system for your server.  
+It able to makes backups of your YunoHost core and your apps by using the YunoHost backup command.  
+It can also makes backups of specified directories.  
+Your backups can be send to many other places, local or distant.  
+Archivist is automatically launched periodicaly to update your backups and send the modifications to the other places.
+

+ 5 - 0
doc/DESCRIPTION_fr.md

@@ -0,0 +1,5 @@
+Archivist est un système de sauvegarde automatique pour votre serveur.  
+Il est capable de faire des sauvegardes de votre noyau YunoHost et de vos applications en utilisant la commande de backup de YunoHost.  
+Il peut également faire des sauvegardes de répertoires spécifiques.  
+Vos sauvegardes peuvent être envoyées à de nombreux autres endroits, locaux ou distants.  
+Archivist est automatiquement lancé périodiquement pour mettre à jour vos sauvegardes et envoyer les modifications aux autres emplacements.

+ 10 - 0
doc/DISCLAIMER.md

@@ -0,0 +1,10 @@
+## Configuration
+
+The configuration of archivist can be changed in the file /opt/yunohost/archivist/Backup_list.conf  
+Please read the [documentation](https://github.com/maniackcrudelis/archivist/blob/master/Configuration.md) about the configuration of archivist for more informations.
+
+## Limitations
+
+* Encfs, which be used to encrypt the data, is not fully secured.  
+Have a look to the [security audit](https://defuse.ca/audits/encfs.htm) to have more informations.
+

+ 10 - 0
doc/DISCLAIMER_fr.md

@@ -0,0 +1,10 @@
+## Configuration
+
+La configuration d'archivist peut être modifiée dans le fichier /opt/yunohost/archivist/Backup_list.conf  
+Veuillez lire la [documentation](https://github.com/maniackcrudelis/archivist/blob/master/Configuration_fr.md) sur la configuration d'archivist pour plus d'informations.
+
+## Limitations
+
+* Encfs, qui est utilisé pour chiffrer les données, n'est pas parfaitement sécurisé.  
+Consultez l'[audit de sécurité](https://defuse.ca/audits/encfs.htm) pour avoir plus d'informations.
+

+ 0 - 0
doc/screenshots/.gitkeep


+ 7 - 2
manifest.json

@@ -6,8 +6,13 @@
         "en": "Automatic backups",
         "fr": "Sauvegardes automatiques"
     },
-    "version": "1.3.1~ynh2",
+    "version": "1.3.2~ynh2",
     "url": "https://github.com/maniackcrudelis/archivist",
+    "upstream": {
+        "license": "GPL-3.0",
+        "website": "https://github.com/maniackcrudelis/archivist",
+        "code": "https://github.com/maniackcrudelis/archivist"
+    },
     "license": "GPL-3.0",
     "maintainer": {
         "name": "",
@@ -23,7 +28,7 @@
     "multi_instance": true,
     "services": [],
     "arguments": {
-        "install" : [
+        "install": [
             {
                 "name": "encrypt",
                 "type": "boolean",

+ 134 - 130
scripts/_common.sh

@@ -4,8 +4,12 @@
 # COMMON VARIABLES
 #=================================================
 
-# Dependencies
-app_depencencies="rsync encfs sshpass ccrypt lzop zstd lzip"
+# dependencies used by the app
+pkg_dependencies="rsync encfs sshpass ccrypt lzop zstd lzip"
+
+#=================================================
+# PERSONAL HELPERS
+#=================================================
 
 #=================================================
 # EXPERIMENTAL HELPERS
@@ -99,8 +103,8 @@ __PRE_TAG1__$(yunohost tools diagnosis | grep -B 100 "services:" | sed '/service
 	echo "$mail_message" > mail_to_send
 
 	# If a html email is required. Apply html tags to the message.
- 	if [ "$admin_mail_html" -eq 1 ]
- 	then
+	if [ "$admin_mail_html" -eq 1 ]
+	then
 		# Insert 'br' tags at each ending of lines.
 		ynh_replace_string "$" "<br>" mail_to_send
 
@@ -199,7 +203,7 @@ include conf.d/yunohost_panel.conf.inc;
 
 	# The current config file will redirect all requests to the root of the app.
 	# To keep the full path, we can use the following rewrite rule:
-	# 	rewrite ^${path_url}/(.*)$ ${path_url}_maintenance/\$1? redirect;
+	# rewrite ^${path_url}/(.*)$ ${path_url}_maintenance/\$1? redirect;
 	# The difference will be in the $1 at the end, which keep the following queries.
 	# But, if it works perfectly for a html request, there's an issue with any php files.
 	# This files are treated as simple files, and will be downloaded by the browser.
@@ -237,134 +241,134 @@ ynh_maintenance_mode_OFF () {
 #
 # usage: ynh_app_changelog [--format=markdown/html/plain] [--output=changelog_file] --changelog=changelog_source]
 # | arg: -f --format= - Format in which the changelog will be printed
-#       markdown: Default format.
-#       html:     Turn urls into html format.
-#       plain:    Plain text changelog
+#	   markdown: Default format.
+#	   html:	 Turn urls into html format.
+#	   plain:	Plain text changelog
 # | arg: -o --output= - Output file for the changelog file (Default ./changelog)
 # | arg: -c --changelog= - CHANGELOG.md source (Default ../CHANGELOG.md)
 #
 # The changelog is printed into the file ./changelog and ./changelog_lite
 ynh_app_changelog () {
-    # Declare an array to define the options of this helper.
-    local legacy_args=foc
-    declare -Ar args_array=( [f]=format= [o]=output= [c]=changelog= )
-    local format
-    local output
-    local changelog
-    # Manage arguments with getopts
-    ynh_handle_getopts_args "$@"
-    format=${format:-markdown}
-    output=${output:-changelog}
-    changelog=${changelog:-../CHANGELOG.md}
-
-    local original_changelog="$changelog"
-    local temp_changelog="changelog_temp"
-    local final_changelog="$output"
-
-    if [ ! -n "$original_changelog" ]
-    then
-        echo "No changelog available..." > "$final_changelog"
-        echo "No changelog available..." > "${final_changelog}_lite"
-        return 0
-    fi
-
-    local current_version=$(ynh_read_manifest --manifest="/etc/yunohost/apps/$YNH_APP_INSTANCE_NAME/manifest.json" --manifest_key="version")
-    local update_version=$(ynh_read_manifest --manifest="../manifest.json" --manifest_key="version")
-
-    # Get the line of the version to update to into the changelog
-    local update_version_line=$(grep --max-count=1 --line-number "^## \[$update_version" "$original_changelog" | cut -d':' -f1)
-    # If there's no entry for this version yet into the changelog
-    # Get the first available version
-    if [ -z "$update_version_line" ]
-    then
-        update_version_line=$(grep --max-count=1 --line-number "^##" "$original_changelog" | cut -d':' -f1)
-    fi
-
-    # Get the length of the complete changelog.
-    local changelog_length=$(wc --lines "$original_changelog" | awk '{print $1}')
-    # Cut the file before the version to update to.
-    tail --lines=$(( $changelog_length - $update_version_line + 1 )) "$original_changelog" > "$temp_changelog"
-
-    # Get the length of the troncated changelog.
-    changelog_length=$(wc --lines "$temp_changelog" | awk '{print $1}')
-    # Get the line of the current version into the changelog
-    # Keep only the last line found
-    local current_version_line=$(grep --line-number "^## \[$current_version" "$temp_changelog" | cut -d':' -f1 | tail --lines=1)
-    # If there's no entry for this version into the changelog
-    # Get the last available version
-    if [ -z "$current_version_line" ]
-    then
-        current_version_line=$(grep --line-number "^##" "$original_changelog" | cut -d':' -f1 | tail --lines=1)
-    fi
-    # Cut the file before the current version.
-    # Then grep the previous version into the changelog to get the line number of the previous version
-    local previous_version_line=$(tail --lines=$(( $changelog_length - $current_version_line )) \
-        "$temp_changelog" | grep --max-count=1 --line-number "^## " | cut -d':' -f1)
-    # If there's no previous version into the changelog
-    # Go until the end of the changelog
-    if [ -z "$previous_version_line" ]
-    then
-        previous_version_line=$changelog_length
-    fi
-
-    # Cut the file after the previous version to keep only the changelog between the current version and the version to update to.
-    head --lines=$(( $current_version_line + $previous_version_line - 1 )) "$temp_changelog" | tee "$final_changelog"
-
-    if [ "$format" = "html" ]
-    then
-        # Replace markdown links by html links
-        ynh_replace_string --match_string="\[\(.*\)\](\(.*\)))" --replace_string="<a href=\"\2\">\1</a>)" --target_file="$final_changelog"
-        ynh_replace_string --match_string="\[\(.*\)\](\(.*\))" --replace_string="<a href=\"\2\">\1</a>" --target_file="$final_changelog"
-    elif [ "$format" = "plain" ]
-    then
-        # Change title format.
-        ynh_replace_string --match_string="^##.*\[\(.*\)\](\(.*\)) - \(.*\)$" --replace_string="## \1 (\3) - \2" --target_file="$final_changelog"
-        # Change modifications lines format.
-        ynh_replace_string --match_string="^\([-*]\).*\[\(.*\)\]\(.*\)" --replace_string="\1 \2 \3" --target_file="$final_changelog"
-    fi
-    # else markdown. As the file is already in markdown, nothing to do.
-
-    # Keep only important changes into the changelog
-    # Remove all minor changes
-    sed '/^-/d' "$final_changelog" > "${final_changelog}_lite"
-    # Remove all blank lines (to keep a clear workspace)
-    sed --in-place '/^$/d' "${final_changelog}_lite"
-    # Add a blank line at the end
-    echo "" >> "${final_changelog}_lite"
-
-    # Clean titles if there's no significative changes
-    local line
-    local previous_line=""
-    while read line <&3
-    do
-        if [ -n "$previous_line" ]
-        then
-            # Remove the line if it's a title or a blank line, and the previous one was a title as well.
-            if ( [ "${line:0:1}" = "#" ] || [ ${#line} -eq 0 ] ) && [ "${previous_line:0:1}" = "#" ]
-            then
-                ynh_replace_special_string --match_string="${previous_line//[/.}" --replace_string="" --target_file="${final_changelog}_lite"
-            fi
-        fi
-        previous_line="$line"
-    done 3< "${final_changelog}_lite"
-
-    # Remove all blank lines again
-    sed --in-place '/^$/d' "${final_changelog}_lite"
-
-    # Restore changelog format with blank lines
-    ynh_replace_string --match_string="^##.*" --replace_string="\n\n&\n" --target_file="${final_changelog}_lite"
-    # Remove the 2 first blank lines
-    sed --in-place '1,2d' "${final_changelog}_lite"
-    # Add a blank line at the end
-    echo "" >> "${final_changelog}_lite"
-
-    # If changelog are empty, add an info
-    if [ $(wc --words "$final_changelog" | awk '{print $1}') -eq 0 ]
-    then
-        echo "No changes from the changelog..." > "$final_changelog"
-    fi
-    if [ $(wc --words "${final_changelog}_lite" | awk '{print $1}') -eq 0 ]
-    then
-        echo "No significative changes from the changelog..." > "${final_changelog}_lite"
-    fi
+	# Declare an array to define the options of this helper.
+	local legacy_args=foc
+	declare -Ar args_array=( [f]=format= [o]=output= [c]=changelog= )
+	local format
+	local output
+	local changelog
+	# Manage arguments with getopts
+	ynh_handle_getopts_args "$@"
+	format=${format:-markdown}
+	output=${output:-changelog}
+	changelog=${changelog:-../CHANGELOG.md}
+
+	local original_changelog="$changelog"
+	local temp_changelog="changelog_temp"
+	local final_changelog="$output"
+
+	if [ ! -n "$original_changelog" ]
+	then
+		echo "No changelog available..." > "$final_changelog"
+		echo "No changelog available..." > "${final_changelog}_lite"
+		return 0
+	fi
+
+	local current_version=$(ynh_read_manifest --manifest="/etc/yunohost/apps/$YNH_APP_INSTANCE_NAME/manifest.json" --manifest_key="version")
+	local update_version=$(ynh_read_manifest --manifest="../manifest.json" --manifest_key="version")
+
+	# Get the line of the version to update to into the changelog
+	local update_version_line=$(grep --max-count=1 --line-number "^## \[$update_version" "$original_changelog" | cut -d':' -f1)
+	# If there's no entry for this version yet into the changelog
+	# Get the first available version
+	if [ -z "$update_version_line" ]
+	then
+		update_version_line=$(grep --max-count=1 --line-number "^##" "$original_changelog" | cut -d':' -f1)
+	fi
+
+	# Get the length of the complete changelog.
+	local changelog_length=$(wc --lines "$original_changelog" | awk '{print $1}')
+	# Cut the file before the version to update to.
+	tail --lines=$(( $changelog_length - $update_version_line + 1 )) "$original_changelog" > "$temp_changelog"
+
+	# Get the length of the troncated changelog.
+	changelog_length=$(wc --lines "$temp_changelog" | awk '{print $1}')
+	# Get the line of the current version into the changelog
+	# Keep only the last line found
+	local current_version_line=$(grep --line-number "^## \[$current_version" "$temp_changelog" | cut -d':' -f1 | tail --lines=1)
+	# If there's no entry for this version into the changelog
+	# Get the last available version
+	if [ -z "$current_version_line" ]
+	then
+		current_version_line=$(grep --line-number "^##" "$original_changelog" | cut -d':' -f1 | tail --lines=1)
+	fi
+	# Cut the file before the current version.
+	# Then grep the previous version into the changelog to get the line number of the previous version
+	local previous_version_line=$(tail --lines=$(( $changelog_length - $current_version_line )) \
+		"$temp_changelog" | grep --max-count=1 --line-number "^## " | cut -d':' -f1)
+	# If there's no previous version into the changelog
+	# Go until the end of the changelog
+	if [ -z "$previous_version_line" ]
+	then
+		previous_version_line=$changelog_length
+	fi
+
+	# Cut the file after the previous version to keep only the changelog between the current version and the version to update to.
+	head --lines=$(( $current_version_line + $previous_version_line - 1 )) "$temp_changelog" | tee "$final_changelog"
+
+	if [ "$format" = "html" ]
+	then
+		# Replace markdown links by html links
+		ynh_replace_string --match_string="\[\(.*\)\](\(.*\)))" --replace_string="<a href=\"\2\">\1</a>)" --target_file="$final_changelog"
+		ynh_replace_string --match_string="\[\(.*\)\](\(.*\))" --replace_string="<a href=\"\2\">\1</a>" --target_file="$final_changelog"
+	elif [ "$format" = "plain" ]
+	then
+		# Change title format.
+		ynh_replace_string --match_string="^##.*\[\(.*\)\](\(.*\)) - \(.*\)$" --replace_string="## \1 (\3) - \2" --target_file="$final_changelog"
+		# Change modifications lines format.
+		ynh_replace_string --match_string="^\([-*]\).*\[\(.*\)\]\(.*\)" --replace_string="\1 \2 \3" --target_file="$final_changelog"
+	fi
+	# else markdown. As the file is already in markdown, nothing to do.
+
+	# Keep only important changes into the changelog
+	# Remove all minor changes
+	sed '/^-/d' "$final_changelog" > "${final_changelog}_lite"
+	# Remove all blank lines (to keep a clear workspace)
+	sed --in-place '/^$/d' "${final_changelog}_lite"
+	# Add a blank line at the end
+	echo "" >> "${final_changelog}_lite"
+
+	# Clean titles if there's no significative changes
+	local line
+	local previous_line=""
+	while read line <&3
+	do
+		if [ -n "$previous_line" ]
+		then
+			# Remove the line if it's a title or a blank line, and the previous one was a title as well.
+			if ( [ "${line:0:1}" = "#" ] || [ ${#line} -eq 0 ] ) && [ "${previous_line:0:1}" = "#" ]
+			then
+				ynh_replace_special_string --match_string="${previous_line//[/.}" --replace_string="" --target_file="${final_changelog}_lite"
+			fi
+		fi
+		previous_line="$line"
+	done 3< "${final_changelog}_lite"
+
+	# Remove all blank lines again
+	sed --in-place '/^$/d' "${final_changelog}_lite"
+
+	# Restore changelog format with blank lines
+	ynh_replace_string --match_string="^##.*" --replace_string="\n\n&\n" --target_file="${final_changelog}_lite"
+	# Remove the 2 first blank lines
+	sed --in-place '1,2d' "${final_changelog}_lite"
+	# Add a blank line at the end
+	echo "" >> "${final_changelog}_lite"
+
+	# If changelog are empty, add an info
+	if [ $(wc --words "$final_changelog" | awk '{print $1}') -eq 0 ]
+	then
+		echo "No changes from the changelog..." > "$final_changelog"
+	fi
+	if [ $(wc --words "${final_changelog}_lite" | awk '{print $1}') -eq 0 ]
+	then
+		echo "No significative changes from the changelog..." > "${final_changelog}_lite"
+	fi
 }

+ 6 - 2
scripts/backup

@@ -6,6 +6,7 @@
 # IMPORT GENERIC 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
 
@@ -26,7 +27,10 @@ app=$YNH_APP_INSTANCE_NAME
 final_path=$(ynh_app_setting_get --app=$app --key=final_path)
 
 #=================================================
-# STANDARD BACKUP STEPS
+# DECLARE DATA AND CONF FILES TO BACKUP
+#=================================================
+ynh_print_info --message="Declaring files to be backed up..."
+
 #=================================================
 # BACKUP THE APP MAIN DIR
 #=================================================
@@ -42,7 +46,7 @@ ynh_backup --src_path="$final_path"
 ynh_backup --src_path="/etc/logrotate.d/$app"
 
 #=================================================
-# BACKUP THE CRON FILE
+# BACKUP VARIOUS FILES
 #=================================================
 
 ynh_backup --src_path="/etc/cron.d/$app"

+ 29 - 30
scripts/install

@@ -6,7 +6,6 @@
 # IMPORT GENERIC HELPERS
 #=================================================
 
-# Load common variables for all scripts.
 source _common.sh
 source /usr/share/yunohost/helpers
 
@@ -38,7 +37,7 @@ final_path=/opt/yunohost/$app
 test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
 
 if [ $encrypt -eq 1 ]; then
-    test -n "$encryption_pwd" || ynh_die --message="encryption_pwd can't be empty if you choose to enable encryption."
+	test -n "$encryption_pwd" || ynh_die --message="encryption_pwd can't be empty if you choose to enable encryption."
 fi
 
 #=================================================
@@ -65,7 +64,7 @@ ynh_script_progression --message="Installing dependencies..." --weight=15
 # To find this, install the package, install also debconf-utils
 # Then use `debconf-get-selections | grep package`
 echo "encfs encfs/security-information boolean true" | debconf-set-selections
-ynh_install_app_dependencies $app_depencencies
+ynh_install_app_dependencies $pkg_dependencies
 
 #=================================================
 # DOWNLOAD, CHECK AND UNPACK SOURCE
@@ -99,33 +98,33 @@ ynh_replace_string --match_string="^enc_backup_dir=.*" --replace_string="enc_bac
 
 if [ $encrypt -eq 1 ]
 then
-    encrypt=true
+	encrypt=true
 
-    passkey="$final_path/passkey"
-    echo "$encryption_pwd" > "$passkey"
-    chmod 400 "$passkey"
+	passkey="$final_path/passkey"
+	echo "$encryption_pwd" > "$passkey"
+	chmod 400 "$passkey"
 else
-    encrypt=false
-    passkey=na
+	encrypt=false
+	passkey=na
 fi
 ynh_replace_string --match_string="^encrypt=.*" --replace_string="encrypt=$encrypt" --target_file="$config_file"
 ynh_replace_string --match_string="^cryptpass=.*" --replace_string="cryptpass=$passkey" --target_file="$config_file"
 
 if [ $core_backup -eq 1 ]
 then
-    core_backup=true
+	core_backup=true
 else
-    core_backup=false
+	core_backup=false
 fi
 ynh_replace_string --match_string="^ynh_core_backup=.*" --replace_string="ynh_core_backup=$core_backup" --target_file="$config_file"
 
 if [ $apps_backup -eq 1 ]
 then
-    # Add all current applications to the backup
-    while read backup_app
-    do
-        ynh_replace_string --match_string="^ynh_app_backup=$" --replace_string="ynh_app_backup=$backup_app\n&" --target_file="$config_file"
-    done <<< "$(yunohost app list | grep 'id:' | sed 's/.*id: //')"
+	# Add all current applications to the backup
+	while read backup_app
+	do
+		ynh_replace_string --match_string="^ynh_app_backup=$" --replace_string="ynh_app_backup=$backup_app\n&" --target_file="$config_file"
+	done <<< "$(yunohost app list | grep 'id:' | sed 's/.*id: //')"
 fi
 
 # Calculate and store the config file checksum into the app settings
@@ -140,28 +139,26 @@ cp ../conf/cron /etc/cron.d/$app
 ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file=/etc/cron.d/$app
 ynh_replace_string --match_string="__APP__" --replace_string=$app --target_file=/etc/cron.d/$app
 if [ "$frequency" = "Daily" ]; then
-    cron_freq="0 2 * * *"
-    run_freq="every day"
+	cron_freq="0 2 * * *"
+	run_freq="every day"
 elif [ "$frequency" = "Each 3 days" ]; then
-    cron_freq="0 2 */3 * *"
-    run_freq="each 3 days"
+	cron_freq="0 2 */3 * *"
+	run_freq="each 3 days"
 elif [ "$frequency" = "Weekly" ]; then
-    cron_freq="0 2 * * 0"
-    run_freq="once a week on sunday"
+	cron_freq="0 2 * * 0"
+	run_freq="once a week on sunday"
 elif [ "$frequency" = "Biweekly" ]; then
-    cron_freq="0 2 * * 0/2"
-    run_freq="one sunday out of two"
+	cron_freq="0 2 * * 0/2"
+	run_freq="one sunday out of two"
 else	# Monthly
-    cron_freq="0 2 1 * *"
-    run_freq="once a month on the first sunday"
+	cron_freq="0 2 1 * *"
+	run_freq="once a month on the first sunday"
 fi
 ynh_replace_string --match_string="__FREQUENCY__" --replace_string="$cron_freq" --target_file=/etc/cron.d/$app
 
 # Calculate and store the config file checksum into the app settings
 ynh_store_file_checksum --file="/etc/cron.d/$app"
 
-#=================================================
-# GENERIC FINALIZATION
 #=================================================
 # SECURE FILES AND DIRECTORIES
 #=================================================
@@ -169,6 +166,8 @@ ynh_store_file_checksum --file="/etc/cron.d/$app"
 # Set permissions to app files
 chown -R root: $final_path
 
+#=================================================
+# GENERIC FINALIZATION
 #=================================================
 # SETUP LOGROTATE
 #=================================================
@@ -193,12 +192,12 @@ ynh_print_info --message="$Informations"
 
 if [ "$encrypt" = "true" ]
 then
-    encrypt_message="Your password for encryption is '$encryption_pwd'
+	encrypt_message="Your password for encryption is '$encryption_pwd'
 
 "
 
 else
-    encrypt_message=""
+	encrypt_message=""
 fi
 
 # Get main domain and buid the url of the admin panel of the app.

+ 10 - 9
scripts/remove

@@ -21,12 +21,12 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path)
 #=================================================
 # STANDARD REMOVE
 #=================================================
-# REMOVE DEPENDENCIES
+# REMOVE LOGROTATE CONFIGURATION
 #=================================================
-ynh_script_progression --message="Removing dependencies..." --weight=7
+ynh_script_progression --message="Removing logrotate configuration..."
 
-# Remove metapackage and its dependencies
-ynh_remove_app_dependencies
+# Remove the app-specific logrotate config
+ynh_remove_logrotate
 
 #=================================================
 # REMOVE APP MAIN DIR
@@ -37,18 +37,19 @@ ynh_script_progression --message="Removing app main directory..."
 ynh_secure_remove --file="$final_path"
 
 #=================================================
-# REMOVE LOGROTATE CONFIGURATION
+# REMOVE DEPENDENCIES
 #=================================================
-ynh_script_progression --message="Removing logrotate configuration..."
+ynh_script_progression --message="Removing dependencies..." --weight=7
 
-# Remove the app-specific logrotate config
-ynh_remove_logrotate
+# Remove metapackage and its dependencies
+ynh_remove_app_dependencies
 
 #=================================================
 # SPECIFIC REMOVE
 #=================================================
-# REMOVE THE CRON FILE
+# REMOVE VARIOUS FILES
 #=================================================
+ynh_script_progression --message="Removing various files..."
 
 # Remove a cron file
 ynh_secure_remove --file="/etc/cron.d/$app"

+ 13 - 14
scripts/restore

@@ -6,7 +6,7 @@
 # IMPORT GENERIC HELPERS
 #=================================================
 
-# Load common variables for all scripts.
+# 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
 
@@ -20,7 +20,7 @@ ynh_abort_if_errors
 #=================================================
 # LOAD SETTINGS
 #=================================================
-ynh_script_progression --message="Loading settings..."
+ynh_script_progression --message="Loading installation settings..."
 
 app=$YNH_APP_INSTANCE_NAME
 
@@ -31,7 +31,8 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path)
 #=================================================
 ynh_script_progression --message="Validating restoration parameters..."
 
-test ! -d $final_path || ynh_die --message="There is already a directory: $final_path "
+test ! -d $final_path \
+	|| ynh_die --message="There is already a directory: $final_path "
 
 #=================================================
 # STANDARD RESTORATION STEPS
@@ -53,26 +54,24 @@ ynh_script_progression --message="Reinstalling dependencies..." --weight=17
 # To find this, install the package, install also debconf-utils
 # Then use `debconf-get-selections | grep package`
 echo "encfs encfs/security-information boolean true" | debconf-set-selections
-ynh_install_app_dependencies $app_depencencies
+ynh_install_app_dependencies $pkg_dependencies
 
 #=================================================
-# RESTORE THE LOGROTATE CONFIGURATION
-#=================================================
-
-mkdir -p /var/log/$app
-ynh_restore_file --origin_path="/etc/logrotate.d/$app"
-
-#=================================================
-# RESTORE THE CRON FILE
+# RESTORE VARIOUS FILES
 #=================================================
+ynh_script_progression --message="Restoring various files..."
 
 ynh_restore_file --origin_path="/etc/cron.d/$app"
 
+mkdir -p "/home/yunohost.app/${app}/backup"
+
 #=================================================
-# RECREATE DIRECTORIES
+# RESTORE THE LOGROTATE CONFIGURATION
 #=================================================
+ynh_script_progression --message="Restoring the logrotate configuration..."
 
-mkdir -p "/home/yunohost.app/${app}/backup"
+mkdir -p /var/log/$app
+ynh_restore_file --origin_path="/etc/logrotate.d/$app"
 
 #=================================================
 # SEND A README FOR THE ADMIN

+ 58 - 57
scripts/upgrade

@@ -6,7 +6,6 @@
 # IMPORT GENERIC HELPERS
 #=================================================
 
-# Load common variables for all scripts.
 source _common.sh
 source /usr/share/yunohost/helpers
 
@@ -27,6 +26,7 @@ overwrite_cron=$(ynh_app_setting_get --app=$app --key=overwrite_cron)
 #=================================================
 # CHECK VERSION
 #=================================================
+ynh_script_progression --message="Checking version..."
 
 upgrade_type=$(ynh_check_app_version_changed)
 
@@ -38,12 +38,14 @@ ynh_script_progression --message="Backing up the app before upgrading (may take
 # Backup the current version of the app
 ynh_backup_before_upgrade
 ynh_clean_setup () {
-    # restore it if the upgrade fails
-    ynh_restore_upgradebackup
+	# Restore it if the upgrade fails
+	ynh_restore_upgradebackup
 }
 # Exit if an error occurs during the execution of the script
 ynh_abort_if_errors
 
+#=================================================
+# STANDARD UPGRADE STEPS
 #=================================================
 # ENSURE DOWNWARD COMPATIBILITY
 #=================================================
@@ -51,51 +53,50 @@ ynh_script_progression --message="Ensuring downward compatibility..."
 
 # If encrypt doesn't exist, create it
 if [ -z "$encrypt" ]; then
-    encrypt="$(grep "^encrypt=" "$final_path/Backup_list.conf" | cut -d= -f2)"
-    if [ "$encrypt" = true ]; then
-        encrypt=1
-    else
-        encrypt=0
-    fi
-    ynh_app_setting_set --app=$app --key=encrypt --value=$encrypt
+	encrypt="$(grep "^encrypt=" "$final_path/Backup_list.conf" | cut -d= -f2)"
+	if [ "$encrypt" = true ]; then
+		encrypt=1
+	else
+		encrypt=0
+	fi
+	ynh_app_setting_set --app=$app --key=encrypt --value=$encrypt
 fi
 
 # If core_backup doesn't exist, create it
 if [ -z "$core_backup" ]; then
-    core_backup="$(grep "^ynh_core_backup=" "$final_path/Backup_list.conf" | cut -d= -f2)"
-    ynh_app_setting_set --app=$app --key=core_backup --value=$core_backup
+	core_backup="$(grep "^ynh_core_backup=" "$final_path/Backup_list.conf" | cut -d= -f2)"
+	ynh_app_setting_set --app=$app --key=core_backup --value=$core_backup
 fi
 
 # If apps_backup doesn't exist, create it
 if [ -z "$apps_backup" ]; then
-    apps_backup="$(grep --count --max-count=1 "^ynh_app_backup=" "$final_path/Backup_list.conf")"
-    ynh_app_setting_set --app=$app --key=apps_backup --value=$apps_backup
+	apps_backup="$(grep --count --max-count=1 "^ynh_app_backup=" "$final_path/Backup_list.conf")"
+	ynh_app_setting_set --app=$app --key=apps_backup --value=$apps_backup
 fi
 
 # If overwrite_cron doesn't exist, create it
 if [ -z "$overwrite_cron" ]; then
-    overwrite_cron=1
-    ynh_app_setting_set --app=$app --key=overwrite_cron --value=$overwrite_cron
+	overwrite_cron=1
+	ynh_app_setting_set --app=$app --key=overwrite_cron --value=$overwrite_cron
 fi
 
 admin_mail_html=$(ynh_app_setting_get --app=$app --key=admin_mail_html)
 # If admin_mail_html doesn't exist, create it
 if [ -z "$admin_mail_html" ]; then
-    admin_mail_html=1
-    ynh_app_setting_set --app=$app --key=admin_mail_html --value=$admin_mail_html
+	admin_mail_html=1
+	ynh_app_setting_set --app=$app --key=admin_mail_html --value=$admin_mail_html
 fi
 
-#=================================================
-# STANDARD UPGRADE STEPS
 #=================================================
 # DOWNLOAD, CHECK AND UNPACK SOURCE
 #=================================================
 
 if [ "$upgrade_type" == "UPGRADE_APP" ]
 then
-    ynh_script_progression --message="Upgrading source files..." --weight=2
-    # Download, check integrity, uncompress and patch the source from app.src
-    ynh_setup_source --dest_dir="$final_path"
+	ynh_script_progression --message="Upgrading source files..." --weight=2
+
+	# Download, check integrity, uncompress and patch the source from app.src
+	ynh_setup_source --dest_dir="$final_path"
 fi
 
 #=================================================
@@ -103,7 +104,7 @@ fi
 #=================================================
 ynh_script_progression --message="Upgrading dependencies..." --weight=8
 
-ynh_install_app_dependencies $app_depencencies
+ynh_install_app_dependencies $pkg_dependencies
 
 #=================================================
 # SPECIFIC UPGRADE
@@ -115,50 +116,50 @@ ynh_script_progression --message="Updating the cron file..."
 # Overwrite the cron file only if it's allowed
 if [ $overwrite_cron -eq 1 ]
 then
-    # Verify the checksum and backup the file if it's different
-    ynh_backup_if_checksum_is_different --file="/etc/cron.d/$app"
-
-    cp ../conf/cron /etc/cron.d/$app
-    ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file=/etc/cron.d/$app
-    ynh_replace_string --match_string="__APP__" --replace_string=$app --target_file=/etc/cron.d/$app
-    if [ "$frequency" = "Daily" ]; then
-        cron_freq="0 2 * * *"
-        run_freq="every day"
-    elif [ "$frequency" = "Each 3 days" ]; then
-        cron_freq="0 2 */3 * *"
-        run_freq="each 3 days"
-    elif [ "$frequency" = "Weekly" ]; then
-        cron_freq="0 2 * * 0"
-        run_freq="once a week on sunday"
-    elif [ "$frequency" = "Biweekly" ]; then
-        cron_freq="0 2 * * 0/2"
-        run_freq="one sunday out of two"
-    else	# Monthly
-        cron_freq="0 2 1 * *"
-        run_freq="once a month on the first sunday"
-    fi
-    ynh_replace_string --match_string="__FREQUENCY__" --replace_string="$cron_freq" --target_file=/etc/cron.d/$app
-
-    # Recalculate and store the config file checksum into the app settings
-    ynh_store_file_checksum --file="/etc/cron.d/$app"
+	# Verify the checksum and backup the file if it's different
+	ynh_backup_if_checksum_is_different --file="/etc/cron.d/$app"
+
+	cp ../conf/cron /etc/cron.d/$app
+	ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file=/etc/cron.d/$app
+	ynh_replace_string --match_string="__APP__" --replace_string=$app --target_file=/etc/cron.d/$app
+	if [ "$frequency" = "Daily" ]; then
+		cron_freq="0 2 * * *"
+		run_freq="every day"
+	elif [ "$frequency" = "Each 3 days" ]; then
+		cron_freq="0 2 */3 * *"
+		run_freq="each 3 days"
+	elif [ "$frequency" = "Weekly" ]; then
+		cron_freq="0 2 * * 0"
+		run_freq="once a week on sunday"
+	elif [ "$frequency" = "Biweekly" ]; then
+		cron_freq="0 2 * * 0/2"
+		run_freq="one sunday out of two"
+	else	# Monthly
+		cron_freq="0 2 1 * *"
+		run_freq="once a month on the first sunday"
+	fi
+	ynh_replace_string --match_string="__FREQUENCY__" --replace_string="$cron_freq" --target_file=/etc/cron.d/$app
+
+	# Recalculate and store the config file checksum into the app settings
+	ynh_store_file_checksum --file="/etc/cron.d/$app"
 fi
 
 #=================================================
-# SETUP LOGROTATE
+# SECURE FILES AND DIRECTORIES
 #=================================================
-ynh_script_progression --message="Upgrading logrotate configuration..."
 
-# Use logrotate to manage app-specific logfile(s)
-ynh_use_logrotate --non-append
+# Set permissions on app files
+chown -R root: $final_path
 
 #=================================================
 # GENERIC FINALIZATION
 #=================================================
-# SECURE FILES AND DIRECTORIES
+# SETUP LOGROTATE
 #=================================================
+ynh_script_progression --message="Upgrading logrotate configuration..."
 
-# Set permissions on app files
-chown -R root: $final_path
+# Use logrotate to manage app-specific logfile(s)
+ynh_use_logrotate --non-append
 
 #=================================================
 # SEND A README FOR THE ADMIN