From 21b7e746095a9dccf9dda9a58cc8ec5afdd87736 Mon Sep 17 00:00:00 2001 From: maniack Date: Fri, 25 Oct 2019 18:29:31 +0200 Subject: [PATCH 1/3] Use toml for config-panel and actions --- actions.json | 33 ------------------- actions.toml | 26 +++++++++++++++ config_panel.json | 81 ----------------------------------------------- config_panel.toml | 65 +++++++++++++++++++++++++++++++++++++ scripts/config | 30 +++++++++++++++++- 5 files changed, 120 insertions(+), 115 deletions(-) delete mode 100644 actions.json create mode 100644 actions.toml delete mode 100644 config_panel.json create mode 100644 config_panel.toml diff --git a/actions.json b/actions.json deleted file mode 100644 index 991a94d..0000000 --- a/actions.json +++ /dev/null @@ -1,33 +0,0 @@ -[{ - "id": "force_backup", - "name": "Create a new backup", - "command": "/bin/bash scripts/actions/force_backup", - "user": "root", - "accepted_return_codes": [0], - "description": { - "en": "Run Archivist to create a new backup.", - "fr": "Lance Archivist pour créer un nouveau backup." - } -}, -{ - "id": "clean_backups", - "name": "Clean all previous backup files", - "command": "/bin/bash scripts/actions/clean_backups", - "user": "root", - "accepted_return_codes": [0], - "description": { - "en": "Remove all previous backup files made by Archivist.", - "fr": "Supprime tout les précédents backups créés par Archivist." - } -}, -{ - "id": "reset_default_config", - "name": "Reset the config file and restore a default one.", - "command": "/bin/bash scripts/actions/reset_default_config \"Backup_list.conf\"", - "user": "root", - "accepted_return_codes": [0], - "description": { - "en": "Reset the config file Backup_list.conf.", - "fr": "Réinitialise le fichier de configuration Backup_list.conf." - } -}] diff --git a/actions.toml b/actions.toml new file mode 100644 index 0000000..a7229a2 --- /dev/null +++ b/actions.toml @@ -0,0 +1,26 @@ +[force_backup] +name = "Create a new backup" +command = "/bin/bash scripts/actions/force_backup" +# user = "root" # optional +# cwd = "/" # optional +# accepted_return_codes = [0, 1, 2, 3] # optional +accepted_return_codes = [0] +description = "Run Archivist to create a new backup." + +[clean_backups] +name = "Clean all previous backup files" +command = "/bin/bash scripts/actions/clean_backups" +# user = "root" # optional +# cwd = "/" # optional +# accepted_return_codes = [0, 1, 2, 3] # optional +accepted_return_codes = [0] +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\"" +# user = "root" # optional +# cwd = "/" # optional +# accepted_return_codes = [0, 1, 2, 3] # optional +accepted_return_codes = [0] +description = "Reset the config file Backup_list.conf." diff --git a/config_panel.json b/config_panel.json deleted file mode 100644 index 4a7484e..0000000 --- a/config_panel.json +++ /dev/null @@ -1,81 +0,0 @@ -{ - "name": "Archivist configuration panel", - "version": "0.1", - "panel": [{ - "name": "Archivist configuration", - "id": "main", - "sections": [{ - "name": "Encryption", - "id": "encryption", - "options": [{ - "name": "Do you want to encrypt your backups ?", - "id": "encrypt", - "type": "bool", - "default": true - }, { - "name": "Set the password for encryption", - "help": "A password is needed if encryption is activated.", - "id": "encryption_pwd", - "type": "password", - "optional": true - }] - }, - { - "name": "Backup", - "id": "backup_types", - "options": [{ - "name": "Would you like to backup your YunoHost core ?", - "id": "core_backup", - "type": "bool", - "default": true - }, { - "name": "Would you like to backup your apps ?", - "help": "WARNING: Changing this value will either remove backup for all apps or add all current apps to the backup.", - "id": "apps_backup", - "type": "bool", - "default": true - }] - }, - { - "name": "Backup options", - "id": "backup_options", - "options": [{ - "name": "Choose the frequency of your backups ?", - "help": "We can't use a choices field for now. In the meantime please choose between one of this values:
Daily, Each 3 days, Weekly, Biweekly, Monthly.", - "id": "frequency", - "type": "text", - "//": "\"choices\" : [\"Daily\", \"Each 3 days\", \"Weekly\", \"Biweekly\", \"Monthly\"]", - "default" : "Weekly" - }, { - "name": "Max size for each backup in Mb", - "help": "Specify the max size of each backup for the following option file_to_backup.
This option is a soft limit, that means the script will try to limit each backup to this max size if it can.
But there's 2 limitations, for a single directory, it can't makes more than one backup file, even if the files in this directory exceed this maximum size.
And, if there's some files in a directory, next to subdirectories, it'll make only one backup for this files.
So this limit will be applied to split the backup by its subdirectories to avoid to have only one big backup.", - "id": "max_size", - "type": "number", - "default": 500 - }] - }, - { - "name": "Overwriting config files", - "id": "overwrite_files", - "options": [{ - "name": "Overwrite the cron file during the upgrade ?", - "help": "If the file is overwritten, a backup will be created.", - "id": "overwrite_cron", - "type": "bool", - "default": true - }] - }, - { - "name": "Global configuration", - "id": "global_config", - "options": [{ - "name": "Send HTML email to admin ?", - "help": "Allow app scripts to send HTML mails instead of plain text.", - "id": "email_type", - "type": "bool", - "default": true - }] - }] - } -] -} diff --git a/config_panel.toml b/config_panel.toml new file mode 100644 index 0000000..132417d --- /dev/null +++ b/config_panel.toml @@ -0,0 +1,65 @@ +version = "0.1" +name = "Archivist configuration panel" + +[main] +name = "Archivist configuration" + + [main.encryption] + name = "Encryption" + + [main.encryption.encrypt] + ask = "Do you want to encrypt your backups ?" + type = "boolean" + default = true + + [main.encryption.encryption_pwd] + ask = "Set the password for encryption" + type = "password" + optional = true + help = "A password is needed if encryption is activated." + + [main.backup_types] + name = "Backup" + + [main.backup_types.core_backup] + ask = "Would you like to backup your YunoHost core ?" + type = "boolean" + default = true + + [main.backup_types.apps_backup] + ask = "Would you like to backup your apps ?" + type = "boolean" + default = true + help = "WARNING: Changing this value will either remove backup for all apps or add all current apps to the backup." + + [main.backup_options] + name = "Backup options" + + [main.backup_options.frequency] + ask = "Choose the frequency of your backups ?" + choices = ["Daily", "Each 3 days", "Weekly", "Biweekly", "Monthly"] + default = "Weekly" + + [main.backup_options.max_size] + ask = "Max size for each backup in Mb" + type = "number" + default = 500 + help = "Specify the max size of each backup for the following option file_to_backup.
This option is a soft limit, that means the script will try to limit each backup to this max size if it can.
But there's 2 limitations, for a single directory, it can't makes more than one backup file, even if the files in this directory exceed this maximum size.
And, if there's some files in a directory, next to subdirectories, it'll make only one backup for this files.
So this limit will be applied to split the backup by its subdirectories to avoid to have only one big backup." + + [main.overwrite_files] + name = "Overwriting config files" + + [main.overwrite_files.overwrite_cron] + ask = "Overwrite the cron file during the upgrade ?" + type = "boolean" + default = true + help = "If the file is overwritten, a backup will be created." + + [main.global_config] + name = "Global configuration" + + [main.global_config.email_type] + ask = "Send HTML email to admin ?" + type = "boolean" + default = true + help = "Allow app scripts to send HTML mails instead of plain text." diff --git a/scripts/config b/scripts/config index c20d898..16f9e03 100644 --- a/scripts/config +++ b/scripts/config @@ -44,14 +44,17 @@ get_config_value() { # Encryption old_encrypt="$(get_config_value encrypt)" encrypt="${YNH_CONFIG_MAIN_ENCRYPTION_ENCRYPT:-$old_encrypt}" + # Encryption password ynh_print_OFF old_encrypt_password="$(cat $passkey)" encrypt_password="${YNH_CONFIG_MAIN_ENCRYPTION_ENCRYPTION_PWD:-$old_encrypt_password}" ynh_print_ON + # ynh_core_backup old_ynh_core_backup="$(get_config_value ynh_core_backup)" ynh_core_backup="${YNH_CONFIG_MAIN_BACKUP_TYPES_CORE_BACKUP:-$old_ynh_core_backup}" + # ynh_app_backup if [ -n "$(get_config_value ynh_app_backup)" ] then @@ -60,9 +63,11 @@ else old_ynh_app_backup="false" fi ynh_app_backup="${YNH_CONFIG_MAIN_BACKUP_TYPES_APPS_BACKUP:-$old_ynh_app_backup}" + # Frequency old_frequency="$(grep "^frequency: " "/etc/yunohost/apps/$app/settings.yml" | cut -d' ' -f2)" frequency="${YNH_CONFIG_MAIN_BACKUP_OPTIONS_FREQUENCY:-$old_frequency}" + # Max size old_max_size="$(get_config_value max_size)" max_size="${YNH_CONFIG_MAIN_BACKUP_OPTIONS_MAX_SIZE:-$old_max_size}" @@ -84,6 +89,7 @@ admin_mail_html="${YNH_CONFIG_MAIN_GLOBAL_CONFIG_EMAIL_TYPE:-$old_admin_mail_htm show_config() { # here you are supposed to read some config file/database/other then print the values # echo "YNH_CONFIG_${PANEL_ID}_${SECTION_ID}_${OPTION_ID}=value" + echo "YNH_CONFIG_MAIN_ENCRYPTION_ENCRYPT=$encrypt" echo "YNH_CONFIG_MAIN_ENCRYPTION_ENCRYPTION_PWD=" @@ -103,8 +109,14 @@ show_config() { #================================================= apply_config() { + + #================================================= + # MODIFY THE PASSWORD + #================================================= + # Change the password if needed - if [ "$encrypt" = "true" ]; then + if [ "$encrypt" = "true" ] + then ynh_print_OFF test -n "$encrypt_password" || ynh_die --message="The password for encryption can't be empty if you choose to enable encryption." ynh_print_ON @@ -115,9 +127,17 @@ apply_config() { ynh_replace_string --match_string="^cryptpass=.*" --replace_string="cryptpass=$passkey" --target_file="$config_file" fi + #================================================= + # MODIFY ENCRYPT SETTING + #================================================= + # Change encrypt in the config file ynh_replace_string --match_string="^encrypt=.*" --replace_string="encrypt=$encrypt" --target_file="$config_file" + #================================================= + # MODIFY SETTINGS + #================================================= + # Change ynh_core_backup in the config file ynh_replace_string --match_string="^ynh_core_backup=.*" --replace_string="ynh_core_backup=$ynh_core_backup" --target_file="$config_file" @@ -161,10 +181,18 @@ apply_config() { # Change max_size in the config file ynh_replace_string --match_string="^max_size=.*" --replace_string="max_size=$max_size" --target_file="$config_file" + #================================================= + # MODIFY OVERWRITTING SETTINGS + #================================================= + # Set overwrite_cron overwrite_cron=$(bool_to_01 $overwrite_cron) ynh_app_setting_set --app=$app --key=overwrite_cron --value="$overwrite_cron" + #================================================= + # MODIFY EMAIL SETTING + #================================================= + # Set admin_mail_html admin_mail_html=$(bool_to_01 $admin_mail_html) ynh_app_setting_set --app=$app --key=admin_mail_html --value="$admin_mail_html" From 9b3cfeab5b1260ce0d277f81bfd32e5326a2118d Mon Sep 17 00:00:00 2001 From: maniack Date: Tue, 3 Dec 2019 22:16:46 +0100 Subject: [PATCH 2/3] Update to v1.0 --- CHANGELOG.md | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++ README.md | 2 +- README_fr.md | 2 +- conf/app.src | 4 ++-- manifest.json | 2 +- 5 files changed, 58 insertions(+), 5 deletions(-) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..9e1f904 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,53 @@ +Changelog +========= + +## Unreleased +- [Use toml for config-panel and actions](https://github.com/YunoHost-Apps/archivist_ynh/pull/21/commits/21b7e746095a9dccf9dda9a58cc8ec5afdd87736) +- [Update to v1.0 (Add support of BACKUP_CORE_ONLY)]() + +## [0.9~ynh1](https://github.com/YunoHost-Apps/archivist_ynh/pull/18) - 2019-08-12 + +#### Changed +* [Update to v0.9 (Recreate enc_backup_dir)](https://github.com/YunoHost-Apps/archivist_ynh/pull/19/commits/536e472adac15e9b6064cac5df5bf7656bc82437) + +## [0.8~ynh1](https://github.com/YunoHost-Apps/archivist_ynh/pull/18) - 2019-06-30 + +#### Changed +* [Update to v0.8 (Add b2 sender)](https://github.com/YunoHost-Apps/archivist_ynh/pull/18/commits/3a52c10afeb129fb62779e9370bb27a052375d02) + + +## [0.7~ynh3](https://github.com/YunoHost-Apps/archivist_ynh/pull/16) - 2019-02-03 + +#### Added +- [Add progression bar](https://github.com/YunoHost-Apps/archivist_ynh/pull/16/commits/c626cb05d0f28d570f0eabbf6dbd13ca42ba58e4) +* [Changelog & html email](https://github.com/YunoHost-Apps/archivist_ynh/pull/16/commits/0b5345ba355c0ea0ebd86a1c5f076097d83c9118) + + +## [0.7~ynh2](https://github.com/YunoHost-Apps/archivist_ynh/pull/15) - 2019-01-21 + +#### Changed +- [Update to last standart](https://github.com/YunoHost-Apps/archivist_ynh/pull/15/commits/1c783c7376ed5a1013e4a88b3a4056bddb679b8c) + + +## [0.7~ynh1](https://github.com/YunoHost-Apps/archivist_ynh/pull/14) - 2018-11-24 + +#### Changed +* [Update to v0.7 (Fix backup --ignore arguments)](https://github.com/YunoHost-Apps/archivist_ynh/pull/14/commits/8c23cb555883676e80f1110b197ce821f5c66e1c) + + +## [0.6~ynh2](https://github.com/YunoHost-Apps/archivist_ynh/pull/13) - 2018-09-30 + +#### Added +* [Add actions and config-panel](https://github.com/YunoHost-Apps/archivist_ynh/pull/13/commits/ee8fd678273ca38df12b826f765544b8a00e1e39) + + +## [0.6~ynh2](https://github.com/YunoHost-Apps/archivist_ynh/pull/11) - 2018-07-16 + +#### Changed +- [Upgrade helpers](https://github.com/YunoHost-Apps/archivist_ynh/pull/11/commits/d3b202985184d475725cff72d75d79dc922926cb) + + +## [0.6~ynh1](https://github.com/YunoHost-Apps/archivist_ynh/pull/5) - 2018-01-04 + +#### Changed +* [Update to 0.6 (Pre and post backup)](https://github.com/YunoHost-Apps/archivist_ynh/pull/5/commits/11a5747a450745801acd6a47e609c054759d1224) diff --git a/README.md b/README.md index 4589a91..1e9d26c 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ It can also makes backups of specified directories. Your backups can be send to many other places, local or distant. Archivist is automatically launched periodicaly to update your backups and send the modifications to the other places. -**Shipped version:** 0.9 +**Shipped version:** 1.0 ## Screenshots diff --git a/README_fr.md b/README_fr.md index 07a4bb6..82602cd 100644 --- a/README_fr.md +++ b/README_fr.md @@ -15,7 +15,7 @@ Il peut également faire des sauvegardes de répertoires spécifiques. Vos sauvegardes peuvent être envoyées à de nombreux autres endroits, locaux ou distants. Archivist est automatiquement lancé périodiquement pour mettre à jour vos sauvegardes et envoyer les modifications aux autres emplacements. -**Version embarquée:** 0.9 +**Version embarquée:** 1.0 ## Captures d'écran diff --git a/conf/app.src b/conf/app.src index 9ffc186..40ea796 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,5 +1,5 @@ -SOURCE_URL=https://github.com/maniackcrudelis/archivist/archive/v0.9.tar.gz -SOURCE_SUM=d67285ff66909faa31f696fc552015a4 +SOURCE_URL=https://github.com/maniackcrudelis/archivist/archive/v1.0.tar.gz +SOURCE_SUM=1f98a67aae8b5c4f76e43cb027f4f3bf SOURCE_SUM_PRG=md5sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true diff --git a/manifest.json b/manifest.json index 0492606..434829e 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "Automatic backups.", "fr": "Sauvegardes automatiques." }, - "version": "0.9~ynh1", + "version": "1.0~ynh1", "url": "https://github.com/maniackcrudelis/archivist", "license": "GPL-3.0", "maintainer": { From 54ec7318b60b8b23195c555d352d4310508e6ba7 Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Tue, 3 Dec 2019 22:19:23 +0100 Subject: [PATCH 3/3] Update CHANGELOG.md --- CHANGELOG.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9e1f904..5a16b8d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,8 +2,13 @@ Changelog ========= ## Unreleased +- Nothing for now... + +## [1.0~ynh1](https://github.com/YunoHost-Apps/archivist_ynh/pull/21) - 2019-12-03 + +#### Changed - [Use toml for config-panel and actions](https://github.com/YunoHost-Apps/archivist_ynh/pull/21/commits/21b7e746095a9dccf9dda9a58cc8ec5afdd87736) -- [Update to v1.0 (Add support of BACKUP_CORE_ONLY)]() +* [Update to v1.0 (Add support of BACKUP_CORE_ONLY)](https://github.com/YunoHost-Apps/archivist_ynh/pull/21/commits/9b3cfeab5b1260ce0d277f81bfd32e5326a2118d) ## [0.9~ynh1](https://github.com/YunoHost-Apps/archivist_ynh/pull/18) - 2019-08-12