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

Merge pull request #47 from YunoHost-Apps/testing

Apply example_ynh
This commit is contained in:
yalh76 2022-07-21 19:32:28 +02:00 committed by GitHub
commit 07069e7a5e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 366 additions and 347 deletions

View file

@ -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 # 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-) [![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.png)](https://install-app.yunohost.org/?app=archivist) [![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)* *[Lire ce readme en français.](./README_fr.md)*
> *This package allow you to install archivist quickly and simply on a YunoHost server. > *This package allows 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.* If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/install) to learn how to install it.*
## Overview ## Overview
Archivist is an automatic backup system for your server. 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 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. It can also makes backups of specified directories.
Your backups can be send to many other places, local or distant. 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. Archivist is automatically launched periodicaly to update your backups and send the modifications to the other places.
**Shipped version:** 1.3.2
## Screenshots
## Demo **Shipped version:** 1.3.2~ynh2
## Disclaimers / important information
No demo available.
## Configuration ## Configuration
The configuration of archivist can be changed in the file /opt/yunohost/archivist/Backup_list.conf 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. 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 ## Limitations
* Encfs, which be used to encrypt the data, is not fully secured. * 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. 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 ## Documentation and resources
* archivist website: https://github.com/maniackcrudelis/archivist
* YunoHost website: https://yunohost.org/
--- * 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. 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 or
sudo yunohost app upgrade archivist -u https://github.com/YunoHost-Apps/archivist_ynh/tree/testing --debug 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>

View file

@ -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 # 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-) [![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.png)](https://install-app.yunohost.org/?app=archivist) [![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)* *[Read this readme in english.](./README.md)*
> *Ce package vous permet d'installer archivist rapidement et simplement sur un serveur YunoHost. > *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.* 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. 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 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. Il peut également faire des sauvegardes de répertoires spécifiques.
Vos sauvegardes peuvent être envoyées à de nombreux autres endroits, locaux ou distants. 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. Archivist est automatiquement lancé périodiquement pour mettre à jour vos sauvegardes et envoyer les modifications aux autres emplacements.
**Version embarquée:** 1.3.2
## Captures d'écran **Version incluse :** 1.3.2~ynh2
## Avertissements / informations importantes
## Démo
Aucune démo pour cette application.
## Configuration ## Configuration
La configuration d'archivist peut être modifiée dans le fichier /opt/yunohost/archivist/Backup_list.conf 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. 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 ## Limitations
* Encfs, qui est utilisé pour chiffrer les données, n'est pas parfaitement sécurisé. * 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. Consultez l'[audit de sécurité](https://defuse.ca/audits/encfs.htm) pour avoir plus d'informations.
## Informations additionnelles
## Liens ## Documentations et ressources
* Reporter un bug: https://github.com/YunoHost-Apps/archivist_ynh/issues * Site officiel de l'app : <https://github.com/maniackcrudelis/archivist>
* Site de archivist: https://github.com/maniackcrudelis/archivist * Dépôt de code officiel de l'app : <https://github.com/maniackcrudelis/archivist>
* Site de YunoHost: https://yunohost.org/ * Documentation YunoHost pour cette app : <https://yunohost.org/app_archivist>
* Signaler un bug : <https://github.com/YunoHost-Apps/archivist_ynh/issues>
--- ## Informations pour les développeurs
Informations à l'intention des développeurs
----------------
Merci de faire vos pull request sur la [branche testing](https://github.com/YunoHost-Apps/archivist_ynh/tree/testing). 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. Pour essayer la branche testing, procédez comme suit.
```
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
ou ou
sudo yunohost app upgrade archivist -u https://github.com/YunoHost-Apps/archivist_ynh/tree/testing --debug 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>

View file

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

0
doc/.gitkeep Normal file
View file

6
doc/DESCRIPTION.md Normal file
View file

@ -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
doc/DESCRIPTION_fr.md Normal file
View file

@ -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
doc/DISCLAIMER.md Normal file
View file

@ -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
doc/DISCLAIMER_fr.md Normal file
View file

@ -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
doc/screenshots/.gitkeep Normal file
View file

View file

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

View file

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

View file

@ -6,6 +6,7 @@
# IMPORT GENERIC HELPERS # 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 ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers 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) 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 # BACKUP THE APP MAIN DIR
#================================================= #=================================================
@ -42,7 +46,7 @@ ynh_backup --src_path="$final_path"
ynh_backup --src_path="/etc/logrotate.d/$app" ynh_backup --src_path="/etc/logrotate.d/$app"
#================================================= #=================================================
# BACKUP THE CRON FILE # BACKUP VARIOUS FILES
#================================================= #=================================================
ynh_backup --src_path="/etc/cron.d/$app" ynh_backup --src_path="/etc/cron.d/$app"

View file

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

View file

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

View file

@ -6,7 +6,7 @@
# IMPORT GENERIC HELPERS # 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 ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
@ -20,7 +20,7 @@ ynh_abort_if_errors
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_script_progression --message="Loading settings..." ynh_script_progression --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME 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..." 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 # STANDARD RESTORATION STEPS
@ -53,27 +54,25 @@ ynh_script_progression --message="Reinstalling dependencies..." --weight=17
# To find this, install the package, install also debconf-utils # To find this, install the package, install also debconf-utils
# Then use `debconf-get-selections | grep package` # Then use `debconf-get-selections | grep package`
echo "encfs encfs/security-information boolean true" | debconf-set-selections echo "encfs encfs/security-information boolean true" | debconf-set-selections
ynh_install_app_dependencies $app_depencencies ynh_install_app_dependencies $pkg_dependencies
#=================================================
# 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"
#================================================= #=================================================
# RESTORE THE LOGROTATE CONFIGURATION # RESTORE THE LOGROTATE CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Restoring the logrotate configuration..."
mkdir -p /var/log/$app mkdir -p /var/log/$app
ynh_restore_file --origin_path="/etc/logrotate.d/$app" ynh_restore_file --origin_path="/etc/logrotate.d/$app"
#=================================================
# RESTORE THE CRON FILE
#=================================================
ynh_restore_file --origin_path="/etc/cron.d/$app"
#=================================================
# RECREATE DIRECTORIES
#=================================================
mkdir -p "/home/yunohost.app/${app}/backup"
#================================================= #=================================================
# SEND A README FOR THE ADMIN # SEND A README FOR THE ADMIN
#================================================= #=================================================

View file

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