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 #61 from YunoHost-Apps/manifestv2

Manifestv2
This commit is contained in:
Salamandar 2024-03-29 13:25:42 +01:00 committed by GitHub
commit 0eae2e1c69
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
26 changed files with 413 additions and 1153 deletions

6
ALL_README.md Normal file
View file

@ -0,0 +1,6 @@
# All available README files by language
- [Read the README in English](README.md)
- [Lire le README en français](README_fr.md)
- [Le o README en galego](README_gl.md)
- [Leggi il “README” in italiano](README_it.md)

View file

@ -1,5 +1,5 @@
<!--
N.B.: This README was automatically generated by https://github.com/YunoHost/apps/tree/master/tools/readme_generator
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.
-->
@ -9,10 +9,10 @@ It shall NOT be edited by hand.
[![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)*
*[Read this README is other languages.](./ALL_README.md)*
> *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.*
> *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
@ -24,36 +24,23 @@ Archivist is automatically launched periodicaly to update your backups and send
**Shipped version:** 1.3.4~ynh1
## 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.
## 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.
**Shipped version:** 1.3.4~ynh2
## Documentation and resources
* Upstream app code repository: <https://github.com/maniackcrudelis/archivist>
* YunoHost Store: <https://apps.yunohost.org/app/archivist>
* Report a bug: <https://github.com/YunoHost-Apps/archivist_ynh/issues>
- Upstream app code repository: <https://github.com/maniackcrudelis/archivist>
- YunoHost Store: <https://apps.yunohost.org/app/archivist>
- Report a bug: <https://github.com/YunoHost-Apps/archivist_ynh/issues>
## Developer info
Please send 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:
``` bash
```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>
**More info regarding app packaging:** <https://yunohost.org/packaging_apps>

View file

@ -1,6 +1,6 @@
<!--
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.
Nota bene: ce README est automatiquement généré par <https://github.com/YunoHost/apps/tree/master/tools/readme_generator>
Il NE doit PAS être modifié à la main.
-->
# Archivist pour YunoHost
@ -9,10 +9,10 @@ It shall NOT be edited by hand.
[![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)*
*[Lire le README dans d'autres langues.](./ALL_README.md)*
> *Ce package vous permet dinstaller Archivist rapidement et simplement sur un serveur YunoHost.
Si vous navez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour savoir comment linstaller et en profiter.*
> *Ce package vous permet dinstaller Archivist rapidement et simplement sur un serveur YunoHost.*
> *Si vous navez pas YunoHost, consultez [ce guide](https://yunohost.org/install) pour savoir comment linstaller et en profiter.*
## Vue densemble
@ -23,36 +23,23 @@ Vos sauvegardes peuvent être envoyées à de nombreux autres endroits, locaux o
Archivist est automatiquement lancé périodiquement pour mettre à jour vos sauvegardes et envoyer les modifications aux autres emplacements.
**Version incluse :** 1.3.4~ynh1
## 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.
## 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.
**Version incluse:** 1.3.4~ynh2
## Documentations et ressources
* Dépôt de code officiel de lapp : <https://github.com/maniackcrudelis/archivist>
* YunoHost Store: <https://apps.yunohost.org/app/archivist>
* Signaler un bug : <https://github.com/YunoHost-Apps/archivist_ynh/issues>
- Dépôt de code officiel de lapp: <https://github.com/maniackcrudelis/archivist>
- YunoHost Store: <https://apps.yunohost.org/app/archivist>
- Signaler un bug: <https://github.com/YunoHost-Apps/archivist_ynh/issues>
## Informations pour les 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 essayer la branche testing, procédez comme suit.
Pour essayer la branche `testing`, procédez comme suit:
``` bash
```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 dinfos sur le packaging dapplications :** <https://yunohost.org/packaging_apps>
**Plus dinfos sur le packaging dapplications:** <https://yunohost.org/packaging_apps>

46
README_gl.md Normal file
View file

@ -0,0 +1,46 @@
<!--
NOTA: Este README foi creado automáticamente por <https://github.com/YunoHost/apps/tree/master/tools/readme_generator>
NON debe editarse manualmente.
-->
# Archivist para YunoHost
[![Nivel de integración](https://dash.yunohost.org/integration/archivist.svg)](https://dash.yunohost.org/appci/app/archivist) ![Estado de funcionamento](https://ci-apps.yunohost.org/ci/badges/archivist.status.svg) ![Estado de mantemento](https://ci-apps.yunohost.org/ci/badges/archivist.maintain.svg)
[![Instalar Archivist con YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=archivist)
*[Le este README en outros idiomas.](./ALL_README.md)*
> *Este paquete permíteche instalar Archivist de xeito rápido e doado nun servidor YunoHost.*
> *Se non usas YunoHost, le a [documentación](https://yunohost.org/install) para saber como instalalo.*
## Vista xeral
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.
**Versión proporcionada:** 1.3.4~ynh2
## Documentación e recursos
- Repositorio de orixe do código: <https://github.com/maniackcrudelis/archivist>
- Tenda YunoHost: <https://apps.yunohost.org/app/archivist>
- Informar dun problema: <https://github.com/YunoHost-Apps/archivist_ynh/issues>
## Info de desenvolvemento
Envía a túa colaboración á [rama `testing`](https://github.com/YunoHost-Apps/archivist_ynh/tree/testing).
Para probar a rama `testing`, procede deste xeito:
```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
```
**Máis info sobre o empaquetado da app:** <https://yunohost.org/packaging_apps>

46
README_it.md Normal file
View file

@ -0,0 +1,46 @@
<!--
N.B.: Questo README è stato automaticamente generato da <https://github.com/YunoHost/apps/tree/master/tools/readme_generator>
NON DEVE essere modificato manualmente.
-->
# Archivist per YunoHost
[![Livello di integrazione](https://dash.yunohost.org/integration/archivist.svg)](https://dash.yunohost.org/appci/app/archivist) ![Stato di funzionamento](https://ci-apps.yunohost.org/ci/badges/archivist.status.svg) ![Stato di manutenzione](https://ci-apps.yunohost.org/ci/badges/archivist.maintain.svg)
[![Installa Archivist con YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=archivist)
*[Leggi questo README in altre lingue.](./ALL_README.md)*
> *Questo pacchetto ti permette di installare Archivist su un server YunoHost in modo semplice e veloce.*
> *Se non hai YunoHost, consulta [la guida](https://yunohost.org/install) per imparare a installarlo.*
## Panoramica
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.
**Versione pubblicata:** 1.3.4~ynh2
## Documentazione e risorse
- Repository upstream del codice dellapp: <https://github.com/maniackcrudelis/archivist>
- Store di YunoHost: <https://apps.yunohost.org/app/archivist>
- Segnala un problema: <https://github.com/YunoHost-Apps/archivist_ynh/issues>
## Informazioni per sviluppatori
Si prega di inviare la tua pull request alla [branch di `testing`](https://github.com/YunoHost-Apps/archivist_ynh/tree/testing).
Per provare la branch di `testing`, si prega di procedere in questo modo:
```bash
sudo yunohost app install https://github.com/YunoHost-Apps/archivist_ynh/tree/testing --debug
o
sudo yunohost app upgrade archivist -u https://github.com/YunoHost-Apps/archivist_ynh/tree/testing --debug
```
**Maggiori informazioni riguardo il pacchetto di questapp:** <https://yunohost.org/packaging_apps>

View file

@ -1,6 +1,6 @@
[force_backup]
name = "Create a new backup"
command = "/bin/bash scripts/actions/force_backup"
command = "scripts/actions/force_backup"
# user = "root" # optional
# cwd = "/" # optional
# accepted_return_codes = [0, 1, 2, 3] # optional
@ -9,7 +9,7 @@ description = "Run Archivist to create a new backup."
[clean_backups]
name = "Clean all previous backup files"
command = "/bin/bash scripts/actions/clean_backups"
command = "scripts/actions/clean_backups"
# user = "root" # optional
# cwd = "/" # optional
# accepted_return_codes = [0, 1, 2, 3] # optional
@ -18,7 +18,7 @@ description = "Remove all previous backup files made by Archivist."
[reset_default_config]
name = "Reset the config file and restore a default one."
command = "/bin/bash scripts/actions/reset_default_config \"Backup_list.conf\""
command = "scripts/actions/reset_default_config \"Backup_list.conf\""
# user = "root" # optional
# cwd = "/" # optional
# accepted_return_codes = [0, 1, 2, 3] # optional
@ -27,7 +27,7 @@ description = "Reset the config file Backup_list.conf."
[reset_default_app]
name = "Reset the app with a default configuration."
command = "/bin/bash scripts/actions/reset_default_app"
command = "scripts/actions/reset_default_app"
# user = "root" # optional
# cwd = "/" # optional
# accepted_return_codes = [0, 1, 2, 3] # optional

View file

@ -1,28 +0,0 @@
;; Test complet
; Manifest
encrypt=true
encryption_pwd="password"
core_backup=true
apps_backup=true
frequency="Weekly"
; 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
;;; 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"&

View file

@ -1,5 +0,0 @@
SOURCE_URL=https://github.com/maniackcrudelis/archivist/archive/refs/tags/v1.3.4.tar.gz
SOURCE_SUM=97df967d79ee2acd0bfae929a9feccea4df0f5943f14101a20a066470142fe89
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true

1
conf/archivist.cron Normal file
View file

@ -0,0 +1 @@
__FREQUENCY_CRON__ root nice -n10 __INSTALL_DIR__/archivist.sh | tee -a /var/log/__APP__/__APP__.log 2>&1

View file

@ -1 +0,0 @@
__FREQUENCY__ root nice -n10 __FINALPATH__/archivist.sh | tee -a /var/log/__APP__/__APP__.log 2>&1

View file

@ -7,4 +7,3 @@ Please read the [documentation](https://github.com/maniackcrudelis/archivist/blo
* 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.

14
doc/POST_INSTALL.md Normal file
View file

@ -0,0 +1,14 @@
If encryption is enabled, your password for encryption is '__ENCRYPTION_PWD__'
Archivist is going to run __FREQUENCY_HUMAN__.
If you want to change the frequency, have a look to the file `/etc/cron.d/__APP__`.
To add recipients or to modify the files or apps to backup,please have a look to the config file `__INSTALL_DIR__/Backup_list.conf`.
Please read the [documentation](https://github.com/maniackcrudelis/archivist/blob/master/Configuration.md) about the configuration of archivist for more information.
You can configure this app easily by using the experimental [config-panel feature](https://__DOMAIN__/yunohost/admin/#/apps/__APP__/config-panel).
You can also find some specific actions for this app by using the experimental [action feature](https://__DOMAIN__/yunohost/admin/#/apps/__APP__/actions).
If you're facing an issue or want to improve this app, please open a new issue in this [project](https://github.com/YunoHost-Apps/archivist_ynh).

View file

@ -1,83 +0,0 @@
{
"name": "Archivist",
"id": "archivist",
"packaging_format": 1,
"description": {
"en": "Automatic backups",
"fr": "Sauvegardes automatiques"
},
"version": "1.3.4~ynh1",
"url": "https://github.com/maniackcrudelis/archivist",
"upstream": {
"license": "GPL-3.0",
"code": "https://github.com/maniackcrudelis/archivist"
},
"license": "GPL-3.0",
"maintainer": {
"name": "",
"email": ""
},
"previous_maintainers": [{
"name": "Maniack Crudelis",
"email": "maniackc_dev@crudelis.fr"
}],
"requirements": {
"yunohost": ">= 11.2.9"
},
"multi_instance": true,
"services": [],
"arguments": {
"install": [
{
"name": "encrypt",
"type": "boolean",
"ask": {
"en": "Do you want to encrypt your backups?",
"fr": "Voulez-vous chiffrer vos sauvegardes ?"
},
"default": true
},
{
"name": "encryption_pwd",
"type": "password",
"ask": {
"en": "Set the password for encryption.",
"fr": "Définissez le mot de passe de chiffrement."
},
"help": {
"en": "It's needed if you use backup encryption.",
"fr": "C'est nécessaire si vous utilisez le chiffrement."
},
"optional": true
},
{
"name": "core_backup",
"type": "boolean",
"ask": {
"en": "Would you like to backup your YunoHost core?",
"fr": "Souhaitez-vous effectuer des sauvegardes du système YunoHost ?"
},
"default": true
},
{
"name": "apps_backup",
"type": "boolean",
"ask": {
"en": "Would you like to backup your apps?",
"fr": "Souhaitez-vous effectuer des sauvegardes de vos applications ?"
},
"default": true
},
{
"name": "frequency",
"type": "select",
"ask": {
"en": "Choose the frequency of your backups?",
"fr": "Choississez la fréquence de votre backup ?"
},
"choices" : ["Daily", "Each 3 days", "Weekly", "Biweekly", "Monthly"],
"default" : "Weekly"
}
]
}
}

91
manifest.toml Normal file
View file

@ -0,0 +1,91 @@
#:schema https://raw.githubusercontent.com/YunoHost/apps/master/schemas/manifest.v2.schema.json
packaging_format = 2
id = "archivist"
name = "Archivist"
description.en = "Automatic backups"
description.fr = "Sauvegardes automatiques"
version = "1.3.4~ynh2"
maintainers = []
[upstream]
license = "GPL-3.0"
code = "https://github.com/maniackcrudelis/archivist"
[integration]
yunohost = ">= 11.2.9"
architectures = "all"
multi_instance = true
ldap = "not_relevant"
sso = "not_relevant"
disk = "50M"
ram.build = "100M"
ram.runtime = "100M"
[install]
[install.encrypt]
ask.en = "Do you want to encrypt your backups?"
ask.fr = "Voulez-vous chiffrer vos sauvegardes ?"
type = "boolean"
default = true
[install.encryption_pwd]
ask.en = "Set the password for encryption."
ask.fr = "Définissez le mot de passe de chiffrement."
help.en = "It's needed if you use backup encryption."
help.fr = "C'est nécessaire si vous utilisez le chiffrement."
type = "password"
optional = true
[install.core_backup]
ask.en = "Would you like to backup your YunoHost core?"
ask.fr = "Souhaitez-vous effectuer des sauvegardes du système YunoHost ?"
type = "boolean"
default = true
[install.apps_backup]
ask.en = "Would you like to backup your apps?"
ask.fr = "Souhaitez-vous effectuer des sauvegardes de vos applications ?"
type = "boolean"
default = true
[install.frequency]
ask.en = "Choose the frequency of your backups?"
ask.fr = "Choississez la fréquence de votre backup ?"
type = "select"
choices.daily = "Daily"
choices.days_3 = "Each 3 days"
choices.weekly = "Weekly"
choices.weeks_2 = "Biweekly"
choices.monthly = "Monthly"
default = "weekly"
[resources]
[resources.sources.main]
url = "https://github.com/maniackcrudelis/archivist/archive/refs/tags/v1.3.4.tar.gz"
sha256 = "97df967d79ee2acd0bfae929a9feccea4df0f5943f14101a20a066470142fe89"
autoupdate.strategy = "latest_github_tag"
[resources.system_user]
[resources.install_dir]
[resources.data_dir]
subdirs = ["backup", "encrypted_backup"]
[resources.permissions]
[resources.apt]
packages = [
"rsync",
"encfs",
"sshpass",
"ccrypt",
"lzop",
"zstd",
"lzip",
]

View file

@ -4,371 +4,44 @@
# COMMON VARIABLES
#=================================================
# dependencies used by the app
pkg_dependencies="rsync encfs sshpass ccrypt lzop zstd lzip"
#=================================================
# PERSONAL HELPERS
#=================================================
_set_frequencies() {
case "$frequency" in
daily)
frequency_cron="0 2 * * *"
frequency_human="every day"
;;
days_3)
frequency_cron="0 2 */3 * *"
frequency_human="each 3 days"
;;
weekly)
frequency_cron="0 2 * * 0"
frequency_human="once a week on sunday"
;;
weeks_2)
frequency_cron="0 2 * * 0/2"
frequency_human="one sunday out of two"
;;
monthly)
frequency_cron="0 2 1 * *"
frequency_human="once a month on the first sunday"
;;
*)
ynh_die --message="Unsupported frequency $frequency" ;;
esac
# For POST_INSTALL.md
ynh_app_setting_set --app="$app" --key=frequency_human --value="$frequency_human"
}
#=================================================
# EXPERIMENTAL HELPERS
#=================================================
# Send an email to inform the administrator
#
# usage: ynh_send_readme_to_admin --app_message=app_message [--recipients=recipients] [--type=type]
# | arg: -m --app_message= - The file with the content to send to the administrator.
# | arg: -r, --recipients= - The recipients of this email. Use spaces to separate multiples recipients. - default: root
# example: "root admin@domain"
# If you give the name of a YunoHost user, ynh_send_readme_to_admin will find its email adress for you
# example: "root admin@domain user1 user2"
# | arg: -t, --type= - Type of mail, could be 'backup', 'change_url', 'install', 'remove', 'restore', 'upgrade'
ynh_send_readme_to_admin() {
# Declare an array to define the options of this helper.
declare -Ar args_array=( [m]=app_message= [r]=recipients= [t]=type= )
local app_message
local recipients
local type
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
app_message="${app_message:-}"
recipients="${recipients:-root}"
type="${type:-install}"
# Get the value of admin_mail_html
admin_mail_html=$(ynh_app_setting_get $app admin_mail_html)
admin_mail_html="${admin_mail_html:-0}"
# Retrieve the email of users
find_mails () {
local list_mails="$1"
local mail
local recipients=" "
# Read each mail in argument
for mail in $list_mails
do
# Keep root or a real email address as it is
if [ "$mail" = "root" ] || echo "$mail" | grep --quiet "@"
then
recipients="$recipients $mail"
else
# But replace an user name without a domain after by its email
if mail=$(ynh_user_get_info "$mail" "mail" 2> /dev/null)
then
recipients="$recipients $mail"
fi
fi
done
echo "$recipients"
}
recipients=$(find_mails "$recipients")
# Subject base
local mail_subject="☁️🆈🅽🅷☁️: \`$app\`"
# Adapt the subject according to the type of mail required.
if [ "$type" = "backup" ]; then
mail_subject="$mail_subject has just been backup."
elif [ "$type" = "change_url" ]; then
mail_subject="$mail_subject has just been moved to a new URL!"
elif [ "$type" = "remove" ]; then
mail_subject="$mail_subject has just been removed!"
elif [ "$type" = "restore" ]; then
mail_subject="$mail_subject has just been restored!"
elif [ "$type" = "upgrade" ]; then
mail_subject="$mail_subject has just been upgraded!"
else # install
mail_subject="$mail_subject has just been installed!"
fi
local mail_message="This is an automated message from your beloved YunoHost server.
Specific information for the application $app.
$(if [ -n "$app_message" ]
then
cat "$app_message"
else
echo "...No specific information..."
fi)
---
Automatic diagnosis data from YunoHost
__PRE_TAG1__$(yunohost tools diagnosis | grep -B 100 "services:" | sed '/services:/d')__PRE_TAG2__"
# Store the message into a file for further modifications.
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
# Insert 'br' tags at each ending of lines.
ynh_replace_string "$" "<br>" mail_to_send
# Insert starting HTML tags
sed --in-place '1s@^@<!DOCTYPE html>\n<html>\n<head></head>\n<body>\n@' mail_to_send
# Keep tabulations
ynh_replace_string " " "\&#160;\&#160;" mail_to_send
ynh_replace_string "\t" "\&#160;\&#160;" mail_to_send
# Insert url links tags
ynh_replace_string "__URL_TAG1__\(.*\)__URL_TAG2__\(.*\)__URL_TAG3__" "<a href=\"\2\">\1</a>" mail_to_send
# Insert pre tags
ynh_replace_string "__PRE_TAG1__" "<pre>" mail_to_send
ynh_replace_string "__PRE_TAG2__" "<\pre>" mail_to_send
# Insert finishing HTML tags
echo -e "\n</body>\n</html>" >> mail_to_send
# Otherwise, remove tags to keep a plain text.
else
# Remove URL tags
ynh_replace_string "__URL_TAG[1,3]__" "" mail_to_send
ynh_replace_string "__URL_TAG2__" ": " mail_to_send
# Remove PRE tags
ynh_replace_string "__PRE_TAG[1-2]__" "" mail_to_send
fi
# Define binary to use for mail command
if [ -e /usr/bin/bsd-mailx ]
then
local mail_bin=/usr/bin/bsd-mailx
else
local mail_bin=/usr/bin/mail.mailutils
fi
if [ "$admin_mail_html" -eq 1 ]
then
content_type="text/html"
else
content_type="text/plain"
fi
# Send the email to the recipients
cat mail_to_send | $mail_bin -a "Content-Type: $content_type; charset=UTF-8" -s "$mail_subject" "$recipients"
}
#=================================================
ynh_maintenance_mode_ON () {
# Load value of $path_url and $domain from the config if their not set
if [ -z $path_url ]; then
path_url=$(ynh_app_setting_get $app path)
fi
if [ -z $domain ]; then
domain=$(ynh_app_setting_get $app domain)
fi
mkdir -p /var/www/html/
# Create an html to serve as maintenance notice
echo "<!DOCTYPE html>
<html>
<head>
<meta http-equiv="refresh" content="3">
<title>Your app $app is currently under maintenance!</title>
<style>
body {
width: 70em;
margin: 0 auto;
}
</style>
</head>
<body>
<h1>Your app $app is currently under maintenance!</h1>
<p>This app has been put under maintenance by your administrator at $(date)</p>
<p>Please wait until the maintenance operation is done. This page will be reloaded as soon as your app will be back.</p>
</body>
</html>" > "/var/www/html/maintenance.$app.html"
# Create a new nginx config file to redirect all access to the app to the maintenance notice instead.
echo "# All request to the app will be redirected to ${path_url}_maintenance and fall on the maintenance notice
rewrite ^${path_url}/(.*)$ ${path_url}_maintenance/? redirect;
# Use another location, to not be in conflict with the original config file
location ${path_url}_maintenance/ {
alias /var/www/html/ ;
try_files maintenance.$app.html =503;
# Include SSOWAT user panel.
include conf.d/yunohost_panel.conf.inc;
}" > "/etc/nginx/conf.d/$domain.d/maintenance.$app.conf"
# 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;
# 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.
# Would be really be nice to be able to fix that issue. So that, when the page is reloaded after the maintenance, the user will be redirected to the real page he was.
systemctl reload nginx
}
ynh_maintenance_mode_OFF () {
# Load value of $path_url and $domain from the config if their not set
if [ -z $path_url ]; then
path_url=$(ynh_app_setting_get $app path)
fi
if [ -z $domain ]; then
domain=$(ynh_app_setting_get $app domain)
fi
# Rewrite the nginx config file to redirect from ${path_url}_maintenance to the real url of the app.
echo "rewrite ^${path_url}_maintenance/(.*)$ ${path_url}/\$1 redirect;" > "/etc/nginx/conf.d/$domain.d/maintenance.$app.conf"
systemctl reload nginx
# Sleep 4 seconds to let the browser reload the pages and redirect the user to the app.
sleep 4
# Then remove the temporary files used for the maintenance.
rm "/var/www/html/maintenance.$app.html"
rm "/etc/nginx/conf.d/$domain.d/maintenance.$app.conf"
systemctl reload nginx
}
# FUTURE OFFICIAL HELPERS
#=================================================
# Create a changelog for an app after an upgrade from the file CHANGELOG.md.
#
# 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
# | 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
}

View file

@ -1,7 +1,5 @@
#!/bin/bash
#=================================================
# GENERIC STARTING
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
@ -9,31 +7,6 @@
source scripts/_common.sh
source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# RETRIEVE ARGUMENTS
#=================================================
app=$YNH_APP_INSTANCE_NAME
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
#=================================================
# CHECK IF ARGUMENTS ARE CORRECT
#=================================================
#=================================================
# CHECK IF AN ACTION HAS TO BE DONE
#=================================================
#=================================================
# SPECIFIC ACTION
#=================================================
# CLEAN ALL BACKUP FILES
#=================================================
@ -42,10 +15,8 @@ ynh_script_progression --message="Cleaning all backup files..." --weight=9
# Get the backup directory from the config file
backup_dir="$(grep "^backup_dir=" "$final_path/Backup_list.conf" | cut -d= -f2)"
while read directory <&3
do
if [ -n "$directory" ]
then
while read -r directory <&3; do
if [ -n "$directory" ]; then
ynh_print_info --message="Clean backup directory $directory"
ynh_secure_remove --file="$directory"
fi

View file

@ -1,7 +1,5 @@
#!/bin/bash
#=================================================
# GENERIC STARTING
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
@ -9,37 +7,12 @@
source scripts/_common.sh
source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# RETRIEVE ARGUMENTS
#=================================================
app=$YNH_APP_INSTANCE_NAME
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
#=================================================
# CHECK IF ARGUMENTS ARE CORRECT
#=================================================
#=================================================
# CHECK IF AN ACTION HAS TO BE DONE
#=================================================
#=================================================
# SPECIFIC ACTION
#=================================================
# FORCE A NEW BACKUP
#=================================================
ynh_script_progression --message="Forcing a new backup..." --weight=9
ynh_exec_warn nice -n10 $final_path/archivist.sh
ynh_exec_warn nice -n10 "$install_dir/archivist.sh"
#=================================================
# END OF SCRIPT

View file

@ -1,7 +1,5 @@
#!/bin/bash
#=================================================
# GENERIC STARTING
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
@ -10,25 +8,7 @@
source scripts/_common.sh
source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
ynh_clean_setup () {
# Clean installation remaining that are not handle by the remove script.
ynh_clean_check_starting
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# RETRIEVE ARGUMENTS
#=================================================
app=$YNH_APP_INSTANCE_NAME
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
frequency="$(ynh_app_setting_get --app=$app --key=frequency)"
_set_frequencies
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
@ -37,68 +17,28 @@ frequency="$(ynh_app_setting_get --app=$app --key=frequency)"
ynh_script_progression --message="Resetting source files..." --time --weight=1
# Download, check integrity, uncompress and patch the source from app.src
(cd scripts; YNH_CWD=$PWD ynh_setup_source --dest_dir="$final_path")
(cd scripts; YNH_CWD=$PWD ynh_setup_source --dest_dir="$install_dir" --full_replace=1 --keep="passkey Backup_list.conf")
#=================================================
# RECREATE DIRECTORY
#=================================================
backup_dir="/home/yunohost.app/${app}/backup"
mkdir -p "$backup_dir"
#=================================================
# UPDATE THE CRON FILE
#=================================================
ynh_script_progression --message="Updating the cron file..."
# Verify the checksum and backup the file if it's different
ynh_backup_if_checksum_is_different --file="/etc/cron.d/$app"
(cd scripts; 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"
# Set permissions on app files
chown -R "root:root" "$install_dir"
#=================================================
# RECONFIGURE ARCHIVIST
#=================================================
ynh_script_progression --message="Reconfiguring archivist..." --time --weight=1
yunohost app action run $app reset_default_config
yunohost app action run "$app" reset_default_config
#=================================================
# SETUP LOGROTATE
# SYSTEM CONFIGURATION
#=================================================
ynh_script_progression --message="Resetting logrotate configuration..." --time --weight=1
ynh_script_progression --message="Resetting system configurations related to $app..." --weight=1
# Use logrotate to manage app-specific logfile(s)
ynh_use_logrotate --non-append
# Use logrotate to manage application logfile(s)
ynh_use_logrotate
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
# Set permissions on app files
chown -R root: $final_path
# Add Cron configuration file
ynh_add_config --template="archivist.cron" --destination="/etc/cron.d/$app"
#=================================================
# END OF SCRIPT

View file

@ -1,7 +1,5 @@
#!/bin/bash
#=================================================
# GENERIC STARTING
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
@ -9,24 +7,6 @@
source scripts/_common.sh
source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# RETRIEVE ARGUMENTS
#=================================================
app=$YNH_APP_INSTANCE_NAME
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
encrypt=$(ynh_app_setting_get --app=$app --key=encrypt)
core_backup=$(ynh_app_setting_get --app=$app --key=core_backup)
apps_backup=$(ynh_app_setting_get --app=$app --key=apps_backup)
#=================================================
# SORT OUT THE CONFIG FILE TO HANDLE
#=================================================
@ -34,11 +14,9 @@ apps_backup=$(ynh_app_setting_get --app=$app --key=apps_backup)
file="$1"
if [ "$file" = "Backup_list.conf" ]; then
config_file="$final_path/Backup_list.conf"
config_file="$install_dir/Backup_list.conf"
fi
#=================================================
# SPECIFIC ACTION
#=================================================
# RESET THE CONFIG FILE
#=================================================
@ -47,43 +25,39 @@ ynh_script_progression --message="Reseting the config file $file"
# Verify the checksum and backup the file if it's different
ynh_backup_if_checksum_is_different --file="$config_file"
if [ "$file" = "Backup_list.conf" ]
then
# Get the default file and overwrite the current config
cp "$final_path/Backup_list.conf.default" "$config_file"
# Recreate the default config
backup_dir="/home/yunohost.app/${app}/backup"
enc_backup_dir="/home/yunohost.app/${app}/encrypted_backup"
ynh_replace_string --match_string="^backup_dir=.*" --replace_string="backup_dir=$backup_dir" --target_file="$config_file"
ynh_replace_string --match_string="^enc_backup_dir=.*" --replace_string="enc_backup_dir=$enc_backup_dir" --target_file="$config_file"
if [ $encrypt -eq 1 ]
then
if [ "$file" = "Backup_list.conf" ]; then
if [ "$encrypt" -eq 1 ]; then
encrypt=true
passkey="$final_path/passkey"
passkey="$install_dir/passkey"
echo "$encryption_pwd" > "$passkey"
chmod 400 "$passkey"
else
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
if [ "$core_backup" -eq 1 ]; then
core_backup=true
else
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
config_file="$install_dir/Backup_list.conf"
cp "$install_dir/Backup_list.conf.default" "$config_file"
ynh_replace_string --target_file="$config_file" --match_string="^backup_dir=.*" --replace_string="backup_dir=$data_dir/backup"
ynh_replace_string --target_file="$config_file" --match_string="^enc_backup_dir=.*" --replace_string="enc_backup_dir=$data_dir/encrypted_backup"
ynh_replace_string --target_file="$config_file" --match_string="^encrypt=.*" --replace_string="encrypt=$encrypt"
ynh_replace_string --target_file="$config_file" --match_string="^cryptpass=.*" --replace_string="cryptpass=$passkey"
ynh_replace_string --target_file="$config_file" --match_string="^ynh_core_backup=.*" --replace_string="ynh_core_backup=$core_backup"
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 -i | grep id: | sed 's/.*id: //')"
while read -r backup_app; do
ynh_replace_string --target_file="$config_file" --match_string="^ynh_app_backup=$" --replace_string="ynh_app_backup=$backup_app\n&"
done <<< "$(yunohost app list | grep 'id:' | sed 's/.*id: //')"
fi
fi

View file

@ -1,7 +1,5 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
@ -10,22 +8,6 @@
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
ynh_print_info --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
#=================================================
# DECLARE DATA AND CONF FILES TO BACKUP
#=================================================
@ -35,21 +17,21 @@ ynh_print_info --message="Declaring files to be backed up..."
# BACKUP THE APP MAIN DIR
#=================================================
ynh_backup --src_path="$final_path"
ynh_backup --src_path="$install_dir"
#=================================================
# SPECIFIC BACKUP
#=================================================
# BACKUP LOGROTATE
# BACKUP SYSTEM
#=================================================
ynh_backup --src_path="/etc/logrotate.d/$app"
ynh_backup --src_path="/etc/cron.d/$app"
#=================================================
# BACKUP VARIOUS FILES
#=================================================
ynh_backup --src_path="/etc/cron.d/$app"
ynh_backup --src_path="/var/log/$app/"
#=================================================
# END OF SCRIPT

View file

@ -1,7 +1,5 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
@ -10,205 +8,83 @@ source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
# INITIALIZE AND STORE SETTINGS
#=================================================
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# RETRIEVE ARGUMENTS FROM THE MANIFEST
#=================================================
encrypt=$YNH_APP_ARG_ENCRYPT
encryption_pwd=$YNH_APP_ARG_ENCRYPTION_PWD
core_backup=$YNH_APP_ARG_CORE_BACKUP
apps_backup=$YNH_APP_ARG_APPS_BACKUP
frequency="$YNH_APP_ARG_FREQUENCY"
app=$YNH_APP_INSTANCE_NAME
#=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#=================================================
ynh_script_progression --message="Validating installation parameters..."
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."
if [ "$encrypt" -eq 1 ] && [ -z "$encryption_pwd" ]; then
ynh_die --message="encryption_pwd can't be empty if you choose to enable encryption."
fi
# Not saved as settings by default
ynh_app_setting_set --app="$app" --key="encryption_pwd" --value="$encryption_pwd"
#=================================================
# STORE SETTINGS FROM MANIFEST
#=================================================
ynh_script_progression --message="Storing installation settings..." --weight=3
_set_frequencies
ynh_app_setting_set --app=$app --key=frequency --value="$frequency"
ynh_app_setting_set --app=$app --key=encrypt --value="$encrypt"
ynh_app_setting_set --app=$app --key=core_backup --value="$core_backup"
ynh_app_setting_set --app=$app --key=apps_backup --value="$apps_backup"
ynh_app_setting_set --app=$app --key=overwrite_cron --value=1
ynh_app_setting_set --app=$app --key=admin_mail_html --value=1
#=================================================
# STANDARD MODIFICATIONS
#=================================================
# INSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Installing dependencies..." --weight=15
# Valid the fucking debconf message
# 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 $pkg_dependencies
ynh_app_setting_set --app="$app" --key=overwrite_cron --value=1
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_script_progression --message="Setting up source files..." --weight=3
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$final_path"
ynh_setup_source --dest_dir="$install_dir"
#=================================================
# SPECIFIC SETUP
#=================================================
# CREATE THE BACKUP DIRECTORY
#=================================================
chown -R "root:root" "$install_dir"
backup_dir="/home/yunohost.app/${app}/backup"
enc_backup_dir="/home/yunohost.app/${app}/encrypted_backup"
mkdir -p "$backup_dir"
chown -R "root:root" "$data_dir"
#=================================================
# CONFIGURE ARCHIVIST
#=================================================
ynh_script_progression --message="Configuring Archivist..." --weight=2
config_file="$final_path/Backup_list.conf"
cp "$final_path/Backup_list.conf.default" "$config_file"
ynh_replace_string --match_string="^backup_dir=.*" --replace_string="backup_dir=$backup_dir" --target_file="$config_file"
ynh_replace_string --match_string="^enc_backup_dir=.*" --replace_string="enc_backup_dir=$enc_backup_dir" --target_file="$config_file"
if [ $encrypt -eq 1 ]
then
encrypt=true
passkey="$final_path/passkey"
echo "$encryption_pwd" > "$passkey"
chmod 400 "$passkey"
if [ "$encrypt" -eq 1 ]; then
encrypt=true
passkey="$install_dir/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
if [ "$core_backup" -eq 1 ]; then
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: //')"
config_file="$install_dir/Backup_list.conf"
cp "$install_dir/Backup_list.conf.default" "$config_file"
ynh_replace_string --target_file="$config_file" --match_string="^backup_dir=.*" --replace_string="backup_dir=$data_dir/backup"
ynh_replace_string --target_file="$config_file" --match_string="^enc_backup_dir=.*" --replace_string="enc_backup_dir=$data_dir/encrypted_backup"
ynh_replace_string --target_file="$config_file" --match_string="^encrypt=.*" --replace_string="encrypt=$encrypt"
ynh_replace_string --target_file="$config_file" --match_string="^cryptpass=.*" --replace_string="cryptpass=$passkey"
ynh_replace_string --target_file="$config_file" --match_string="^ynh_core_backup=.*" --replace_string="ynh_core_backup=$core_backup"
if [ $apps_backup -eq 1 ]; then
# Add all current applications to the backup
while read -r backup_app; do
ynh_replace_string --target_file="$config_file" --match_string="^ynh_app_backup=$" --replace_string="ynh_app_backup=$backup_app\n&"
done <<< "$(yunohost app list | grep 'id:' | sed 's/.*id: //')"
fi
# Calculate and store the config file checksum into the app settings
ynh_store_file_checksum --file="$config_file"
#=================================================
# SET THE CRON FILE
# SYSTEM CONFIGURATION
#=================================================
ynh_script_progression --message="Configuring the cron file..."
ynh_script_progression --message="Adding system configurations related to $app..." --weight=1
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
# Calculate and store the config file checksum into the app settings
ynh_store_file_checksum --file="/etc/cron.d/$app"
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
# Set permissions to app files
chown -R root: $final_path
#=================================================
# GENERIC FINALIZATION
#=================================================
# SETUP LOGROTATE
#=================================================
ynh_script_progression --message="Configuring log rotation..."
mkdir -p /var/log/$app
# Use logrotate to manage application logfile(s)
ynh_use_logrotate
#=================================================
# PRINT INFORMATION
#=================================================
Informations="To add recipients or to modify the files or apps to backup,please have a look to the config file $config_file"
ynh_print_info --message="$Informations"
#=================================================
# SEND A README FOR THE ADMIN
#=================================================
if [ "$encrypt" = "true" ]
then
encrypt_message="Your password for encryption is '$encryption_pwd'"
else
encrypt_message=""
fi
# Get main domain and buid the url of the admin panel of the app.
admin_panel="https://$(grep portal_domain /etc/ssowat/conf.json | cut -d'"' -f4)/yunohost/admin/#/apps/$app"
echo "${encrypt_message}Archivist is going to run $run_freq.
If you want to change the frequency, have a look to the file /etc/cron.d/$app.
$Informations
Please read the __URL_TAG1__documentation__URL_TAG2__https://github.com/maniackcrudelis/archivist/blob/master/Configuration.md__URL_TAG3__ about the configuration of archivist for more information.
You can configure this app easily by using the experimental __URL_TAG1__config-panel feature__URL_TAG2__$admin_panel/config-panel__URL_TAG3__.
You can also find some specific actions for this app by using the experimental __URL_TAG1__action feature__URL_TAG2__$admin_panel/actions__URL_TAG3__.
If you're facing an issue or want to improve this app, please open a new issue in this __URL_TAG1__project__URL_TAG2__https://github.com/YunoHost-Apps/archivist_ynh__URL_TAG3__." > mail_to_send
ynh_send_readme_to_admin --app_message="mail_to_send" --recipients="root" --type=install
# Add Cron configuration file
ynh_add_config --template="archivist.cron" --destination="/etc/cron.d/$app"
#=================================================
# END OF SCRIPT

View file

@ -1,7 +1,5 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
@ -10,54 +8,17 @@ source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
# REMOVE SYSTEM CONFIGURATIONS
#=================================================
ynh_script_progression --message="Loading installation settings..." --weight=2
app=$YNH_APP_INSTANCE_NAME
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
#=================================================
# STANDARD REMOVE
#=================================================
# REMOVE LOGROTATE CONFIGURATION
#=================================================
ynh_script_progression --message="Removing logrotate configuration..."
ynh_script_progression --message="Removing system configurations related to $app..." --weight=1
# Remove the app-specific logrotate config
ynh_remove_logrotate
#=================================================
# REMOVE APP MAIN DIR
#=================================================
ynh_script_progression --message="Removing app main directory..."
# Remove the app directory securely
ynh_secure_remove --file="$final_path"
#=================================================
# REMOVE DEPENDENCIES
#=================================================
ynh_script_progression --message="Removing dependencies..." --weight=7
# Remove metapackage and its dependencies
ynh_remove_app_dependencies
#=================================================
# SPECIFIC REMOVE
#=================================================
# REMOVE VARIOUS FILES
#=================================================
ynh_script_progression --message="Removing various files..."
# Remove a cron file
ynh_secure_remove --file="/etc/cron.d/$app"
ynh_script_progression --message="Removing backup directory..." --weight=5
# Remove the backup directory
ynh_secure_remove --file="/home/yunohost.app/$app/backup"
ynh_secure_remove --file="/var/log/$app"
#=================================================
# END OF SCRIPT

View file

@ -1,7 +1,5 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
@ -10,87 +8,38 @@
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
#=================================================
# CHECK IF THE APP CAN BE RESTORED
#=================================================
ynh_script_progression --message="Validating restoration parameters..."
test ! -d $final_path \
|| ynh_die --message="There is already a directory: $final_path "
#=================================================
# STANDARD RESTORATION STEPS
#=================================================
# RESTORE THE APP MAIN DIR
#=================================================
ynh_script_progression --message="Restoring the app main directory..."
ynh_script_progression --message="Restoring the app main directory..." --weight=1
ynh_restore_file --origin_path="$final_path"
ynh_restore_file --origin_path="$install_dir"
chown -R "root:root" "$install_dir"
#=================================================
# SPECIFIC RESTORATION
# RESTORE THE DATA DIRECTORY
#=================================================
# REINSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Reinstalling dependencies..." --weight=17
ynh_script_progression --message="Restoring the data directory..." --weight=1
# Valid the fucking debconf message
# 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 $pkg_dependencies
ynh_restore_file --origin_path="$data_dir" --not_mandatory
chown -R "root:root" "$data_dir"
#=================================================
# RESTORE SYSTEM CONFIGURATIONS
#=================================================
ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
ynh_restore_file --origin_path="/etc/cron.d/$app"
#=================================================
# 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
#=================================================
ynh_script_progression --message="Restoring the logrotate configuration..."
mkdir -p /var/log/$app
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
#=================================================
# SEND A README FOR THE ADMIN
#=================================================
# Get main domain and buid the url of the admin panel of the app.
admin_panel="https://$(grep portal_domain /etc/ssowat/conf.json | cut -d'"' -f4)/yunohost/admin/#/apps/$app"
echo "If you want to change the frequency of Archivist, have a look to the file /etc/cron.d/$app.
The configuration file of Archivist has been restored at $final_path/Backup_list.conf
Please read the __URL_TAG1__documentation__URL_TAG2__https://github.com/maniackcrudelis/archivist/blob/master/Configuration.md__URL_TAG3__ about the configuration of archivist for more information.
You can configure this app easily by using the experimental __URL_TAG1__config-panel feature__URL_TAG2__$admin_panel/config-panel__URL_TAG3__.
You can also find some specific actions for this app by using the experimental __URL_TAG1__action feature__URL_TAG2__$admin_panel/actions__URL_TAG3__.
If you're facing an issue or want to improve this app, please open a new issue in this __URL_TAG1__project__URL_TAG2__https://github.com/YunoHost-Apps/archivist_ynh__URL_TAG3__." > mail_to_send
ynh_send_readme_to_admin --app_message="mail_to_send" --recipients="root" --type=restore
ynh_restore_file --origin_path="/var/log/$app/"
#=================================================
# END OF SCRIPT

View file

@ -1,7 +1,5 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
@ -9,184 +7,75 @@
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..." --weight=3
app=$YNH_APP_INSTANCE_NAME
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
frequency="$(ynh_app_setting_get --app=$app --key=frequency)"
encrypt=$(ynh_app_setting_get --app=$app --key=encrypt)
core_backup=$(ynh_app_setting_get --app=$app --key=core_backup)
apps_backup=$(ynh_app_setting_get --app=$app --key=apps_backup)
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)
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=2
# Backup the current version of the app
ynh_backup_before_upgrade
ynh_clean_setup () {
# Restore it if the upgrade fails
ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
ynh_script_progression --message="Ensuring downward compatibility..."
_set_frequencies
# 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
if [ -z "${encrypt:-}" ]; then
encrypt="$(grep "^encrypt=" "$install_dir/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
if [ -z "${core_backup:-}" ]; then
core_backup="$(grep "^ynh_core_backup=" "$install_dir/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
if [ -z "${apps_backup:-}" ]; then
apps_backup="$(grep --count --max-count=1 "^ynh_app_backup=" "$install_dir/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
if [ -z "${overwrite_cron:-}" ]; then
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
if [ -z "${admin_mail_html:-}" ]; then
admin_mail_html=1
ynh_app_setting_set --app="$app" --key="admin_mail_html" --value="$admin_mail_html"
fi
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_script_progression --message="Upgrading source files..." --weight=2
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="$install_dir" --full_replace=1 --keep="passkey Backup_list.conf"
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$final_path"
fi
chown -R "root:root" "$install_dir"
#=================================================
# UPGRADE DEPENDENCIES
# UPDATE A CONFIG FILE
#=================================================
ynh_script_progression --message="Upgrading dependencies..." --weight=8
ynh_install_app_dependencies $pkg_dependencies
ynh_script_progression --message="Updating $app's configuration files..." --weight=1
#=================================================
# SPECIFIC UPGRADE
# REAPPLY SYSTEM CONFIGURATIONS
#=================================================
# UPDATE THE CRON FILE
#=================================================
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"
fi
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
# Set permissions on app files
chown -R root: $final_path
#=================================================
# GENERIC FINALIZATION
#=================================================
# SETUP LOGROTATE
#=================================================
ynh_script_progression --message="Upgrading logrotate configuration..."
ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1
# Use logrotate to manage app-specific logfile(s)
ynh_use_logrotate --non-append
#=================================================
# SEND A README FOR THE ADMIN
#=================================================
# Get main domain and buid the url of the admin panel of the app.
admin_panel="https://$(grep portal_domain /etc/ssowat/conf.json | cut -d'"' -f4)/yunohost/admin/#/apps/$app"
# Build the changelog
ynh_app_changelog || true
echo "Archivist is going to run $run_freq.
If you want to change the frequency, have a look to the file /etc/cron.d/$app.
Please read the __URL_TAG1__documentation__URL_TAG2__https://github.com/maniackcrudelis/archivist/blob/master/Configuration.md__URL_TAG3__ about the configuration of archivist for more information.
You can configure this app easily by using the experimental __URL_TAG1__config-panel feature__URL_TAG2__$admin_panel/config-panel__URL_TAG3__.
You can also find some specific actions for this app by using the experimental __URL_TAG1__action feature__URL_TAG2__$admin_panel/actions__URL_TAG3__.
If you're facing an issue or want to improve this app, please open a new issue in this __URL_TAG1__project__URL_TAG2__https://github.com/YunoHost-Apps/archivist_ynh__URL_TAG3__.
---
Changelog since your last upgrade:
$(cat changelog)" > mail_to_send
ynh_send_readme_to_admin --app_message="mail_to_send" --recipients="root" --type=upgrade
if (( overwrite_cron == 1 )); then
# Add Cron configuration file
ynh_add_config --template="archivist.cron" --destination="/etc/cron.d/$app"
fi
#=================================================
# END OF SCRIPT

12
tests.toml Normal file
View file

@ -0,0 +1,12 @@
#:schema https://raw.githubusercontent.com/YunoHost/apps/master/schemas/tests.v1.schema.json
test_format = 1.0
[default]
args.encryption_pwd = "the_password"
args.frequency = "weekly"
test_upgrade_from.ce0ea695d4a4cff09b77bd2cb3438904012f7280.name = "Packaging v1"
test_upgrade_from.ce0ea695d4a4cff09b77bd2cb3438904012f7280.args.frequency = "Weekly"
test_upgrade_from.ce0ea695d4a4cff09b77bd2cb3438904012f7280.args.encryption_pwd = "the_password"